You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ch...@apache.org on 2013/03/01 19:45:58 UTC
svn commit: r1451680 - in /pig/trunk: CHANGES.txt
test/org/apache/pig/pigunit/PigTest.java
test/org/apache/pig/test/pigunit/TestPigTest.java
Author: cheolsoo
Date: Fri Mar 1 18:45:58 2013
New Revision: 1451680
URL: http://svn.apache.org/r1451680
Log:
PIG-3162: PigTest.assertOutput doesn't allow non-default delimiter (dreambird via cheolsoo)
Modified:
pig/trunk/CHANGES.txt
pig/trunk/test/org/apache/pig/pigunit/PigTest.java
pig/trunk/test/org/apache/pig/test/pigunit/TestPigTest.java
Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1451680&r1=1451679&r2=1451680&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Fri Mar 1 18:45:58 2013
@@ -28,6 +28,8 @@ PIG-3174: Remove rpm and deb artifacts
IMPROVEMENTS
+PIG-3162: PigTest.assertOutput doesn't allow non-default delimiter (dreambird via cheolsoo)
+
PIG-3002: Pig client should handle CountersExceededException (jarcec via billgraham)
PIG-3189: Remove ivy/pig.pom and improve build mvn targets (billgraham)
Modified: pig/trunk/test/org/apache/pig/pigunit/PigTest.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/pigunit/PigTest.java?rev=1451680&r1=1451679&r2=1451680&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/pigunit/PigTest.java (original)
+++ pig/trunk/test/org/apache/pig/pigunit/PigTest.java Fri Mar 1 18:45:58 2013
@@ -259,6 +259,11 @@ public class PigTest {
public void assertOutput(String aliasInput, String[] input, String alias, String[] expected)
throws IOException, ParseException {
+ assertOutput(aliasInput, input, alias, expected, "\\t");
+ }
+
+ public void assertOutput(String aliasInput, String[] input, String alias, String[] expected, String delimiter)
+ throws IOException, ParseException {
registerScript();
StringBuilder sb = new StringBuilder();
@@ -267,7 +272,7 @@ public class PigTest {
final String destination = FileLocalizer.getTemporaryPath(getPigServer().getPigContext()).toString();
getCluster().copyFromLocalFile(input, destination, true);
override(aliasInput,
- String.format("%s = LOAD '%s' AS %s;", aliasInput, destination, sb.toString()));
+ String.format("%s = LOAD '%s' USING PigStorage('%s') AS %s;", aliasInput, destination, delimiter, sb.toString()));
assertOutput(alias, expected);
}
Modified: pig/trunk/test/org/apache/pig/test/pigunit/TestPigTest.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/pigunit/TestPigTest.java?rev=1451680&r1=1451679&r2=1451680&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/pigunit/TestPigTest.java (original)
+++ pig/trunk/test/org/apache/pig/test/pigunit/TestPigTest.java Fri Mar 1 18:45:58 2013
@@ -134,6 +134,38 @@ public class TestPigTest {
}
@Test
+ public void testDelimiter() throws ParseException, IOException {
+ String[] args = {
+ "n=3",
+ "reducers=1",
+ "input=top_queries_input_data.txt",
+ "output=top_3_queries",
+ };
+ test = new PigTest(PIG_SCRIPT, args);
+
+ String[] input = {
+ "yahoo,10",
+ "twitter,7",
+ "facebook,10",
+ "yahoo,15",
+ "facebook,5",
+ "a,1",
+ "b,2",
+ "c,3",
+ "d,4",
+ "e,5",
+ };
+
+ String[] output = {
+ "(yahoo,25)",
+ "(facebook,15)",
+ "(twitter,7)",
+ };
+
+ test.assertOutput("data", input, "queries_limit", output, ",");
+ }
+
+ @Test
public void testSubset() throws ParseException, IOException {
String[] args = {
"n=3",
@@ -385,4 +417,4 @@ public class TestPigTest {
scriptFile.delete();
bootupFile.delete();
}
-}
\ No newline at end of file
+}