Why the content of objects has changed after putting it in an array
What can a test framework do with our simple java program? is it MRUnit fault or something else is happening here?
This is my simple identity Reduce Program:
public class SimpleReducer extends Reducer<Text, Text, Text, Text> { @Override protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException { List<Text> list = new ArrayList<>(); Iterator<Text> iter = values.iterator(); while(iter.hasNext()) { Text text = iter.next(); list.add(text); System.out.println(text); } System.out.println("-----------------------"); for (Text text : list) { System.out.println(text); context.write(key, text); } } }
And here is my test case:
@Test public void testReducer() throws IOException, InterruptedException { new ReduceDriver<Text, Text, Text, Text>() .withReducer(new SimpleReducer()) .withInput(new Text("eee"), Arrays.asList( new Text("a"), new Text("b"), new Text("v"), new Text("k"))) .withOutput(new Text("eee"), new Text("a")) .withOutput(new Text("eee"), new Text("b")) .withOutput(new Text("eee"), new Text("v")) .withOutput(new Text("eee"), new Text("k")) .runTest(); }
The output log of my program is as follow:
a b v k ----------------------- k k k k
Now my question is:
-
Why content of objects has changed after putting them in an ArrayList?
-
Is this MRUnit fault?
-
Is it possible for a test framework to control our objects to this extent?