PIG-5317: Upgrade old dependencies: commons-lang, hsqldb, commons-logging (nkollar via rohini)

git-svn-id: https://svn.apache.org/repos/asf/pig/trunk@1819863 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/CHANGES.txt b/CHANGES.txt
index d382b41..7fc8a4a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -26,6 +26,8 @@
  
 IMPROVEMENTS
 
+PIG-5317: Upgrade old dependencies: commons-lang, hsqldb, commons-logging (nkollar via rohini)
+
 PIG-5322: ConstantCalculator optimizer is not applied for split (rohini)
 
 PIG-5316: Initialize mapred.task.id property for PoS jobs (nkollar via szita)
diff --git a/build.xml b/build.xml
index 40f0695..8bcbe5e 100644
--- a/build.xml
+++ b/build.xml
@@ -772,7 +772,7 @@
             <fileset dir="${ivy.lib.dir}" includes="commons-cli-*.jar"/>
             <fileset dir="${ivy.lib.dir}" includes="commons-configuration-*.jar"/>
             <fileset dir="${ivy.lib.dir}" includes="commons-collections-*.jar"/>
-            <fileset dir="${ivy.lib.dir}" includes="commons-lang-*.jar"/>
+            <fileset dir="${ivy.lib.dir}" includes="commons-lang3-*.jar"/>
             <fileset dir="${ivy.lib.dir}" includes="commons-codec-*.jar"/>
             <fileset dir="${ivy.lib.dir}" includes="commons-io-*.jar"/>
             <fileset dir="${ivy.lib.dir}" includes="commons-logging-*.jar"/>
@@ -1079,7 +1079,7 @@
             <fileset dir="${test.build.classes}">
                 <include name="**/org/apache/pig/test/**"/>
             </fileset>
-            <zipfileset src="${ivy.lib.dir}/commons-lang-${commons-lang.version}.jar" />
+            <zipfileset src="${ivy.lib.dir}/commons-lang3-${commons-lang3.version}.jar" />
         </jar>
     </target>
 
@@ -1094,7 +1094,7 @@
                 <include name="**/org/apache/pig/pigunit/**"/>
                 <include name="**/org/apache/pig/test/Util.**"/>
             </fileset>
-            <zipfileset src="${ivy.lib.dir}/commons-lang-${commons-lang.version}.jar" />
+            <zipfileset src="${ivy.lib.dir}/commons-lang3-${commons-lang3.version}.jar" />
         </jar>
     </target>
 
diff --git a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/xml/XPathAllTest.java b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/xml/XPathAllTest.java
index fe2acea..c5317c2 100644
--- a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/xml/XPathAllTest.java
+++ b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/xml/XPathAllTest.java
@@ -19,7 +19,7 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import org.apache.commons.lang.math.RandomUtils;
+import org.apache.commons.lang3.RandomUtils;
 import org.apache.pig.data.Tuple;
 import org.apache.pig.data.TupleFactory;
 import org.apache.pig.piggybank.evaluation.xml.XPathAll;
@@ -356,7 +356,7 @@
 
         final StringBuilder sb = new StringBuilder();
 
