我正在尝试为我的 hadoop MR 工作编写一些单元测试并得到以下异常。这是我第一次使用 MRUnit,所以我不太确定这里发生了什么。
java.lang.IncompatibleClassChangeError: Found class org.apache.hadoop.mapreduce.TaskInputOutputContext, but interface was expected
at org.apache.hadoop.mrunit.mapreduce.mock.MockContextWrapper.createCommon(MockContextWrapper.java:53)
at org.apache.hadoop.mrunit.mapreduce.mock.MockMapContextWrapper.create(MockMapContextWrapper.java:70)
at org.apache.hadoop.mrunit.mapreduce.mock.MockMapContextWrapper.<init>(MockMapContextWrapper.java:62)
at org.apache.hadoop.mrunit.mapreduce.MapDriver.run(MapDriver.java:217)
at org.apache.hadoop.mrunit.MapDriverBase.runTest(MapDriverBase.java:150)
at org.apache.hadoop.mrunit.TestDriver.runTest(TestDriver.java:137)
我的实际代码看起来很简单
private MapDriver<Text, Text, Text, Text> mapDriver = MapDriver.newMapDriver(mapper);
private ReduceDriver<Text, Text, Text, Text> reduceDriver = ReduceDriver.newReduceDriver(reducer);
private MapReduceDriver<Text, Text, Text, Text, Text, Text> driver = MapReduceDriver.newMapReduceDriver(mapper, reducer);
@Test
public void testMapper() {
mapDriver.withInput(new Text("1"), new Text("Line 1"));
mapDriver.withOutput(new Text("1"), new Text("Line 1"));
mapDriver.runTest();
}