I try to test my mapper in MaprReduce job with such test:
@Test
public void testMapper_1() throws IOException {
mapDriver.withInput(new LongWritable(),
new Text("ip981 - - [26/Apr/2011:14:52:47 -0400] \"GET /faq/ide.jpg HTTP/1.1\" 200 40416 \"http://host2/faq/\" \"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.205 Safari/534.16\""));
mapDriver.withInput(new LongWritable(),
new Text("ip987 - - [26/Apr/2011:14:52:50 -0400] \"GET /faq/scsi.gif HTTP/1.1\" 200 953 \"http://host2/faq/\" \"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13\""));
MetricWritable value1 = new MetricWritable();
value1.setValues(40416, 1.0);
mapDriver.withOutput(new Text("ip981"), value1);
MetricWritable value2 = new MetricWritable();
value2.setValues(953, 1.0);
mapDriver.withOutput(new Text("ip987"), value2);
mapDriver.runTest();
}
And recieve from MRUnit following error:
java.lang.AssertionError: 2 Error(s): (Missing expected output (ip981, 1.0 40416) at position 0, got (ip981, 1.0 40416)., Missing expected output (ip987, 1.0 953) at position 1, got (ip987, 1.0 953).)
My job works correctly with real input log. I suspect that problem is in whitespace and tab characters between fields of value. But I have no idea how to fix it. Could somebody help me to find way of fixing? Thank you.
Aucun commentaire:
Enregistrer un commentaire