-        final int max = RandomUtils.nextInt(100);
+        final int max = RandomUtils.nextInt(0, 100);
 
         for (int i = 0; i < max; i++) {
             sb.append("<expansion>This is an expansion of the xml to simulate random sized xml" + i + "</expansion>");
diff --git a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/xml/XPathTest.java b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/xml/XPathTest.java
index 646a55f..a7a8646 100644
--- a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/xml/XPathTest.java
+++ b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/evaluation/xml/XPathTest.java
@@ -17,7 +17,7 @@
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import org.apache.commons.lang.math.RandomUtils;
+import org.apache.commons.lang3.RandomUtils;
 import org.apache.pig.data.Tuple;
 import org.apache.pig.data.TupleFactory;
 import org.apache.pig.piggybank.evaluation.xml.XPath;
@@ -314,7 +314,7 @@
         
         final StringBuilder sb = new StringBuilder();
         
-        final int max = RandomUtils.nextInt(100);
+        final int max = RandomUtils.nextInt(0, 100);
         
         for(int i = 0; i < max; i++) {
             sb.append("<expansion>This is an expansion of the xml to simulate random sized xml" + i + "</expansion>"); 
diff --git a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestCSVExcelStorage.java b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestCSVExcelStorage.java
index 9cdfa95..3717c4f 100644
--- a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestCSVExcelStorage.java
+++ b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestCSVExcelStorage.java
@@ -25,7 +25,7 @@
 import java.util.Iterator;
 import java.util.Properties;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.pig.ExecType;
 import org.apache.pig.PigServer;
 import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MRConfiguration;
diff --git a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestDBStorage.java b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestDBStorage.java
index 5c6b8cc..3fec174 100644
--- a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestDBStorage.java
+++ b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestDBStorage.java
@@ -30,10 +30,12 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Date;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 
 import org.apache.pig.ExecType;
 import org.apache.pig.PigServer;
-import org.apache.pig.backend.executionengine.ExecException;
 import org.apache.pig.backend.executionengine.ExecJob;
 import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MRConfiguration;
 import org.apache.pig.test.MiniGenericCluster;
@@ -56,15 +58,13 @@
     private String driver = "org.hsqldb.jdbcDriver";
     // private String url = "jdbc:hsqldb:mem:.";
     private String TMP_DIR;
-    private String dblocation;
-    private String url;
-    private String dbUrl = "jdbc:hsqldb:hsql://localhost/" + "batchtest";
+    private String dbUrl = "jdbc:hsqldb:hsql://localhost/batchtest";
     private String user = "sa";
     private String password = "";
 
     private static final String INPUT_FILE = "datafile.txt";
 
-    public TestDBStorage() throws ExecException, IOException {
+    public TestDBStorage() throws IOException {
         // Initialise Pig server
         cluster = MiniGenericCluster.buildCluster();
         pigServer = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
@@ -74,15 +74,13 @@
                 .setProperty(MRConfiguration.REDUCE_MAX_ATTEMPTS, "1");
         System.out.println("Pig server initialized successfully");
         TMP_DIR = System.getProperty("user.dir") + "/build/test/";
-        dblocation = TMP_DIR + "batchtest";
-        url = "jdbc:hsqldb:file:" + dblocation
-               + ";hsqldb.default_table_type=cached;hsqldb.cache_rows=100";
         // Initialise DBServer
         dbServer = new Server();
         dbServer.setDatabaseName(0, "batchtest");
         // dbServer.setDatabasePath(0, "mem:test;sql.enforce_strict_size=true");
         dbServer.setDatabasePath(0,
-                            "file:" + TMP_DIR + "batchtest;sql.enforce_strict_size=true");
+                            "file:" + TMP_DIR + "batchtest;"+
+                            "hsqldb.default_table_type=cached;hsqldb.cache_rows=100;sql.enforce_strict_size=true");
         dbServer.setLogWriter(null);
         dbServer.setErrWriter(null);
         dbServer.start();
@@ -98,7 +96,6 @@
 
     private void createFile() throws IOException {
         PrintWriter w = new PrintWriter(new FileWriter(INPUT_FILE));
-        w = new PrintWriter(new FileWriter(INPUT_FILE));
         w.println("100\tapple\t1.0\t2008-01-01");
         w.println("100\torange\t2.0\t2008-02-01");
         w.println("100\tbanana\t1.1\t2008-03-01");
@@ -111,7 +108,7 @@
         Connection con = null;
         String sql = "create table ttt (id integer, name varchar(32), ratio double, dt date)";
         try {
-            con = DriverManager.getConnection(url, user, password);
+            con = DriverManager.getConnection(dbUrl, user, password);
         } catch (SQLException sqe) {
             throw new IOException("Unable to obtain a connection to the database",
                     sqe);
@@ -159,11 +156,11 @@
     }
 
     @Test
-    public void testWriteToDB() throws IOException {
+    public void testWriteToDB() throws IOException, InterruptedException, ParseException {
         String insertQuery = "insert into ttt (id, name, ratio, dt) values (?,?,?,?)";
         pigServer.setBatchOn();
         String dbStore = "org.apache.pig.piggybank.storage.DBStorage('" + driver
-                + "', '" + Util.encodeEscape(url) + "', '" + insertQuery + "');";
+                + "', '" + Util.encodeEscape(dbUrl) + "', '" + insertQuery + "');";
         pigServer.registerQuery("A = LOAD '" + INPUT_FILE
                 + "' as (id:int, fruit:chararray, ratio:double, dt : datetime);");
         pigServer.registerQuery("STORE A INTO 'dummy' USING " + dbStore);
@@ -179,7 +176,7 @@
         Connection con = null;
         String selectQuery = "select id, name, ratio, dt from ttt order by name";
         try {
-            con = DriverManager.getConnection(url, user, password);
+            con = DriverManager.getConnection(dbUrl, user, password);
         } catch (SQLException sqe) {
             throw new IOException(
                     "Unable to obtain database connection for data verification", sqe);
@@ -189,10 +186,14 @@
             ResultSet rs = ps.executeQuery();
 
             int expId = 100;
-            String[] expNames = { "apple", "banana", "orange" };
-            double[] expRatios = { 1.0, 1.1, 2.0 };
-                        Date []  expDates = {new Date(2008,01,01),new Date(2008,02,01),new Date(2008,03,01)};
-            for (int i = 0; i < 4 && rs.next(); i++) {
+            String[] expNames = {"apple", "banana", "orange"};
+            double[] expRatios = {1.0, 1.1, 2.0};
+            DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+            Date[] expDates = {new Date(df.parse("2008-01-01").getTime()),
+                new Date(df.parse("2008-03-01").getTime()),
+                new Date(df.parse("2008-02-01").getTime())};
+            for (int i = 0; i < 4; i++) {
+                rs.next();
                 //Need to check for nulls explicitly.
                 if ( i == 0) {
                     //Id
diff --git a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestFixedWidthLoader.java b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestFixedWidthLoader.java
index 4d9a0c1..f64155e 100644
--- a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestFixedWidthLoader.java
+++ b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestFixedWidthLoader.java
@@ -22,9 +22,7 @@
 import java.io.IOException;
 import java.util.Iterator;
 
-import junit.framework.TestCase;
-
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 
 import org.apache.pig.ExecType;
 import org.apache.pig.data.Tuple;
diff --git a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestFixedWidthStorer.java b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestFixedWidthStorer.java
index c262c21..863f3f7 100644
--- a/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestFixedWidthStorer.java
+++ b/contrib/piggybank/java/src/test/java/org/apache/pig/piggybank/test/storage/TestFixedWidthStorer.java
@@ -24,7 +24,7 @@
 
 import org.junit.Assert;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 
 import org.apache.pig.ExecType;
 import org.apache.pig.data.Tuple;
diff --git a/ivy.xml b/ivy.xml
index ef2ca0a..3ac6751 100644
--- a/ivy.xml
+++ b/ivy.xml
@@ -224,8 +224,6 @@
     <dependency org="org.fusesource.jansi" name="jansi" rev="${jansi.version}"
       conf="compile->master"/>
     <dependency org="joda-time" name="joda-time" rev="${joda-time.version}" conf="compile->master"/>
-    <dependency org="commons-lang" name="commons-lang" rev="${commons-lang.version}"
-      conf="compile->master"/>
     <dependency org="com.google.guava" name="guava" rev="${guava.version}" conf="compile->master" />
     <dependency org="org.python" name="jython-standalone" rev="${jython.version}" conf="compile->master"/>
     <dependency org="rhino" name="js" rev="${rhino.version}" conf="compile->master"/>
@@ -364,7 +362,7 @@
     </dependency>
 
     <!-- for piggybank -->
-    <dependency org="hsqldb" name="hsqldb" rev="${hsqldb.version}"
+    <dependency org="org.hsqldb" name="hsqldb" rev="${hsqldb.version}"
       conf="test->default" />
     <dependency org="org.apache.hive" name="hive-exec" rev="${hive.version}" conf="compile->master" changing="true">
       <artifact name="hive-exec" m:classifier="core" />
diff --git a/ivy/libraries.properties b/ivy/libraries.properties
index c638727..800b75e 100644
--- a/ivy/libraries.properties
+++ b/ivy/libraries.properties
@@ -25,8 +25,7 @@
 commons-codec.version=1.4
 commons-io.version=2.3
 commons-el.version=1.0
-commons-logging.version=1.1.1
-commons-lang.version=2.6
+commons-logging.version=1.2
 commons-configuration.version=1.6
 commons-collections.version=3.2.1
 commons-collections4.version=4.0
@@ -40,7 +39,7 @@
 hadoop-hdfs.version=2.7.3
 hadoop-mapreduce.version=2.7.3
 hbase1.version=1.2.4
-hsqldb.version=1.8.0.10
+hsqldb.version=2.4.0
 hive.version=1.2.1
 httpcomponents.version=4.4
 jackson.version=1.9.13
diff --git a/ivy/pig-template.xml b/ivy/pig-template.xml
index 5c930c9..43ecf63 100644
--- a/ivy/pig-template.xml
+++ b/ivy/pig-template.xml
@@ -34,11 +34,6 @@
       <version>1.4</version>
     </dependency>
     <dependency>
-      <groupId>commons-net</groupId>
-      <artifactId>commons-net</artifactId>
-      <version>3.1</version>
-    </dependency>
-    <dependency>
       <groupId>commons-el</groupId>
       <artifactId>commons-el</artifactId>
       <version>1.0</version>
@@ -59,9 +54,9 @@
       <version>4.11</version>
     </dependency>
     <dependency>
-      <groupId>hsqldb</groupId>
+      <groupId>org.hsqldb</groupId>
       <artifactId>hsqldb</artifactId>
-      <version>1.8.0.10</version>
+      <version>2.4.0</version>
     </dependency>
     <dependency>
       <groupId>jline</groupId>
diff --git a/ivy/piggybank-template.xml b/ivy/piggybank-template.xml
index 44fac48..5bbbe7c 100644
--- a/ivy/piggybank-template.xml
+++ b/ivy/piggybank-template.xml
@@ -24,9 +24,9 @@
   <version>@version</version>
   <dependencies>
     <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-      <version>2.6</version>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>3.6</version>
     </dependency>
     <dependency>
       <groupId>log4j</groupId>
@@ -36,7 +36,7 @@
     <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
-      <version>1.1.1</version>
+      <version>1.2</version>
     </dependency>
     <dependency>
       <groupId>commons-el</groupId>
@@ -92,9 +92,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>hsqldb</groupId>
+      <groupId>org.hsqldb</groupId>
       <artifactId>hsqldb</artifactId>
-      <version>1.8.0.10</version>
+      <version>2.4.0</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
diff --git a/ivy/pigunit-template.xml b/ivy/pigunit-template.xml
index ae64384..de900d7 100644
--- a/ivy/pigunit-template.xml
+++ b/ivy/pigunit-template.xml
@@ -24,9 +24,9 @@
   <version>@version</version>
   <dependencies>
     <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-      <version>2.6</version>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>3.6</version>
     </dependency>
     <dependency>
       <groupId>log4j</groupId>
@@ -36,7 +36,7 @@
     <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
-      <version>1.1.1</version>
+      <version>1.2</version>
     </dependency>
     <dependency>
       <groupId>com.google.guava</groupId>
diff --git a/src/org/apache/pig/PigServer.java b/src/org/apache/pig/PigServer.java
index c35fd31..f8eab63 100644
--- a/src/org/apache/pig/PigServer.java
+++ b/src/org/apache/pig/PigServer.java
@@ -44,7 +44,6 @@
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
diff --git a/src/org/apache/pig/backend/hadoop/accumulo/AbstractAccumuloStorage.java b/src/org/apache/pig/backend/hadoop/accumulo/AbstractAccumuloStorage.java
index a96d095..6dac450 100644
--- a/src/org/apache/pig/backend/hadoop/accumulo/AbstractAccumuloStorage.java
+++ b/src/org/apache/pig/backend/hadoop/accumulo/AbstractAccumuloStorage.java
@@ -43,7 +43,7 @@
 import org.apache.accumulo.core.util.Pair;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.ParseException;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
diff --git a/src/org/apache/pig/backend/hadoop/accumulo/AccumuloStorageOptions.java b/src/org/apache/pig/backend/hadoop/accumulo/AccumuloStorageOptions.java
index 8e4a610..088ade8 100644
--- a/src/org/apache/pig/backend/hadoop/accumulo/AccumuloStorageOptions.java
+++ b/src/org/apache/pig/backend/hadoop/accumulo/AccumuloStorageOptions.java
@@ -23,7 +23,7 @@
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 
 public class AccumuloStorageOptions {
     public static final Option CASTER_OPTION = new Option(
diff --git a/src/org/apache/pig/backend/hadoop/executionengine/tez/TezJob.java b/src/org/apache/pig/backend/hadoop/executionengine/tez/TezJob.java
index 80ef5ad..d561904 100644
--- a/src/org/apache/pig/backend/hadoop/executionengine/tez/TezJob.java
+++ b/src/org/apache/pig/backend/hadoop/executionengine/tez/TezJob.java
@@ -23,7 +23,7 @@
 import java.util.Timer;
 import java.util.TimerTask;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
diff --git a/src/org/apache/pig/backend/hadoop/executionengine/tez/util/TezCompilerUtil.java b/src/org/apache/pig/backend/hadoop/executionengine/tez/util/TezCompilerUtil.java
index 99d8857..5f2fda9 100644
--- a/src/org/apache/pig/backend/hadoop/executionengine/tez/util/TezCompilerUtil.java
+++ b/src/org/apache/pig/backend/hadoop/executionengine/tez/util/TezCompilerUtil.java
@@ -23,7 +23,7 @@
 import java.util.List;
 import java.util.Set;
 
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.pig.PigException;
 import org.apache.pig.backend.executionengine.ExecException;
 import org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator;
diff --git a/src/org/apache/pig/tools/grunt/GruntParser.java b/src/org/apache/pig/tools/grunt/GruntParser.java
index a5d4495..e27ca8f 100644
--- a/src/org/apache/pig/tools/grunt/GruntParser.java
+++ b/src/org/apache/pig/tools/grunt/GruntParser.java
@@ -44,7 +44,7 @@
 import jline.console.ConsoleReader;
 
 import org.apache.commons.io.output.NullOutputStream;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.fs.FileSystem;
diff --git a/src/org/apache/pig/tools/pigstats/tez/TezPigScriptStats.java b/src/org/apache/pig/tools/pigstats/tez/TezPigScriptStats.java
index 5bce44d..fde621c 100644
--- a/src/org/apache/pig/tools/pigstats/tez/TezPigScriptStats.java
+++ b/src/org/apache/pig/tools/pigstats/tez/TezPigScriptStats.java
@@ -23,7 +23,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.mapred.JobClient;
diff --git a/test/org/apache/pig/builtin/TestOrcStoragePushdown.java b/test/org/apache/pig/builtin/TestOrcStoragePushdown.java
index f0dc151..8a77030 100644
--- a/test/org/apache/pig/builtin/TestOrcStoragePushdown.java
+++ b/test/org/apache/pig/builtin/TestOrcStoragePushdown.java
@@ -31,8 +31,8 @@
 import java.util.HashSet;
 import java.util.List;
 
-import org.apache.commons.lang.RandomStringUtils;
-import org.apache.commons.lang.math.RandomUtils;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.commons.lang3.RandomUtils;
 import org.apache.hadoop.hive.ql.io.sarg.SearchArgument;
 import org.apache.log4j.FileAppender;
 import org.apache.log4j.Level;
@@ -143,12 +143,12 @@
                     .replaceAll("\n", " ").replaceAll("\r", " "))).append("\t"); //string
             int year;
             if (i > 5000 && i <= 8000) { //datetime
-                year = RandomUtils.nextInt(4)+2010;
+                year = RandomUtils.nextInt(0, 4)+2010;
             } else {
-                year = RandomUtils.nextInt(10)+2000;
+                year = RandomUtils.nextInt(0, 10)+2000;
             }
-            sb.append(new DateTime(year, RandomUtils.nextInt(12)+1,
-                    RandomUtils.nextInt(28)+1, RandomUtils.nextInt(24), RandomUtils.nextInt(60),
+            sb.append(new DateTime(year, RandomUtils.nextInt(0, 12)+1,
+                    RandomUtils.nextInt(0, 28)+1, RandomUtils.nextInt(0, 24), RandomUtils.nextInt(0, 60),
                     DateTimeZone.UTC).toString()).append("\t"); // datetime
             String bigString;
             if (i>7500) {
diff --git a/test/org/apache/pig/impl/streaming/TestStreamingUtil.java b/test/org/apache/pig/impl/streaming/TestStreamingUtil.java
index 8c20dbd..cd94a3e 100644
--- a/test/org/apache/pig/impl/streaming/TestStreamingUtil.java
+++ b/test/org/apache/pig/impl/streaming/TestStreamingUtil.java
@@ -26,7 +26,7 @@
 import java.util.Map;
 import java.util.Random;
 
-import org.apache.commons.lang.RandomStringUtils;
+import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.junit.Test;
 
diff --git a/test/org/apache/pig/pigunit/PigTest.java b/test/org/apache/pig/pigunit/PigTest.java
index 82b2c5c..3161c4d 100644
--- a/test/org/apache/pig/pigunit/PigTest.java
+++ b/test/org/apache/pig/pigunit/PigTest.java
@@ -18,7 +18,6 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.StringReader;
-import java.lang.Object;
 import java.nio.MappedByteBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.charset.Charset;
@@ -31,10 +30,9 @@
 import java.util.Map;
 import java.util.Set;
 
-import com.google.common.collect.Iterables;
 import org.junit.Assert;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.pig.ExecType;
 import org.apache.pig.ExecTypeProvider;
diff --git a/test/org/apache/pig/test/SparkMiniCluster.java b/test/org/apache/pig/test/SparkMiniCluster.java
index 27f7f8c..f51bc18 100644
--- a/test/org/apache/pig/test/SparkMiniCluster.java
+++ b/test/org/apache/pig/test/SparkMiniCluster.java
@@ -17,19 +17,8 @@
  */
 package org.apache.pig.test;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.apache.hadoop.mapreduce.v2.MiniMRYarnCluster;
-import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.pig.ExecType;
 import org.apache.pig.backend.hadoop.executionengine.Launcher;
 import org.apache.pig.backend.hadoop.executionengine.spark.SparkExecType;
diff --git a/test/org/apache/pig/test/TestJobControlCompiler.java b/test/org/apache/pig/test/TestJobControlCompiler.java
index 22aa638..2c39964 100644
--- a/test/org/apache/pig/test/TestJobControlCompiler.java
+++ b/test/org/apache/pig/test/TestJobControlCompiler.java
@@ -46,7 +46,7 @@
 import javax.tools.StandardJavaFileManager;
 import javax.tools.ToolProvider;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.filecache.DistributedCache;
 import org.apache.hadoop.fs.FileSystem;
diff --git a/test/org/apache/pig/test/TestLogToPhyCompiler.java b/test/org/apache/pig/test/TestLogToPhyCompiler.java
index d091012..5751e5c 100644
--- a/test/org/apache/pig/test/TestLogToPhyCompiler.java
+++ b/test/org/apache/pig/test/TestLogToPhyCompiler.java
@@ -32,7 +32,6 @@
 import java.util.Properties;
 import java.util.Random;
 
-import org.apache.commons.lang.CharSet;
 import org.apache.pig.ExecType;
 import org.apache.pig.PigServer;
 import org.apache.pig.SortColInfo;
diff --git a/test/org/apache/pig/test/TestPigRunner.java b/test/org/apache/pig/test/TestPigRunner.java
index ac106e0..101fc96 100644
--- a/test/org/apache/pig/test/TestPigRunner.java
+++ b/test/org/apache/pig/test/TestPigRunner.java
@@ -41,13 +41,11 @@
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.mapred.Counters;
-import org.apache.pig.ExecType;
 import org.apache.pig.PigConfiguration;
 import org.apache.pig.PigRunner;
 import org.apache.pig.PigRunner.ReturnCode;
 import org.apache.pig.backend.hadoop.datastorage.ConfigurationUtil;
 import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MRConfiguration;
-import org.apache.pig.backend.hadoop.executionengine.spark.SparkExecType;
 import org.apache.pig.impl.PigContext;
 import org.apache.pig.impl.io.FileLocalizer;
 import org.apache.pig.impl.plan.OperatorPlan;
diff --git a/test/org/apache/pig/test/TezMiniCluster.java b/test/org/apache/pig/test/TezMiniCluster.java
index 2e76d76..ca98246 100644
--- a/test/org/apache/pig/test/TezMiniCluster.java
+++ b/test/org/apache/pig/test/TezMiniCluster.java
@@ -21,16 +21,10 @@
 import java.io.FileFilter;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.util.Map.Entry;
 
 import org.apache.commons.io.filefilter.RegexFileFilter;
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hdfs.MiniDFSCluster;
-import org.apache.hadoop.mapreduce.v2.MiniMRYarnCluster;
-import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.pig.ExecType;
 import org.apache.pig.PigConfiguration;
 import org.apache.pig.backend.hadoop.executionengine.Launcher;
@@ -38,7 +32,6 @@
 import org.apache.pig.backend.hadoop.executionengine.tez.TezLauncher;
 import org.apache.pig.backend.hadoop.executionengine.tez.TezSessionManager;
 import org.apache.tez.dag.api.TezConfiguration;
-import org.apache.tez.mapreduce.hadoop.MRJobConfig;
 import org.apache.tez.runtime.library.api.TezRuntimeConfiguration;
 
 public class TezMiniCluster extends YarnMiniCluster {
diff --git a/test/org/apache/pig/test/YarnMiniCluster.java b/test/org/apache/pig/test/YarnMiniCluster.java
index 9dac04b..69d8081 100644
--- a/test/org/apache/pig/test/YarnMiniCluster.java
+++ b/test/org/apache/pig/test/YarnMiniCluster.java
@@ -22,14 +22,13 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.mapreduce.MRJobConfig;
 import org.apache.hadoop.mapreduce.v2.MiniMRYarnCluster;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
-import org.apache.pig.ExecType;
 
 public abstract class YarnMiniCluster extends MiniGenericCluster {
     protected static final File CONF_DIR = new File("build/classes");
diff --git a/test/org/apache/pig/test/pigunit/TestPigTest.java b/test/org/apache/pig/test/pigunit/TestPigTest.java
index 4657af3..596a079 100644
--- a/test/org/apache/pig/test/pigunit/TestPigTest.java
+++ b/test/org/apache/pig/test/pigunit/TestPigTest.java
@@ -28,7 +28,7 @@
 import java.util.Map;
 import java.util.Properties;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.fs.Path;
diff --git a/test/org/apache/pig/tez/TestTezAutoParallelism.java b/test/org/apache/pig/tez/TestTezAutoParallelism.java
index dbd4891..771fee9 100644
--- a/test/org/apache/pig/tez/TestTezAutoParallelism.java
+++ b/test/org/apache/pig/tez/TestTezAutoParallelism.java
@@ -31,7 +31,7 @@
 import java.util.Properties;
 import java.util.Random;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;