From 20bbef04c4344b6e53645ad934db20888b98bccf Mon Sep 17 00:00:00 2001 From: Hari Shreedharan Date: Fri, 12 Jul 2013 16:29:52 -0700 Subject: [PATCH] SQOOP-1105. Sqoop2: Remove our implementation of StringUtils (Raghav Kumar Gautam via Hari Shreedharan) --- .../sqoop/client/utils/FormDisplayer.java | 2 +- .../sqoop/json/util/FormSerialization.java | 2 +- .../org/apache/sqoop/model/MEnumInput.java | 2 +- .../org/apache/sqoop/utils/StringUtils.java | 51 ------------------- .../apache/sqoop/utils/TestStringUtils.java | 35 ------------- repository/repository-derby/pom.xml | 5 ++ .../derby/DerbyRepositoryHandler.java | 2 +- 7 files changed, 9 insertions(+), 90 deletions(-) delete mode 100644 common/src/main/java/org/apache/sqoop/utils/StringUtils.java delete mode 100644 common/src/test/java/org/apache/sqoop/utils/TestStringUtils.java diff --git a/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java b/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java index 0a0f319b..b044e222 100644 --- a/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java +++ b/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java @@ -17,6 +17,7 @@ */ package org.apache.sqoop.client.utils; +import org.apache.commons.lang.StringUtils; import org.apache.sqoop.client.core.Constants; import org.apache.sqoop.model.MAccountableEntity; import org.apache.sqoop.model.MBooleanInput; @@ -31,7 +32,6 @@ import org.apache.sqoop.model.MJobForms; import org.apache.sqoop.model.MMapInput; import org.apache.sqoop.model.MStringInput; -import org.apache.sqoop.utils.StringUtils; import org.apache.sqoop.validation.Status; import java.util.ArrayList; diff --git a/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java b/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java index 05a08781..98768d6c 100644 --- a/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java +++ b/common/src/main/java/org/apache/sqoop/json/util/FormSerialization.java @@ -17,6 +17,7 @@ */ package org.apache.sqoop.json.util; +import org.apache.commons.lang.StringUtils; import org.apache.sqoop.model.MBooleanInput; import org.apache.sqoop.model.MEnumInput; import org.apache.sqoop.model.MForm; @@ -26,7 +27,6 @@ import org.apache.sqoop.model.MIntegerInput; import org.apache.sqoop.model.MMapInput; import org.apache.sqoop.model.MStringInput; -import org.apache.sqoop.utils.StringUtils; import org.json.simple.JSONArray; import org.json.simple.JSONObject; diff --git a/common/src/main/java/org/apache/sqoop/model/MEnumInput.java b/common/src/main/java/org/apache/sqoop/model/MEnumInput.java index 620c8400..28830f40 100644 --- a/common/src/main/java/org/apache/sqoop/model/MEnumInput.java +++ b/common/src/main/java/org/apache/sqoop/model/MEnumInput.java @@ -17,8 +17,8 @@ */ package org.apache.sqoop.model; +import org.apache.commons.lang.StringUtils; import org.apache.sqoop.common.SqoopException; -import org.apache.sqoop.utils.StringUtils; import java.util.Arrays; diff --git a/common/src/main/java/org/apache/sqoop/utils/StringUtils.java b/common/src/main/java/org/apache/sqoop/utils/StringUtils.java deleted file mode 100644 index 97d356a4..00000000 --- a/common/src/main/java/org/apache/sqoop/utils/StringUtils.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sqoop.utils; - -/** - * Convenience String methods. - * - * We might consider replacing this with commons-lang library at some point. - */ -public final class StringUtils { - - public static String join(String []array, String separator) { - if(array == null) { - return null; - } - - StringBuilder sb = new StringBuilder(); - boolean first = true; - - for(String item : array) { - if(first) { - first = false; - } else { - sb.append(separator); - } - - sb.append(item); - } - - return sb.toString(); - } - - private StringUtils() { - // Instantiation is prohibited - } -} diff --git a/common/src/test/java/org/apache/sqoop/utils/TestStringUtils.java b/common/src/test/java/org/apache/sqoop/utils/TestStringUtils.java deleted file mode 100644 index e0ca2ec4..00000000 --- a/common/src/test/java/org/apache/sqoop/utils/TestStringUtils.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sqoop.utils; - -import junit.framework.TestCase; - -/** - * - */ -public class TestStringUtils extends TestCase { - - public void testJoin() { - assertNull(StringUtils.join(null, "a")); - - String []a = new String[] {"a", "b", "c"}; - - assertEquals("a,b,c", StringUtils.join(a, ",")); - assertEquals("abc", StringUtils.join(a, "")); - } -} diff --git a/repository/repository-derby/pom.xml b/repository/repository-derby/pom.xml index f6cf60d6..6ad6d64d 100644 --- a/repository/repository-derby/pom.xml +++ b/repository/repository-derby/pom.xml @@ -42,6 +42,11 @@ limitations under the License. derby + + commons-lang + commons-lang + + junit junit diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java index 72c72bbf..f717abff 100644 --- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java +++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java @@ -39,6 +39,7 @@ import javax.sql.DataSource; import org.apache.log4j.Logger; +import org.apache.commons.lang.StringUtils; import org.apache.sqoop.common.SqoopException; import org.apache.sqoop.model.MBooleanInput; import org.apache.sqoop.model.MConnection; @@ -63,7 +64,6 @@ import org.apache.sqoop.submission.counter.Counter; import org.apache.sqoop.submission.counter.CounterGroup; import org.apache.sqoop.submission.counter.Counters; -import org.apache.sqoop.utils.StringUtils; /** * JDBC based repository handler for Derby database.