1 2 3 4 package net.nutch.searcher; 5 6 import java.io.*; 7 import net.nutch.io.*; 8 import junit.framework.TestCase; 9 10 public class TestHitDetails extends TestCase { 11 public TestHitDetails(String name) { super(name); } 12 13 public void testHitDetails() throws Exception { 14 final int length = 3; 15 final String [] fields = new String [] {"a", "b", "c" }; 16 final String [] values = new String [] { "foo", "bar", "baz" }; 17 18 HitDetails before = new HitDetails(fields, values); 19 20 DataOutputBuffer dob = new DataOutputBuffer(); 21 before.write(dob); 22 23 DataInputBuffer dib = new DataInputBuffer(); 24 dib.reset(dob.getData(), dob.getLength()); 25 26 HitDetails after = HitDetails.read(dib); 27 28 assertEquals(length, after.getLength()); 29 for (int i = 0; i < length; i++) { 30 assertEquals(fields[i], after.getField(i)); 31 assertEquals(values[i], after.getValue(i)); 32 assertEquals(values[i], after.getValue(fields[i])); 33 } 34 } 35 } 36 | Popular Tags |