1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.skife.lucene.graph;
16
17 import junit.framework.TestCase;
18 import org.apache.lucene.document.Field;
19 import org.apache.lucene.index.IndexReader;
20 import org.skife.lucene.graph.helper.Beer;
21
22 import java.io.File;
23 import java.util.Collection;
24
25 public class MetadataFactoryTest extends TestCase
26 {
27 public void testMetadataIsSet() throws Exception
28 {
29 final GraphIndexer indexer = new GraphIndexer(new MetadataFactory()
30 {
31 public Field[] build(Object entity)
32 {
33 return new Field[] {Field.Text("wombat", "Is Happy")};
34 }
35 });
36
37 final File index = indexer.index(new Beer(1, "Schlitz"));
38 final IndexReader reader = IndexReader.open(index);
39 final Collection field_names = reader.getFieldNames();
40 assertTrue(field_names.contains("wombat"));
41 reader.close();
42 }
43 }