KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > nutch > searcher > TestHitDetails


1 /* Copyright (c) 2003 The Nutch Organization. All rights reserved. */
2 /* Use subject to the conditions in http://www.nutch.org/LICENSE.txt. */
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 JavaDoc name) { super(name); }
12
13   public void testHitDetails() throws Exception JavaDoc {
14     final int length = 3;
15     final String JavaDoc[] fields = new String JavaDoc[] {"a", "b", "c" };
16     final String JavaDoc[] values = new String JavaDoc[] { "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