1   /*  Copyright 2004 Brian McCallister
2    *
3    *   Licensed under the Apache License, Version 2.0 (the "License");
4    *   you may not use this file except in compliance with the License.
5    *   You may obtain a copy of the License at
6    *
7    *       http://www.apache.org/licenses/LICENSE-2.0
8    *
9    *   Unless required by applicable law or agreed to in writing, software
10   *   distributed under the License is distributed on an "AS IS" BASIS,
11   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   *   See the License for the specific language governing permissions and
13   *   limitations under the License.
14   */
15  package org.skife.lucene.graph;
16  
17  import junit.framework.TestCase;
18  import org.apache.lucene.index.IndexReader;
19  import org.skife.lucene.graph.helper.Beer;
20  import org.skife.lucene.graph.helper.Cozy;
21  
22  import java.io.File;
23  import java.util.Collection;
24  
25  public class ChainedPropertyTest extends TestCase
26  {
27      private GraphIndexer indexer = new GraphIndexer();
28  
29      public void testChainedPropertiesExist() throws Exception
30      {
31          final Cozy cozy = new Cozy(1, new Beer(2, "Schlitz)"));
32  
33          final File index = indexer.index(cozy);
34          final IndexReader reader = IndexReader.open(index);
35          final Collection fields = reader.getFieldNames();
36  
37          assertTrue("cozy.beer.name not indexed", fields.contains("cozy.beer.name"));
38          assertTrue("cozy.beer.identity not indexed", fields.contains("cozy.beer.identity"));
39          assertTrue("cozy.beer not indexed", fields.contains("cozy.beer"));
40          assertTrue("beer.name not indexed", fields.contains("beer.name"));
41          assertTrue("cozy.identity not indexed", fields.contains("cozy.identity"));
42      }
43  }