5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-06 13:00:38 +08:00

SQOOP-1974: Sqoop2: parseCSVString in SQOOPIDFUtils add more tests

(Veena Basavaraj via Abraham Elmahrek)
This commit is contained in:
Abraham Elmahrek 2015-01-06 13:11:13 -08:00
parent ae26b9668e
commit dc50e4074f
2 changed files with 26 additions and 0 deletions

View File

@ -175,5 +175,18 @@ public void testEncodeMapToCSVString() {
String encodedText = encodeToCSVMap(map, mapCol);
assertEquals(encodedText, "'{\"A\":[\"A\",\"B\"]}'");
}
@Test
public void testParseCSVString() {
String csv= "'hello, world','34',45";
String[] arr = parseCSVString(csv);
assertEquals(arr.length, 3);
assertEquals(arr[0], "'hello, world'");
assertEquals(arr[1], "'34'");
assertEquals(arr[2], "45");
}
}

View File

@ -197,6 +197,19 @@ public void testInputAsCSVTextInAndDataOut() {
assertEquals(testData, dataFormat.getData());
}
@Test
public void testInputAsCSVTextInObjectOutWithSingleColumn() {
String testData = "'\"hello, world\"'";
Schema schema = new Schema("test");
schema.addColumn(new Text("text"));
dataFormat.setSchema(schema);
dataFormat.setCSVTextData(testData);
Object[] out = dataFormat.getObjectData();
assertEquals("\"hello, world\"",out[0]);
}
@Test
public void testInputAsCSVTextInObjectOut() {