Equivalent of xUnit for testing Pig.
Call {@link PigTest#getCluster()} then construct a test and call an assert method.Have a look to the test of this class for more example.
108109110111112113114115116117118
"n=3", "reducers=1", "input=top_queries_input_data.txt", "output=top_3_queries", }; test = new PigTest(PIG_SCRIPT, args); String[] input = { "yahoo\t10", "twitter\t7", "facebook\t10",
140141142143144145146147148149150
"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",
172173174175176177178179180181182
204205206207208209210211212213214
"n=3", "reducers=1", "input=top_queries_input_data.txt", "output=top_3_queries", }; test = new PigTest(PIG_SCRIPT, args); test.override("queries_limit", "queries_limit = LIMIT queries_ordered 2;"); String[] output = { "(yahoo,25)",
227228229230231232233234235236237
"queries_ordered = ORDER queries_sum BY count DESC PARALLEL 1;", "queries_limit = LIMIT queries_ordered 3;", "STORE queries_limit INTO 'top_3_queries';", }; test = new PigTest(script); String[] output = { "(yahoo,25)", "(facebook,15)", "(twitter,7)",
246247248249250251252253254
"n=3", "reducers=1", "input=top_queries_input_data.txt", "output=top_3_queries", }; test = new PigTest(PIG_SCRIPT, args); test.assertOutput(new File("test/data/pigunit/top_queries_expected_top_3.txt")); }
257258259260261262263264265
public void testArgFiles() throws ParseException, IOException { String[] argsFile = { "test/data/pigunit/top_queries_params.txt" }; test = new PigTest(PIG_SCRIPT, null, argsFile); test.assertOutput(new File("test/data/pigunit/top_queries_expected_top_3.txt")); }
273274275276277278279280281282283
"queries_ordered = ORDER queries_sum BY count DESC PARALLEL 1;", "queries_limit = LIMIT queries_ordered 3;", "STORE queries_limit INTO 'top_3_queries';", }; test = new PigTest(script); String expected = "(yahoo,25)\n" + "(facebook,15)\n" + "(twitter,7)";
295296297298299300301302303304305
"queries_ordered = ORDER queries BY query DESC PARALLEL 1;", "queries_limit = LIMIT queries_ordered 3;", "STORE queries_limit INTO 'top_3_queries';", }; test = new PigTest(script); String[] output = { "(yahoo,{(yahoo)})", "(yahoo,{(yahoo)})", "(twitter,{(twitter)})",
314315316317318319320321322323324
"n=3", "reducers=1", "input=top_queries_input_data.txt", "output=top_3_queries", }; test = new PigTest(PIG_SCRIPT, args); // By default PigUnit removes all the STORE and DUMP test.unoverride("STORE"); test.runScript();