Repository: sqoop Updated Branches: refs/heads/trunk c0b9bc435 -> 4a74b8bce
http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/oracle/TestOraOopUtilities.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/oracle/TestOraOopUtilities.java b/src/test/org/apache/sqoop/manager/oracle/TestOraOopUtilities.java index 93592af..0e8f3fe 100644 --- a/src/test/org/apache/sqoop/manager/oracle/TestOraOopUtilities.java +++ b/src/test/org/apache/sqoop/manager/oracle/TestOraOopUtilities.java @@ -23,11 +23,12 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import junit.framework.Assert; - import org.apache.hadoop.conf.Configuration; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + /** * Unit tests for OraOopUtilities. */ @@ -48,60 +49,60 @@ public class TestOraOopUtilities extends OraOopTestCase { // table context = OraOopUtilities.decodeOracleTableName("oraoop", "junk", null); - Assert.assertEquals(context.getSchema(), "ORAOOP"); - Assert.assertEquals(context.getName(), "JUNK"); + assertEquals(context.getSchema(), "ORAOOP"); + assertEquals(context.getName(), "JUNK"); // "table" context = OraOopUtilities.decodeOracleTableName("oraoop", "\"Junk\"", null); - Assert.assertEquals(context.getSchema(), "ORAOOP"); - Assert.assertEquals(context.getName(), "Junk"); + assertEquals(context.getSchema(), "ORAOOP"); + assertEquals(context.getName(), "Junk"); // schema.table context = OraOopUtilities.decodeOracleTableName("oraoop", "targusr.junk", null); - Assert.assertEquals(context.getSchema(), "TARGUSR"); - Assert.assertEquals(context.getName(), "JUNK"); + assertEquals(context.getSchema(), "TARGUSR"); + assertEquals(context.getName(), "JUNK"); // schema."table" context = OraOopUtilities.decodeOracleTableName("oraoop", "targusr.\"Junk\"", null); - Assert.assertEquals(context.getSchema(), "TARGUSR"); - Assert.assertEquals(context.getName(), "Junk"); + assertEquals(context.getSchema(), "TARGUSR"); + assertEquals(context.getName(), "Junk"); // "schema".table context = OraOopUtilities.decodeOracleTableName("oraoop", "\"Targusr\".junk", null); - Assert.assertEquals(context.getSchema(), "Targusr"); - Assert.assertEquals(context.getName(), "JUNK"); + assertEquals(context.getSchema(), "Targusr"); + assertEquals(context.getName(), "JUNK"); // "schema"."table" String inputStr = "\"Targusr\".\"Junk\""; context = OraOopUtilities.decodeOracleTableName("oraoop", inputStr, null); - Assert.assertEquals(context.getSchema(), "Targusr"); - Assert.assertEquals(context.getName(), "Junk"); + assertEquals(context.getSchema(), "Targusr"); + assertEquals(context.getName(), "Junk"); // Test for "." within schema... context = OraOopUtilities.decodeOracleTableName("oraoop", "\"targ.usr\".junk", null); - Assert.assertEquals(context.getSchema(), "targ.usr"); - Assert.assertEquals(context.getName(), "JUNK"); + assertEquals(context.getSchema(), "targ.usr"); + assertEquals(context.getName(), "JUNK"); // Test for "." within table... context = OraOopUtilities.decodeOracleTableName("oraoop", "targusr.\"junk.tab.with.dots\"", null); - Assert.assertEquals(context.getSchema(), "TARGUSR"); - Assert.assertEquals(context.getName(), "junk.tab.with.dots"); + assertEquals(context.getSchema(), "TARGUSR"); + assertEquals(context.getName(), "junk.tab.with.dots"); // Test for "." within schema and within table... context = OraOopUtilities.decodeOracleTableName("oraoop", "\"targ.usr\".\"junk.tab.with.dots\"", null); - Assert.assertEquals(context.getSchema(), "targ.usr"); - Assert.assertEquals(context.getName(), "junk.tab.with.dots"); + assertEquals(context.getSchema(), "targ.usr"); + assertEquals(context.getName(), "junk.tab.with.dots"); } @Test @@ -110,7 +111,7 @@ public class TestOraOopUtilities extends OraOopTestCase { String actual = OraOopUtilities.getCurrentMethodName(); String expected = "testgetCurrentMethodName()"; - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @@ -122,11 +123,11 @@ public class TestOraOopUtilities extends OraOopTestCase { expected = "1_1"; actual = OraOopUtilities.generateDataChunkId(1, 1); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); expected = "1234_99"; actual = OraOopUtilities.generateDataChunkId(1234, 99); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -134,7 +135,7 @@ public class TestOraOopUtilities extends OraOopTestCase { try { OraOopUtilities.getDuplicatedStringArrayValues(null, false); - Assert.fail("An IllegalArgumentException should be been thrown."); + fail("An IllegalArgumentException should be been thrown."); } catch (IllegalArgumentException ex) { // This is what we want to happen. } @@ -143,49 +144,49 @@ public class TestOraOopUtilities extends OraOopTestCase { duplicates = OraOopUtilities.getDuplicatedStringArrayValues(new String[] {}, false); - Assert.assertEquals(0, duplicates.length); + assertEquals(0, duplicates.length); duplicates = OraOopUtilities.getDuplicatedStringArrayValues(new String[] { "a", "b", "c", }, false); - Assert.assertEquals(0, duplicates.length); + assertEquals(0, duplicates.length); duplicates = OraOopUtilities.getDuplicatedStringArrayValues(new String[] { "a", "A", "b", }, false); - Assert.assertEquals(0, duplicates.length); + assertEquals(0, duplicates.length); duplicates = OraOopUtilities.getDuplicatedStringArrayValues(new String[] { "a", "A", "b", }, true); - Assert.assertEquals(1, duplicates.length); - Assert.assertEquals("A", duplicates[0]); + assertEquals(1, duplicates.length); + assertEquals("A", duplicates[0]); duplicates = OraOopUtilities.getDuplicatedStringArrayValues(new String[] { "A", "a", "b", }, true); - Assert.assertEquals(1, duplicates.length); - Assert.assertEquals("a", duplicates[0]); + assertEquals(1, duplicates.length); + assertEquals("a", duplicates[0]); duplicates = OraOopUtilities.getDuplicatedStringArrayValues(new String[] { "A", "a", "b", "A", }, false); - Assert.assertEquals(1, duplicates.length); - Assert.assertEquals("A", duplicates[0]); + assertEquals(1, duplicates.length); + assertEquals("A", duplicates[0]); duplicates = OraOopUtilities.getDuplicatedStringArrayValues(new String[] { "A", "a", "b", "A", }, true); - Assert.assertEquals(2, duplicates.length); - Assert.assertEquals("a", duplicates[0]); - Assert.assertEquals("A", duplicates[1]); + assertEquals(2, duplicates.length); + assertEquals("a", duplicates[0]); + assertEquals("A", duplicates[1]); duplicates = OraOopUtilities.getDuplicatedStringArrayValues(new String[] { "A", "a", "b", "A", "A", }, true); - Assert.assertEquals(2, duplicates.length); - Assert.assertEquals("a", duplicates[0]); - Assert.assertEquals("A", duplicates[1]); + assertEquals(2, duplicates.length); + assertEquals("a", duplicates[0]); + assertEquals("A", duplicates[1]); } @Test @@ -206,17 +207,14 @@ public class TestOraOopUtilities extends OraOopTestCase { } catch (Exception ex) { String msg = OraOopUtilities.getFullExceptionMessage(ex); if (!msg.contains("IOException") || !msg.contains("lorem ipsum!")) { - Assert - .fail("Inner exception text has not been included in the message"); + fail("Inner exception text has not been included in the message"); } if (!msg.contains("SQLException") || !msg.contains("dolor sit amet")) { - Assert - .fail("Inner exception text has not been included in the message"); + fail("Inner exception text has not been included in the message"); } if (!msg.contains("RuntimeException") || !msg.contains("consectetur adipisicing elit")) { - Assert - .fail("Outer exception text has not been included in the message"); + fail("Outer exception text has not been included in the message"); } } } @@ -225,7 +223,7 @@ public class TestOraOopUtilities extends OraOopTestCase { public void testGetOraOopOracleDataChunkMethod() { try { OraOopUtilities.getOraOopOracleDataChunkMethod(null); - Assert.fail("An IllegalArgumentException should be been thrown."); + fail("An IllegalArgumentException should be been thrown."); } catch (IllegalArgumentException ex) { // This is what we want to happen. } @@ -235,7 +233,7 @@ public class TestOraOopUtilities extends OraOopTestCase { // Check the default is ROWID dataChunkMethod = OraOopUtilities.getOraOopOracleDataChunkMethod(conf); - Assert.assertEquals(OraOopConstants.OraOopOracleDataChunkMethod.ROWID, + assertEquals(OraOopConstants.OraOopOracleDataChunkMethod.ROWID, dataChunkMethod); // Invalid value specified @@ -246,18 +244,17 @@ public class TestOraOopUtilities extends OraOopTestCase { String logText = OraOopUtilities.LOG.getLogEntries(); OraOopUtilities.LOG.setCacheLogEntries(false); if (!logText.toLowerCase().contains("loremipsum")) { - Assert - .fail("The LOG should inform the user they've selected an invalid " + fail("The LOG should inform the user they've selected an invalid " + "data chunk method - and what that was."); } - Assert.assertEquals("Should have used the default value", + assertEquals("Should have used the default value", OraOopConstants.ORAOOP_ORACLE_DATA_CHUNK_METHOD_DEFAULT, dataChunkMethod); // Valid value specified conf.set(OraOopConstants.ORAOOP_ORACLE_DATA_CHUNK_METHOD, "partition"); dataChunkMethod = OraOopUtilities.getOraOopOracleDataChunkMethod(conf); - Assert.assertEquals(OraOopConstants.OraOopOracleDataChunkMethod.PARTITION, + assertEquals(OraOopConstants.OraOopOracleDataChunkMethod.PARTITION, dataChunkMethod); } @@ -268,7 +265,7 @@ public class TestOraOopUtilities extends OraOopTestCase { try { OraOopUtilities.getOraOopOracleBlockToSplitAllocationMethod(null, OraOopConstants.OraOopOracleBlockToSplitAllocationMethod.RANDOM); - Assert.fail("An IllegalArgumentException should be been thrown."); + fail("An IllegalArgumentException should be been thrown."); } catch (IllegalArgumentException ex) { // This is what we want to happen. } @@ -280,7 +277,7 @@ public class TestOraOopUtilities extends OraOopTestCase { allocationMethod = OraOopUtilities.getOraOopOracleBlockToSplitAllocationMethod(conf, OraOopConstants.OraOopOracleBlockToSplitAllocationMethod.RANDOM); - Assert.assertEquals( + assertEquals( OraOopConstants.OraOopOracleBlockToSplitAllocationMethod.RANDOM, allocationMethod); @@ -289,7 +286,7 @@ public class TestOraOopUtilities extends OraOopTestCase { OraOopUtilities.getOraOopOracleBlockToSplitAllocationMethod( conf, OraOopConstants.OraOopOracleBlockToSplitAllocationMethod.SEQUENTIAL); - Assert.assertEquals( + assertEquals( OraOopConstants.OraOopOracleBlockToSplitAllocationMethod.SEQUENTIAL, allocationMethod); @@ -305,13 +302,12 @@ public class TestOraOopUtilities extends OraOopTestCase { String logText = OraOopUtilities.LOG.getLogEntries(); OraOopUtilities.LOG.setCacheLogEntries(false); if (!logText.toLowerCase().contains("loremipsum")) { - Assert - .fail("The LOG should inform the user they've selected an invalid " + fail("The LOG should inform the user they've selected an invalid " + "allocation method - and what that was."); } if (!logText.contains("ROUNDROBIN or SEQUENTIAL or RANDOM")) { - Assert.fail("The LOG should inform the user what the valid choices are."); + fail("The LOG should inform the user what the valid choices are."); } // An valid property value specified... @@ -321,7 +317,7 @@ public class TestOraOopUtilities extends OraOopTestCase { OraOopUtilities.getOraOopOracleBlockToSplitAllocationMethod( conf, OraOopConstants.OraOopOracleBlockToSplitAllocationMethod.SEQUENTIAL); - Assert.assertEquals( + assertEquals( OraOopConstants.OraOopOracleBlockToSplitAllocationMethod.SEQUENTIAL, allocationMethod); } @@ -333,7 +329,7 @@ public class TestOraOopUtilities extends OraOopTestCase { try { OraOopUtilities.getOraOopTableImportWhereClauseLocation(null, OraOopConstants.OraOopTableImportWhereClauseLocation.SPLIT); - Assert.fail("An IllegalArgumentException should be been thrown."); + fail("An IllegalArgumentException should be been thrown."); } catch (IllegalArgumentException ex) { // This is what we want to happen. } @@ -345,7 +341,7 @@ public class TestOraOopUtilities extends OraOopTestCase { location = OraOopUtilities.getOraOopTableImportWhereClauseLocation(conf, OraOopConstants.OraOopTableImportWhereClauseLocation.SPLIT); - Assert.assertEquals( + assertEquals( OraOopConstants.OraOopTableImportWhereClauseLocation.SPLIT, location); // An invalid property value specified... @@ -359,13 +355,12 @@ public class TestOraOopUtilities extends OraOopTestCase { String logText = OraOopUtilities.LOG.getLogEntries(); OraOopUtilities.LOG.setCacheLogEntries(false); if (!logText.toLowerCase().contains("loremipsum")) { - Assert - .fail("The LOG should inform the user they've selected an invalid " + fail("The LOG should inform the user they've selected an invalid " + "where-clause-location - and what that was."); } if (!logText.contains("SUBSPLIT or SPLIT")) { - Assert.fail("The LOG should inform the user what the valid choices are."); + fail("The LOG should inform the user what the valid choices are."); } // An valid property value specified... @@ -374,7 +369,7 @@ public class TestOraOopUtilities extends OraOopTestCase { location = OraOopUtilities.getOraOopTableImportWhereClauseLocation(conf, OraOopConstants.OraOopTableImportWhereClauseLocation.SUBSPLIT); - Assert.assertEquals( + assertEquals( OraOopConstants.OraOopTableImportWhereClauseLocation.SPLIT, location); } @@ -384,11 +379,11 @@ public class TestOraOopUtilities extends OraOopTestCase { String expected = " a"; String actual = OraOopUtilities.padLeft("a", 4); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); expected = "abcd"; actual = OraOopUtilities.padLeft("abcd", 3); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -396,11 +391,11 @@ public class TestOraOopUtilities extends OraOopTestCase { String expected = "a "; String actual = OraOopUtilities.padRight("a", 4); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); expected = "abcd"; actual = OraOopUtilities.padRight("abcd", 3); - Assert.assertEquals(expected, actual); + assertEquals(expected, actual); } @Test @@ -414,7 +409,7 @@ public class TestOraOopUtilities extends OraOopTestCase { "alter session set timezone = '{oracle.sessionTimeZone|GMT}';", conf); String expected = "alter session set timezone = 'GMT';"; - Assert.assertEquals("OraOop configuration expression failure.", expected, + assertEquals("OraOop configuration expression failure.", expected, actual); // Configuration property value exists... @@ -424,7 +419,7 @@ public class TestOraOopUtilities extends OraOopTestCase { "alter session set timezone = '{oracle.sessionTimeZone|GMT}';", conf); expected = "alter session set timezone = 'Africa/Algiers';"; - Assert.assertEquals("OraOop configuration expression failure.", expected, + assertEquals("OraOop configuration expression failure.", expected, actual); // Multiple properties in one expression... @@ -436,14 +431,14 @@ public class TestOraOopUtilities extends OraOopTestCase { OraOopUtilities.replaceConfigurationExpression("set {expr1}={expr2};", conf); expected = "set 1=2;"; - Assert.assertEquals("OraOop configuration expression failure.", expected, + assertEquals("OraOop configuration expression failure.", expected, actual); actual = OraOopUtilities.replaceConfigurationExpression( "set {expr4|0}={expr5|5};", conf); expected = "set 4=5;"; - Assert.assertEquals("OraOop configuration expression failure.", expected, + assertEquals("OraOop configuration expression failure.", expected, actual); } @@ -451,12 +446,12 @@ public class TestOraOopUtilities extends OraOopTestCase { public void testStackContainsClass() { if (OraOopUtilities.stackContainsClass("lorem.ipsum.dolor")) { - Assert.fail("There's no way the stack actually contains this!"); + fail("There's no way the stack actually contains this!"); } String expected = "org.apache.sqoop.manager.oracle.TestOraOopUtilities"; if (!OraOopUtilities.stackContainsClass(expected)) { - Assert.fail("The stack should contain the class:" + expected); + fail("The stack should contain the class:" + expected); } } @@ -465,20 +460,20 @@ public class TestOraOopUtilities extends OraOopTestCase { org.apache.hadoop.conf.Configuration conf = new Configuration(); String hint = OraOopUtilities.getImportHint(conf); - Assert.assertEquals("Default import hint", "/*+ NO_INDEX(t) */ ", hint); + assertEquals("Default import hint", "/*+ NO_INDEX(t) */ ", hint); conf.set("oraoop.import.hint", "NO_INDEX(t) SCN_ASCENDING"); hint = OraOopUtilities.getImportHint(conf); - Assert.assertEquals("Changed import hint", + assertEquals("Changed import hint", "/*+ NO_INDEX(t) SCN_ASCENDING */ ", hint); conf.set("oraoop.import.hint", " "); hint = OraOopUtilities.getImportHint(conf); - Assert.assertEquals("Whitespace import hint", "", hint); + assertEquals("Whitespace import hint", "", hint); conf.set("oraoop.import.hint", ""); hint = OraOopUtilities.getImportHint(conf); - Assert.assertEquals("Blank import hint", "", hint); + assertEquals("Blank import hint", "", hint); } @@ -491,43 +486,43 @@ public class TestOraOopUtilities extends OraOopTestCase { expected.add("abcde"); expected.add("ghijklm"); result = OraOopUtilities.splitStringList("abcde,ghijklm"); - Assert.assertEquals(expected, result); + assertEquals(expected, result); expected = new ArrayList<String>(); expected.add("\"abcde\""); expected.add("\"ghijklm\""); result = OraOopUtilities.splitStringList("\"abcde\",\"ghijklm\""); - Assert.assertEquals(expected, result); + assertEquals(expected, result); expected = new ArrayList<String>(); expected.add("abcde"); expected.add("\"ghijklm\""); result = OraOopUtilities.splitStringList("abcde,\"ghijklm\""); - Assert.assertEquals(expected, result); + assertEquals(expected, result); expected = new ArrayList<String>(); expected.add("\"abcde\""); expected.add("ghijklm"); result = OraOopUtilities.splitStringList("\"abcde\",ghijklm"); - Assert.assertEquals(expected, result); + assertEquals(expected, result); expected = new ArrayList<String>(); expected.add("\"ab,cde\""); expected.add("ghijklm"); result = OraOopUtilities.splitStringList("\"ab,cde\",ghijklm"); - Assert.assertEquals(expected, result); + assertEquals(expected, result); expected = new ArrayList<String>(); expected.add("abcde"); expected.add("\"ghi,jklm\""); result = OraOopUtilities.splitStringList("abcde,\"ghi,jklm\""); - Assert.assertEquals(expected, result); + assertEquals(expected, result); expected = new ArrayList<String>(); expected.add("\"ab,cde\""); expected.add("\"ghi,jklm\""); result = OraOopUtilities.splitStringList("\"ab,cde\",\"ghi,jklm\""); - Assert.assertEquals(expected, result); + assertEquals(expected, result); expected = new ArrayList<String>(); expected.add("\"ab,cde\""); @@ -541,7 +536,7 @@ public class TestOraOopUtilities extends OraOopTestCase { OraOopUtilities .splitStringList("\"ab,cde\",\"ghi,jklm\",\",Lorem\",\"ip!~sum\"," + "\"do,lo,,r\",\"s#it\",\"am$e$t\""); - Assert.assertEquals(expected, result); + assertEquals(expected, result); expected = new ArrayList<String>(); expected.add("LOREM"); @@ -550,7 +545,7 @@ public class TestOraOopUtilities extends OraOopTestCase { expected.add("SIT"); expected.add("AMET"); result = OraOopUtilities.splitStringList("LOREM,IPSUM,DOLOR,SIT,AMET"); - Assert.assertEquals(expected, result); + assertEquals(expected, result); } @Test @@ -566,7 +561,7 @@ public class TestOraOopUtilities extends OraOopTestCase { expected.add("AMET"); result = OraOopUtilities.splitOracleStringList("lorem,ipsum,dolor,sit,amet"); - Assert.assertEquals(expected, result); + assertEquals(expected, result); expected = new ArrayList<String>(); expected.add("LOREM"); @@ -577,7 +572,7 @@ public class TestOraOopUtilities extends OraOopTestCase { result = OraOopUtilities .splitOracleStringList("lorem,\"ipsum\",\"dolor\",sit,\"amet\""); - Assert.assertEquals(expected, result); + assertEquals(expected, result); expected = new ArrayList<String>(); expected.add("LOREM"); @@ -588,7 +583,7 @@ public class TestOraOopUtilities extends OraOopTestCase { result = OraOopUtilities .splitOracleStringList("lorem,\"ip,sum\",\"dol$or\",sit,\"am!~#et\""); - Assert.assertEquals(expected, result); + assertEquals(expected, result); } @Test @@ -602,18 +597,18 @@ public class TestOraOopUtilities extends OraOopTestCase { conf.set(confProperty, ""); OraOopUtilities.appendJavaSecurityEgd(conf); actual = conf.get(confProperty); - Assert.assertEquals("Append to empty string", expected, actual); + assertEquals("Append to empty string", expected, actual); expected = "-Djava.security.egd=file:/dev/random"; conf.set(confProperty, expected); OraOopUtilities.appendJavaSecurityEgd(conf); actual = conf.get(confProperty); - Assert.assertEquals("Append to empty string", expected, actual); + assertEquals("Append to empty string", expected, actual); expected = confValue + " -Xmx201m"; conf.set(confProperty, "-Xmx201m"); OraOopUtilities.appendJavaSecurityEgd(conf); actual = conf.get(confProperty); - Assert.assertEquals("Append to empty string", expected, actual); + assertEquals("Append to empty string", expected, actual); } } http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/oracle/TestOracleTable.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/oracle/TestOracleTable.java b/src/test/org/apache/sqoop/manager/oracle/TestOracleTable.java index 854d826..b9f8c0f 100644 --- a/src/test/org/apache/sqoop/manager/oracle/TestOracleTable.java +++ b/src/test/org/apache/sqoop/manager/oracle/TestOracleTable.java @@ -18,10 +18,10 @@ package org.apache.sqoop.manager.oracle; -import junit.framework.Assert; - import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** * Unit tests for OracleTable. */ @@ -30,13 +30,13 @@ public class TestOracleTable extends OraOopTestCase { @Test public void testToString() { OracleTable table = new OracleTable("ORAOOP", "TEST_TABLE"); - Assert.assertEquals("\"ORAOOP\".\"TEST_TABLE\"", table.toString()); + assertEquals("\"ORAOOP\".\"TEST_TABLE\"", table.toString()); table = new OracleTable("", "TEST_TABLE2"); - Assert.assertEquals("\"TEST_TABLE2\"", table.toString()); + assertEquals("\"TEST_TABLE2\"", table.toString()); table = new OracleTable("TEST_TABLE3"); - Assert.assertEquals("\"TEST_TABLE3\"", table.toString()); + assertEquals("\"TEST_TABLE3\"", table.toString()); } } http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/oracle/TimestampDataTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/oracle/TimestampDataTest.java b/src/test/org/apache/sqoop/manager/oracle/TimestampDataTest.java index 6ceccd1..1babf6c 100644 --- a/src/test/org/apache/sqoop/manager/oracle/TimestampDataTest.java +++ b/src/test/org/apache/sqoop/manager/oracle/TimestampDataTest.java @@ -18,11 +18,11 @@ package org.apache.sqoop.manager.oracle; -import junit.framework.Assert; - import org.apache.hadoop.conf.Configuration; import org.junit.Test; +import static org.junit.Assert.assertEquals; + /** * These tests need to be separate as changing the mapping type for timestamp * requires the tests to be run in a different process. Maven needs to be setup @@ -40,7 +40,7 @@ public class TimestampDataTest extends OraOopTestCase { try { int retCode = runImport("TST_PRODUCT", sqoopConf, false); - Assert.assertEquals("Return code should be 0", 0, retCode); + assertEquals("Return code should be 0", 0, retCode); } finally { cleanupFolders(); http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/ManagerCompatExport.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/ManagerCompatExport.java b/src/test/org/apache/sqoop/manager/sqlserver/ManagerCompatExport.java index 73976a3..8c5176a 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/ManagerCompatExport.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/ManagerCompatExport.java @@ -39,6 +39,11 @@ import com.cloudera.sqoop.SqoopOptions; import com.cloudera.sqoop.testutil.ExportJobTestCase; import com.cloudera.sqoop.tool.ExportTool; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + /** * Test utilities for export to SQL Server. */ @@ -111,12 +116,14 @@ public abstract class ManagerCompatExport extends ExportJobTestCase { public abstract void createFile(DATATYPES dt, String data) throws Exception; + @Test public void testVarBinary() { exportTestMethod(DATATYPES.VARBINARY); } + @Test public void testTime() { exportTestMethod(DATATYPES.TIME); @@ -151,11 +158,13 @@ public abstract class ManagerCompatExport extends ExportJobTestCase { } + @Test public void testDecimal() { exportTestMethod(DATATYPES.DECIMAL); } + @Test public void testNumeric() { exportTestMethod(DATATYPES.NUMERIC); @@ -203,6 +212,7 @@ public abstract class ManagerCompatExport extends ExportJobTestCase { } + @Test public void testMoney() { exportTestMethod(DATATYPES.MONEY); @@ -250,11 +260,13 @@ public abstract class ManagerCompatExport extends ExportJobTestCase { } + @Test public void testImage() { exportTestMethod(DATATYPES.IMAGE); } + @Test public void testBinary() { exportTestMethod(DATATYPES.BINARY); @@ -596,17 +608,6 @@ public abstract class ManagerCompatExport extends ExportJobTestCase { } - /** - * Create the argv to pass to Sqoop. - * - * @param includeHadoopFlags - * if true, then include -D various.settings=values - * @param rowsPerStmt - * number of rows to export in a single INSERT statement. - * @param statementsPerTx - * ## of statements to use in a transaction. - * @return the argv as an array of strings. - */ protected String[] getArgv(DATATYPES dt) { ArrayList<String> args = new ArrayList<String>(); http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeExportSequenceFileManualTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeExportSequenceFileManualTest.java b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeExportSequenceFileManualTest.java index 97034a1..21676f0 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeExportSequenceFileManualTest.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeExportSequenceFileManualTest.java @@ -38,6 +38,10 @@ import com.cloudera.sqoop.lib.SqoopRecord; import com.cloudera.sqoop.tool.CodeGenTool; import com.cloudera.sqoop.util.ClassLoaderStack; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + /** * Export sequence file to SQL Server test. */ @@ -182,17 +186,6 @@ public class SQLServerDatatypeExportSequenceFileManualTest return codeGenArgv.toArray(new String[0]); } - /** - * Create the argv to pass to Sqoop. - * - * @param includeHadoopFlags - * if true, then include -D various.settings=values - * @param rowsPerStmt - * number of rows to export in a single INSERT statement. - * @param statementsPerTx - * ## of statements to use in a transaction. - * @return the argv as an array of strings. - */ protected String[] getArgv(DATATYPES dt, String... additionalArgv) { ArrayList<String> args = new ArrayList<String>(); http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeImportDelimitedFileManualTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeImportDelimitedFileManualTest.java b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeImportDelimitedFileManualTest.java index 87bc203..519fb52 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeImportDelimitedFileManualTest.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeImportDelimitedFileManualTest.java @@ -38,6 +38,10 @@ import com.cloudera.sqoop.orm.CompilationManager; import com.cloudera.sqoop.testutil.CommonArgs; import com.cloudera.sqoop.tool.ImportTool; import com.cloudera.sqoop.util.ClassLoaderStack; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** * Test import delimited file from SQL Server. @@ -218,6 +222,7 @@ public class SQLServerDatatypeImportDelimitedFileManualTest } + @Test public void testVarBinary() { if (!supportsVarBinary()) { return; @@ -225,6 +230,7 @@ public class SQLServerDatatypeImportDelimitedFileManualTest dataTypeTest(DATATYPES.VARBINARY); } + @Test public void testTime() { if (!supportsTime()) { skipped = true; http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeImportSequenceFileManualTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeImportSequenceFileManualTest.java b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeImportSequenceFileManualTest.java index 8b30da0..a0dad8a 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeImportSequenceFileManualTest.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerDatatypeImportSequenceFileManualTest.java @@ -30,13 +30,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.util.StringUtils; -import org.apache.sqoop.manager.sqlserver.MSSQLTestUtils.*; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import com.cloudera.sqoop.SqoopOptions; import com.cloudera.sqoop.testutil.ManagerCompatTestCase; import org.apache.sqoop.manager.sqlserver.MSSQLTestDataFileParser.DATATYPES; import org.apache.sqoop.manager.sqlserver.MSSQLTestData.KEY_STRINGS; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * Testing import of a sequence file to SQL Server. */ @@ -122,6 +126,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends return opts; } + @Before public void setUp() { try { super.setUp(); @@ -151,6 +156,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } } + @After public void tearDown() { try { super.tearDown(); @@ -209,6 +215,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends verifyType("BIT", getFalseBoolLiteralSqlInput(), getFalseBoolSeqOutput()); } + @Test public void testBoolean() { try { super.testBoolean(); @@ -218,6 +225,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } } + @Test public void testBoolean2() { try { super.testBoolean2(); @@ -227,6 +235,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } } + @Test public void testBoolean3() { try { super.testBoolean3(); @@ -236,6 +245,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } } + @Test public void testDouble1() { try { super.testDouble1(); @@ -255,6 +265,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } } + @Test public void testClob1() { try { super.testClob1(); @@ -264,6 +275,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } } + @Test public void testBlob1() { try { super.testBlob1(); @@ -273,6 +285,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } } + @Test public void testLongVarChar() { try { super.testLongVarChar(); @@ -282,6 +295,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } } + @Test public void testTimestamp1() { try { super.testTimestamp1(); @@ -291,6 +305,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } } + @Test public void testTimestamp2() { try { super.testTimestamp2(); @@ -300,6 +315,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } } + @Test public void testTimestamp3() { try { super.testTimestamp3(); @@ -309,6 +325,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } } + @Test public void testVarBinary() { if (!supportsVarBinary()) { return; @@ -316,6 +333,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends dataTypeTest(DATATYPES.VARBINARY); } + @Test public void testTime() { if (!supportsTime()) { skipped = true; @@ -360,23 +378,29 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends dataTypeTest(DATATYPES.DATETIMEOFFSET); } + @Test public void testDecimal() { dataTypeTest(DATATYPES.DECIMAL); } + @Test public void testNumeric() { dataTypeTest(DATATYPES.NUMERIC); } + @Test public void testNumeric1() { } + @Test public void testNumeric2() { } + @Test public void testDecimal1() { } + @Test public void testDecimal2() { } @@ -418,7 +442,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends } @Test - public void testTinyInt2() { + public void testTinyInt2() { } @Test @@ -436,6 +460,7 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends dataTypeTest(DATATYPES.DATE); } + @Test public void testMoney() { dataTypeTest(DATATYPES.MONEY); } @@ -475,10 +500,12 @@ public class SQLServerDatatypeImportSequenceFileManualTest extends dataTypeTest(DATATYPES.NVARCHAR); } + @Test public void testImage() { dataTypeTest(DATATYPES.IMAGE); } + @Test public void testBinary() { dataTypeTest(DATATYPES.BINARY); } http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/SQLServerHiveImportManualTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerHiveImportManualTest.java b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerHiveImportManualTest.java index 077613f..1999272 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerHiveImportManualTest.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerHiveImportManualTest.java @@ -33,15 +33,18 @@ import com.cloudera.sqoop.SqoopOptions; import com.cloudera.sqoop.hive.TestHiveImport; import com.cloudera.sqoop.testutil.CommonArgs; import com.cloudera.sqoop.tool.SqoopTool; +import org.junit.Before; + +import static org.junit.Assert.fail; /** * Test import to Hive from SQL Server. */ public class SQLServerHiveImportManualTest extends TestHiveImport { + @Before public void setUp() { super.setUp(); - } protected boolean useHsqldbTestServer() { http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/SQLServerManagerManualTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerManagerManualTest.java b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerManagerManualTest.java index ee576c9..1178e3c 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerManagerManualTest.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerManagerManualTest.java @@ -26,7 +26,6 @@ import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Types; import java.util.Map; -import junit.framework.TestCase; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; @@ -43,10 +42,15 @@ import com.cloudera.sqoop.testutil.HsqldbTestServer; import com.cloudera.sqoop.tool.ImportTool; import com.cloudera.sqoop.tool.SqoopTool; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + /** * Test methods of the generic SqlManager implementation. */ -public class SQLServerManagerManualTest extends TestCase { +public class SQLServerManagerManualTest { public static final Log LOG = LogFactory.getLog( SQLServerManagerManualTest.class.getName()); http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/SQLServerMultiColsManualTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerMultiColsManualTest.java b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerMultiColsManualTest.java index 66b4a51..6a8ab51 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerMultiColsManualTest.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerMultiColsManualTest.java @@ -26,6 +26,7 @@ import org.apache.sqoop.manager.sqlserver.MSSQLTestUtils.*; import com.cloudera.sqoop.SqoopOptions; import com.cloudera.sqoop.TestMultiCols; +import org.junit.Test; /** * Test multiple columns SQL Server. @@ -76,26 +77,32 @@ public class SQLServerMultiColsManualTest extends TestMultiCols { } + @Test public void testMixed4() { // Overridden to bypass test case invalid for MSSQL server } + @Test public void testMixed5() { // Overridden to bypass test case invalid for MSSQL server } + @Test public void testMixed6() { // Overridden to bypass test case invalid for MSSQL server } + @Test public void testSkipFirstCol() { // Overridden to bypass test case invalid for MSSQL server } + @Test public void testSkipSecondCol() { // Overridden to bypass test case invalid for MSSQL server } + @Test public void testSkipThirdCol() { // Overridden to bypass test case invalid for MSSQL server } http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/SQLServerMultiMapsManualTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerMultiMapsManualTest.java b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerMultiMapsManualTest.java index 58ef4b4..c9a5b5e 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerMultiMapsManualTest.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerMultiMapsManualTest.java @@ -48,12 +48,19 @@ import com.cloudera.sqoop.testutil.SeqFileReader; import com.cloudera.sqoop.tool.ImportTool; import com.cloudera.sqoop.tool.SqoopTool; import com.cloudera.sqoop.util.ClassLoaderStack; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** * Test that using multiple mapper splits works. */ public class SQLServerMultiMapsManualTest extends ImportJobTestCase { + @Before public void setUp() { super.setUp(); MSSQLTestUtils utils = new MSSQLTestUtils(); @@ -67,6 +74,7 @@ public class SQLServerMultiMapsManualTest extends ImportJobTestCase { } + @After public void tearDown() { super.tearDown(); MSSQLTestUtils utils = new MSSQLTestUtils(); @@ -229,6 +237,7 @@ public class SQLServerMultiMapsManualTest extends ImportJobTestCase { } } + @Test public void testSplitByFirstCol() throws IOException { runMultiMapTest("L_ORDERKEY", 10); } http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/SQLServerParseMethodsManualTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerParseMethodsManualTest.java b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerParseMethodsManualTest.java index 21c950a..cd05aec 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerParseMethodsManualTest.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerParseMethodsManualTest.java @@ -48,6 +48,10 @@ import com.cloudera.sqoop.testutil.ImportJobTestCase; import com.cloudera.sqoop.testutil.ReparseMapper; import com.cloudera.sqoop.tool.ImportTool; import com.cloudera.sqoop.util.ClassLoaderStack; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.fail; /** * Test that the parse() methods generated in user SqoopRecord implementations @@ -55,6 +59,7 @@ import com.cloudera.sqoop.util.ClassLoaderStack; */ public class SQLServerParseMethodsManualTest extends ImportJobTestCase { + @Before public void setUp() { super.setUp(); Path p = new Path(getWarehouseDir()); @@ -170,6 +175,7 @@ public class SQLServerParseMethodsManualTest extends ImportJobTestCase { } } + @Test public void testDefaults() throws IOException { String[] types = { "INTEGER", "VARCHAR(32)", "INTEGER" }; String[] vals = { "64", "'foo'", "128" }; @@ -178,6 +184,7 @@ public class SQLServerParseMethodsManualTest extends ImportJobTestCase { runParseTest(",", "\\n", "\\\"", "\\", false); } + @Test public void testRequiredEnclose() throws IOException { String[] types = { "INTEGER", "VARCHAR(32)", "INTEGER" }; String[] vals = { "64", "'foo'", "128" }; @@ -186,6 +193,7 @@ public class SQLServerParseMethodsManualTest extends ImportJobTestCase { runParseTest(",", "\\n", "\\\"", "\\", true); } + @Test public void testStringEscapes() throws IOException { String[] types = { "VARCHAR(32)", "VARCHAR(32)", "VARCHAR(32)", "VARCHAR(32)", "VARCHAR(32)", }; @@ -196,6 +204,7 @@ public class SQLServerParseMethodsManualTest extends ImportJobTestCase { runParseTest(",", "\\n", "\\\'", "\\", false); } + @Test public void testNumericTypes() throws IOException { String[] types = { "INTEGER", "REAL", "FLOAT", "DATE", "TIME", "BIT", }; String[] vals = { "42", "36.0", "127.1", "'2009-07-02'", "'11:24:00'", http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/SQLServerQueryManualTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerQueryManualTest.java b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerQueryManualTest.java index 613bbce..0057ac9 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerQueryManualTest.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerQueryManualTest.java @@ -42,12 +42,19 @@ import com.cloudera.sqoop.testutil.ImportJobTestCase; import com.cloudera.sqoop.testutil.SeqFileReader; import com.cloudera.sqoop.tool.ImportTool; import com.cloudera.sqoop.util.ClassLoaderStack; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** * Test that --query works in Sqoop. */ public class SQLServerQueryManualTest extends ImportJobTestCase { + @Before public void setUp() { super.setUp(); MSSQLTestUtils utils = new MSSQLTestUtils(); @@ -61,6 +68,7 @@ public class SQLServerQueryManualTest extends ImportJobTestCase { } + @After public void tearDown() { super.tearDown(); MSSQLTestUtils utils = new MSSQLTestUtils(); @@ -202,6 +210,7 @@ public class SQLServerQueryManualTest extends ImportJobTestCase { } } + @Test public void testSelectStar() throws IOException { runQueryTest("SELECT * FROM " + getTableName() + " WHERE L_ORDERKEY > 0 AND $CONDITIONS", @@ -209,6 +218,7 @@ public class SQLServerQueryManualTest extends ImportJobTestCase { + "nocomments\n", 4, 10, getTablePath().toString()); } + @Test public void testCompoundWhere() throws IOException { runQueryTest("SELECT * FROM " + getTableName() + " WHERE L_ORDERKEY > 1 AND L_PARTKEY < 4 AND $CONDITIONS", @@ -216,6 +226,7 @@ public class SQLServerQueryManualTest extends ImportJobTestCase { + "nocomments\n", 1, 2, getTablePath().toString()); } + @Test public void testFailNoConditions() throws IOException { String[] argv = getArgv(true, "SELECT * FROM " + getTableName(), getTablePath().toString() + "where $CONDITIONS", true); http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/SQLServerSplitByManualTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerSplitByManualTest.java b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerSplitByManualTest.java index 4729aac..f85245a 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerSplitByManualTest.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerSplitByManualTest.java @@ -42,12 +42,19 @@ import com.cloudera.sqoop.testutil.ImportJobTestCase; import com.cloudera.sqoop.testutil.SeqFileReader; import com.cloudera.sqoop.tool.ImportTool; import com.cloudera.sqoop.util.ClassLoaderStack; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** * Test that --split-by works. */ public class SQLServerSplitByManualTest extends ImportJobTestCase { + @Before public void setUp() { super.setUp(); MSSQLTestUtils utils = new MSSQLTestUtils(); @@ -61,6 +68,7 @@ public class SQLServerSplitByManualTest extends ImportJobTestCase { } + @After public void tearDown() { super.tearDown(); MSSQLTestUtils utils = new MSSQLTestUtils(); @@ -187,11 +195,13 @@ public class SQLServerSplitByManualTest extends ImportJobTestCase { } } + @Test public void testSplitByFirstCol() throws IOException { String splitByCol = "L_ORDERKEY"; runSplitByTest(splitByCol, 10); } + @Test public void testSplitBySecondCol() throws IOException { String splitByCol = "L_PARTKEY"; runSplitByTest(splitByCol, 10); http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/manager/sqlserver/SQLServerWhereManualTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerWhereManualTest.java b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerWhereManualTest.java index 9fad144..10ae03b 100644 --- a/src/test/org/apache/sqoop/manager/sqlserver/SQLServerWhereManualTest.java +++ b/src/test/org/apache/sqoop/manager/sqlserver/SQLServerWhereManualTest.java @@ -43,6 +43,12 @@ import com.cloudera.sqoop.testutil.ImportJobTestCase; import com.cloudera.sqoop.testutil.SeqFileReader; import com.cloudera.sqoop.tool.ImportTool; import com.cloudera.sqoop.util.ClassLoaderStack; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** * Test that --where works in Sqoop. Methods essentially copied out of the other @@ -50,6 +56,7 @@ import com.cloudera.sqoop.util.ClassLoaderStack; */ public class SQLServerWhereManualTest extends ImportJobTestCase { + @Before public void setUp(){ super.setUp(); MSSQLTestUtils utils = new MSSQLTestUtils(); @@ -63,6 +70,7 @@ public class SQLServerWhereManualTest extends ImportJobTestCase { } + @After public void tearDown(){ super.tearDown(); MSSQLTestUtils utils = new MSSQLTestUtils(); @@ -205,6 +213,7 @@ public class SQLServerWhereManualTest extends ImportJobTestCase { } } + @Test public void testSingleClauseWhere() throws IOException { String whereClause = "L_ORDERKEY > 0 "; runWhereTest(whereClause, @@ -212,6 +221,7 @@ public class SQLServerWhereManualTest extends ImportJobTestCase { + "\n", 4, 10); } + @Test public void testMultiClauseWhere() throws IOException { String whereClause = "L_ORDERKEY > 1 AND L_PARTKEY < 4"; runWhereTest(whereClause, http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/mapreduce/TestJdbcExportJob.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/mapreduce/TestJdbcExportJob.java b/src/test/org/apache/sqoop/mapreduce/TestJdbcExportJob.java index 19440ff..250ffa6 100644 --- a/src/test/org/apache/sqoop/mapreduce/TestJdbcExportJob.java +++ b/src/test/org/apache/sqoop/mapreduce/TestJdbcExportJob.java @@ -25,6 +25,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; @@ -41,12 +42,11 @@ import com.cloudera.sqoop.SqoopOptions; import com.cloudera.sqoop.manager.ConnManager; import com.cloudera.sqoop.manager.ExportJobContext; -import junit.framework.TestCase; /** * Test methods of the JdbcExportJob implementation. */ -public class TestJdbcExportJob extends TestCase { +public class TestJdbcExportJob { @Test public void testAvroWithNoColumnsSpecified() throws Exception { http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/mapreduce/TestJobBase.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/mapreduce/TestJobBase.java b/src/test/org/apache/sqoop/mapreduce/TestJobBase.java index f228a35..017f984 100644 --- a/src/test/org/apache/sqoop/mapreduce/TestJobBase.java +++ b/src/test/org/apache/sqoop/mapreduce/TestJobBase.java @@ -18,6 +18,7 @@ package org.apache.sqoop.mapreduce; +import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -33,9 +34,7 @@ import org.junit.Test; import com.cloudera.sqoop.SqoopOptions; import com.cloudera.sqoop.mapreduce.JobBase; -import junit.framework.TestCase; - -public class TestJobBase extends TestCase { +public class TestJobBase { SqoopOptions options; Configuration conf; http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/mapreduce/db/TestBigDecimalSplitter.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/mapreduce/db/TestBigDecimalSplitter.java b/src/test/org/apache/sqoop/mapreduce/db/TestBigDecimalSplitter.java index 1e557a5..8257435 100644 --- a/src/test/org/apache/sqoop/mapreduce/db/TestBigDecimalSplitter.java +++ b/src/test/org/apache/sqoop/mapreduce/db/TestBigDecimalSplitter.java @@ -20,13 +20,15 @@ package org.apache.sqoop.mapreduce.db; import java.math.BigDecimal; -import junit.framework.TestCase; - import com.cloudera.sqoop.mapreduce.db.BigDecimalSplitter; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; -public class TestBigDecimalSplitter extends TestCase { +public class TestBigDecimalSplitter { /* Test if the decimal split sizes are generated as expected */ + @Test public void testDecimalTryDivide() { BigDecimal numerator = new BigDecimal("2"); BigDecimal denominator = new BigDecimal("4"); @@ -37,6 +39,7 @@ public class TestBigDecimalSplitter extends TestCase { } /* Test if the integer split sizes are generated as expected */ + @Test public void testIntegerTryDivide() { BigDecimal numerator = new BigDecimal("99"); BigDecimal denominator = new BigDecimal("3"); @@ -47,6 +50,7 @@ public class TestBigDecimalSplitter extends TestCase { } /* Test if the recurring decimal split sizes are generated as expected */ + @Test public void testRecurringTryDivide() { BigDecimal numerator = new BigDecimal("1"); BigDecimal denominator = new BigDecimal("3"); http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/mapreduce/db/TestDBConfiguration.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/mapreduce/db/TestDBConfiguration.java b/src/test/org/apache/sqoop/mapreduce/db/TestDBConfiguration.java index cad1004..3160db9 100644 --- a/src/test/org/apache/sqoop/mapreduce/db/TestDBConfiguration.java +++ b/src/test/org/apache/sqoop/mapreduce/db/TestDBConfiguration.java @@ -20,13 +20,16 @@ package org.apache.sqoop.mapreduce.db; import java.util.Properties; -import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; /** * Test aspects of DBConfiguration. */ -public class TestDBConfiguration extends TestCase { +public class TestDBConfiguration { + @Test public void testPropertiesToString() { Properties connParams = new Properties(); connParams.setProperty("a", "value-a"); http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/mapreduce/db/TestIntegerSplitter.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/mapreduce/db/TestIntegerSplitter.java b/src/test/org/apache/sqoop/mapreduce/db/TestIntegerSplitter.java index e93b6ad..efd0b95 100644 --- a/src/test/org/apache/sqoop/mapreduce/db/TestIntegerSplitter.java +++ b/src/test/org/apache/sqoop/mapreduce/db/TestIntegerSplitter.java @@ -20,14 +20,16 @@ package org.apache.sqoop.mapreduce.db; import java.sql.SQLException; import java.util.List; -import junit.framework.TestCase; - import com.cloudera.sqoop.mapreduce.db.IntegerSplitter; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** * Test that the IntegerSplitter generates sane splits. */ -public class TestIntegerSplitter extends TestCase { +public class TestIntegerSplitter { private long [] toLongArray(List<Long> in) { long [] out = new long[in.size()]; for (int i = 0; i < in.size(); i++) { @@ -75,24 +77,28 @@ public class TestIntegerSplitter extends TestCase { } } + @Test public void testEvenSplits() throws SQLException { List<Long> splits = new IntegerSplitter().split(10,-1, 0, 100); long [] expected = { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, }; assertLongArrayEquals(expected, toLongArray(splits)); } + @Test public void testOddSplits() throws SQLException { List<Long> splits = new IntegerSplitter().split(10,-1, 0, 95); long [] expected = { 0, 10, 20, 30, 40, 50, 59, 68, 77, 86, 95, }; assertLongArrayEquals(expected, toLongArray(splits)); } + @Test public void testSingletonSplit() throws SQLException { List<Long> splits = new IntegerSplitter().split(1,-1, 5, 5); long [] expected = { 5, 5 }; assertLongArrayEquals(expected, toLongArray(splits)); } + @Test public void testSingletonSplit2() throws SQLException { // Same test, but overly-high numSplits List<Long> splits = new IntegerSplitter().split(5,-1, 5, 5); @@ -100,12 +106,14 @@ public class TestIntegerSplitter extends TestCase { assertLongArrayEquals(expected, toLongArray(splits)); } + @Test public void testTooManySplits() throws SQLException { List<Long> splits = new IntegerSplitter().split(5,-1, 3, 5); long [] expected = { 3, 4, 5, 5}; assertLongArrayEquals(expected, toLongArray(splits)); } + @Test public void testExactSplitsAsInterval() throws SQLException { List<Long> splits = new IntegerSplitter().split(5,-1, 1, 5); long [] expected = { 1, 2, 3, 4, 5, 5}; @@ -118,30 +126,35 @@ public class TestIntegerSplitter extends TestCase { * * @throws SQLException */ + @Test public void testBigIntSplits() throws SQLException { List<Long> splits = new IntegerSplitter().split(4,-1, 14, 7863696997872966707L); assertEquals(splits.size(), 5); } + @Test public void testEvenSplitsWithLimit() throws SQLException { List<Long> splits = new IntegerSplitter().split(5, 10, 0, 100); long [] expected = { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 }; assertLongArrayEquals(expected, toLongArray(splits)); } + @Test public void testOddSplitsWithLimit() throws SQLException { List<Long> splits = new IntegerSplitter().split(5, 10, 0, 95); long [] expected = { 0, 10, 20, 30, 40, 50, 59, 68, 77, 86, 95}; assertLongArrayEquals(expected, toLongArray(splits)); } + @Test public void testSplitWithBiggerLimit() throws SQLException { List<Long> splits = new IntegerSplitter().split(10, 15, 0, 100); long [] expected = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100}; assertLongArrayEquals(expected, toLongArray(splits)); } + @Test public void testFractionalSplitWithLimit() throws SQLException { List<Long> splits = new IntegerSplitter().split(5, 1, 1, 10); long [] expected = {1,2, 3, 4, 5, 6, 7, 8, 9, 10, 10}; http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/mapreduce/db/TestTextSplitter.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/mapreduce/db/TestTextSplitter.java b/src/test/org/apache/sqoop/mapreduce/db/TestTextSplitter.java index c402a54..adb795e 100644 --- a/src/test/org/apache/sqoop/mapreduce/db/TestTextSplitter.java +++ b/src/test/org/apache/sqoop/mapreduce/db/TestTextSplitter.java @@ -22,21 +22,20 @@ import java.sql.SQLException; import java.util.List; import com.cloudera.sqoop.mapreduce.db.TextSplitter; - -import junit.framework.JUnit4TestAdapter; -import junit.framework.TestCase; import org.apache.sqoop.validation.ValidationException; -import org.junit.Rule; import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import org.junit.Rule; + import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; + /** * Test that the TextSplitter implementation creates a sane set of splits. */ -@RunWith(JUnit4.class) -public class TestTextSplitter extends TestCase { +public class TestTextSplitter { @Rule public ExpectedException thrown = ExpectedException.none(); @@ -172,9 +171,4 @@ public class TestTextSplitter extends TestCase { assertEquals(false, splitter2.isUseNCharStrings()); } - //workaround: ant kept falling back to JUnit3 - public static junit.framework.Test suite() { - return new JUnit4TestAdapter(TestTextSplitter.class); - } - } http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/mapreduce/db/TextSplitterHadoopConfIntegrationTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/mapreduce/db/TextSplitterHadoopConfIntegrationTest.java b/src/test/org/apache/sqoop/mapreduce/db/TextSplitterHadoopConfIntegrationTest.java index 32ebf45..6a521bf 100644 --- a/src/test/org/apache/sqoop/mapreduce/db/TextSplitterHadoopConfIntegrationTest.java +++ b/src/test/org/apache/sqoop/mapreduce/db/TextSplitterHadoopConfIntegrationTest.java @@ -20,24 +20,20 @@ package org.apache.sqoop.mapreduce.db; import java.sql.ResultSet; import java.util.List; -import junit.framework.JUnit4TestAdapter; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.mapreduce.InputSplit; import org.apache.hadoop.mapreduce.Job; import org.apache.sqoop.validation.ValidationException; -import com.cloudera.sqoop.Sqoop; import com.cloudera.sqoop.testutil.MockResultSet; -import junit.framework.TestCase; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -@RunWith(JUnit4.class) -public class TextSplitterHadoopConfIntegrationTest extends TestCase { +import static org.junit.Assert.assertFalse; + +public class TextSplitterHadoopConfIntegrationTest { private static final String TEXT_COL_NAME = "text_col_name"; @Rule @@ -66,9 +62,5 @@ public class TextSplitterHadoopConfIntegrationTest extends TestCase { assertFalse(splits.isEmpty()); } - //workaround: ant kept falling back to JUnit3 - public static junit.framework.Test suite() { - return new JUnit4TestAdapter(TextSplitterHadoopConfIntegrationTest.class); - } } http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/tool/TestBaseSqoopTool.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/tool/TestBaseSqoopTool.java b/src/test/org/apache/sqoop/tool/TestBaseSqoopTool.java index fbbffe9..ddf046e 100644 --- a/src/test/org/apache/sqoop/tool/TestBaseSqoopTool.java +++ b/src/test/org/apache/sqoop/tool/TestBaseSqoopTool.java @@ -19,19 +19,15 @@ package org.apache.sqoop.tool; import com.cloudera.sqoop.SqoopOptions; -import junit.framework.JUnit4TestAdapter; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; import org.mockito.Mockito; import static org.hamcrest.CoreMatchers.sameInstance; import static org.mockito.Mockito.mock; -@RunWith(JUnit4.class) public class TestBaseSqoopTool { @Rule @@ -73,8 +69,4 @@ public class TestBaseSqoopTool { testBaseSqoopTool.rethrowIfRequired(testSqoopOptions, expectedCauseException); } - public static junit.framework.Test suite() { - return new JUnit4TestAdapter(TestBaseSqoopTool.class); - } - } http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/tool/TestMainframeImportTool.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/tool/TestMainframeImportTool.java b/src/test/org/apache/sqoop/tool/TestMainframeImportTool.java index 3e502d0..d51e33e 100644 --- a/src/test/org/apache/sqoop/tool/TestMainframeImportTool.java +++ b/src/test/org/apache/sqoop/tool/TestMainframeImportTool.java @@ -36,6 +36,12 @@ import com.cloudera.sqoop.SqoopOptions.InvalidOptionsException; import com.cloudera.sqoop.cli.ToolOptions; import com.cloudera.sqoop.testutil.BaseSqoopTestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + public class TestMainframeImportTool extends BaseSqoopTestCase { private static final Log LOG = LogFactory.getLog(TestMainframeImportTool.class http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/validation/AbortOnFailureHandlerTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/validation/AbortOnFailureHandlerTest.java b/src/test/org/apache/sqoop/validation/AbortOnFailureHandlerTest.java index f38164c..f5808b2 100644 --- a/src/test/org/apache/sqoop/validation/AbortOnFailureHandlerTest.java +++ b/src/test/org/apache/sqoop/validation/AbortOnFailureHandlerTest.java @@ -19,14 +19,18 @@ package org.apache.sqoop.validation; import com.cloudera.sqoop.SqoopOptions; -import junit.framework.TestCase; import org.apache.hadoop.conf.Configuration; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; /** * Tests for AbortOnFailureHandler. */ -public class AbortOnFailureHandlerTest extends TestCase { +public class AbortOnFailureHandlerTest { + @Test public void testAbortOnFailureHandlerIsDefaultOption() { assertEquals(AbortOnFailureHandler.class, new SqoopOptions(new Configuration()).getValidationFailureHandlerClass()); @@ -35,6 +39,7 @@ public class AbortOnFailureHandlerTest extends TestCase { /** * Positive case. */ + @Test public void testAbortOnFailureHandlerAborting() { try { Validator validator = new RowCountValidator(); @@ -51,6 +56,7 @@ public class AbortOnFailureHandlerTest extends TestCase { /** * Negative case. */ + @Test public void testAbortOnFailureHandlerNotAborting() { try { Validator validator = new RowCountValidator(); http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/validation/AbsoluteValidationThresholdTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/validation/AbsoluteValidationThresholdTest.java b/src/test/org/apache/sqoop/validation/AbsoluteValidationThresholdTest.java index 9ac5074..86a99c4 100644 --- a/src/test/org/apache/sqoop/validation/AbsoluteValidationThresholdTest.java +++ b/src/test/org/apache/sqoop/validation/AbsoluteValidationThresholdTest.java @@ -18,17 +18,21 @@ package org.apache.sqoop.validation; -import junit.framework.TestCase; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; /** * Tests for AbsoluteValidationThreshold. */ -public class AbsoluteValidationThresholdTest extends TestCase { +public class AbsoluteValidationThresholdTest { /** * Test the implementation for AbsoluteValidationThreshold. * Both arguments should be same else fail. */ + @Test public void testAbsoluteValidationThreshold() { ValidationThreshold validationThreshold = new AbsoluteValidationThreshold(); assertTrue(validationThreshold.compare(100, 100)); http://git-wip-us.apache.org/repos/asf/sqoop/blob/4a74b8bc/src/test/org/apache/sqoop/validation/RowCountValidatorImportTest.java ---------------------------------------------------------------------- diff --git a/src/test/org/apache/sqoop/validation/RowCountValidatorImportTest.java b/src/test/org/apache/sqoop/validation/RowCountValidatorImportTest.java index 035d3b1..9ba62d4 100644 --- a/src/test/org/apache/sqoop/validation/RowCountValidatorImportTest.java +++ b/src/test/org/apache/sqoop/validation/RowCountValidatorImportTest.java @@ -22,11 +22,16 @@ import com.cloudera.sqoop.SqoopOptions; import com.cloudera.sqoop.testutil.ImportJobTestCase; import org.apache.hadoop.conf.Configuration; import org.apache.sqoop.tool.ImportTool; +import org.junit.Test; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + /** * Tests for RowCountValidator. */ @@ -43,6 +48,7 @@ public class RowCountValidatorImportTest extends ImportJobTestCase { * * @throws Exception */ + @Test public void testValidateOptionIsEnabledInCLI() throws Exception { String[] types = {"INT NOT NULL PRIMARY KEY", "VARCHAR(32)", "VARCHAR(32)"}; String[] insertVals = {"1", "'Bob'", "'sales'"}; @@ -59,6 +65,7 @@ public class RowCountValidatorImportTest extends ImportJobTestCase { } } + @Test public void testValidationOptionsParsedCorrectly() throws Exception { String[] types = {"INT NOT NULL PRIMARY KEY", "VARCHAR(32)", "VARCHAR(32)"}; String[] insertVals = {"1", "'Bob'", "'sales'"}; @@ -96,6 +103,7 @@ public class RowCountValidatorImportTest extends ImportJobTestCase { } } + @Test public void testInvalidValidationOptions() throws Exception { String[] types = {"INT NOT NULL PRIMARY KEY", "VARCHAR(32)", "VARCHAR(32)"}; String[] insertVals = {"1", "'Bob'", "'sales'"}; @@ -140,6 +148,7 @@ public class RowCountValidatorImportTest extends ImportJobTestCase { /** * Negative case where the row counts do NOT match. */ + @Test public void testValidatorWithDifferentRowCounts() { try { Validator validator = new RowCountValidator(); @@ -156,6 +165,7 @@ public class RowCountValidatorImportTest extends ImportJobTestCase { /** * Positive case where the row counts match. */ + @Test public void testValidatorWithMatchingRowCounts() { try { Validator validator = new RowCountValidator(); @@ -170,6 +180,7 @@ public class RowCountValidatorImportTest extends ImportJobTestCase { * * @throws Exception */ + @Test public void testValidatorForImportTable() throws Exception { String[] types = {"INT NOT NULL PRIMARY KEY", "VARCHAR(32)", "VARCHAR(32)"}; String[] insertVals = {"1", "'Bob'", "'sales'"};
