gates
Thu, 10 Apr 2008 15:15:00 -0700
Modified: incubator/pig/trunk/test/org/apache/pig/test/TestStreaming.java URL: http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/TestStreaming.java?rev=646988&r1=646987&r2=646988&view=diff ============================================================================== --- incubator/pig/trunk/test/org/apache/pig/test/TestStreaming.java (original) +++ incubator/pig/trunk/test/org/apache/pig/test/TestStreaming.java Thu Apr 10 15:14:04 2008 @@ -27,6 +27,7 @@ import org.apache.pig.PigServer; import org.apache.pig.PigServer.ExecType; +import org.apache.pig.backend.executionengine.ExecException; import org.apache.pig.builtin.PigStorage; import org.apache.pig.data.*; import org.apache.pig.impl.io.BufferedPositionedInputStream; @@ -68,8 +69,7 @@ private void testSimpleMapSideStreaming(ExecType execType) throws Exception { - PigServer pigServer = new PigServer(execType); - + PigServer pigServer = createPigServer(execType); File input = Util.createInputFile("tmp", "", new String[] {"A,1", "B,2", "C,3", "D,2", "A,5", "B,5", "C,8", "A,8", @@ -94,6 +94,16 @@ Util.checkQueryOutputs(pigServer.openIterator("OP"), expectedResults); } + private PigServer createPigServer(ExecType execType) throws ExecException { + PigServer pigServer; + if (execType == ExecType.MAPREDUCE) { + pigServer = new PigServer(execType, cluster.getProperties()); + } else { + pigServer = new PigServer(execType); + } + return pigServer; + } + @Test public void testLocalSimpleMapSideStreamingWithOutputSchema() throws Exception { @@ -108,7 +118,7 @@ private void testSimpleMapSideStreamingWithOutputSchema(ExecType execType) throws Exception { - PigServer pigServer = new PigServer(execType); + PigServer pigServer = createPigServer(execType); File input = Util.createInputFile("tmp", "", new String[] {"A,1", "B,2", "C,3", "D,2", @@ -147,7 +157,7 @@ private void testSimpleReduceSideStreamingAfterFlatten(ExecType execType) throws Exception { - PigServer pigServer = new PigServer(execType); + PigServer pigServer = createPigServer(execType); File input = Util.createInputFile("tmp", "", new String[] {"A,1", "B,2", "C,3", "D,2", @@ -190,7 +200,7 @@ private void testSimpleOrderedReduceSideStreamingAfterFlatten( ExecType execType) throws Exception { - PigServer pigServer = new PigServer(execType); + PigServer pigServer = createPigServer(execType); File input = Util.createInputFile("tmp", "", new String[] {"A,1,2,3", "B,2,4,5", @@ -240,7 +250,7 @@ @Test public void testInputShipSpecs() throws Exception { - PigServer pigServer = new PigServer(MAPREDUCE); + PigServer pigServer = new PigServer(MAPREDUCE, cluster.getProperties()); File input = Util.createInputFile("tmp", "", new String[] {"A,1", "B,2", "C,3", @@ -299,7 +309,7 @@ @Test public void testOutputShipSpecs() throws Exception { - PigServer pigServer = new PigServer(MAPREDUCE); + PigServer pigServer = new PigServer(MAPREDUCE, cluster.getProperties()); File input = Util.createInputFile("tmp", "", new String[] {"A,1", "B,2", "C,3", @@ -359,7 +369,7 @@ @Test public void testInputOutputSpecs() throws Exception { - PigServer pigServer = new PigServer(MAPREDUCE); + PigServer pigServer = new PigServer(MAPREDUCE, cluster.getProperties()); File input = Util.createInputFile("tmp", "", new String[] {"A,1", "B,2", "C,3", @@ -422,4 +432,4 @@ // Cleanup pigServer.deleteFile(output); } -} +} Modified: incubator/pig/trunk/test/org/apache/pig/test/Util.java URL: http://svn.apache.org/viewvc/incubator/pig/trunk/test/org/apache/pig/test/Util.java?rev=646988&r1=646987&r2=646988&view=diff ============================================================================== --- incubator/pig/trunk/test/org/apache/pig/test/Util.java (original) +++ incubator/pig/trunk/test/org/apache/pig/test/Util.java Thu Apr 10 15:14:04 2008 @@ -105,10 +105,27 @@ */ static public void checkQueryOutputs(Iterator<Tuple> actualResults, Tuple[] expectedResults) { + for (Tuple expected : expectedResults) { Tuple actual = actualResults.next(); Assert.assertEquals(expected, actual); } } + + static public void printQueryOutput(Iterator<Tuple> actualResults, + Tuple[] expectedResults) { + + System.out.println("Expected :") ; + for (Tuple expected : expectedResults) { + System.out.println(expected.toString()) ; + } + System.out.println("---End----") ; + + System.out.println("Actual :") ; + while (actualResults.hasNext()) { + System.out.println(actualResults.next().toString()) ; + } + System.out.println("---End----") ; + } }