pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / facet / src / test / org / apache / lucene / facet / enhancements / params / DefaultEnhancementsIndexingParamsTest.java
1 package org.apache.lucene.facet.enhancements.params;
2
3 import java.util.List;
4
5 import org.junit.Test;
6
7 import org.apache.lucene.util.LuceneTestCase;
8 import org.apache.lucene.facet.enhancements.CategoryEnhancement;
9 import org.apache.lucene.facet.enhancements.CategoryEnhancementDummy1;
10 import org.apache.lucene.facet.enhancements.CategoryEnhancementDummy2;
11 import org.apache.lucene.facet.enhancements.params.DefaultEnhancementsIndexingParams;
12 import org.apache.lucene.facet.enhancements.params.EnhancementsIndexingParams;
13 import org.apache.lucene.facet.index.DummyProperty;
14 import org.apache.lucene.facet.index.attributes.CategoryProperty;
15
16 /**
17  * Licensed to the Apache Software Foundation (ASF) under one or more
18  * contributor license agreements.  See the NOTICE file distributed with
19  * this work for additional information regarding copyright ownership.
20  * The ASF licenses this file to You under the Apache License, Version 2.0
21  * (the "License"); you may not use this file except in compliance with
22  * the License.  You may obtain a copy of the License at
23  *
24  *     http://www.apache.org/licenses/LICENSE-2.0
25  *
26  * Unless required by applicable law or agreed to in writing, software
27  * distributed under the License is distributed on an "AS IS" BASIS,
28  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29  * See the License for the specific language governing permissions and
30  * limitations under the License.
31  */
32
33 public class DefaultEnhancementsIndexingParamsTest extends LuceneTestCase {
34
35   @Test
36   public void testCategoryEnhancements() {
37     EnhancementsIndexingParams params = 
38       new DefaultEnhancementsIndexingParams(
39           new CategoryEnhancementDummy1());
40
41     // check retainable properties 
42     List<Class<? extends CategoryProperty>> retainableProps = params
43         .getRetainableProperties();
44     assertNull("Unexpected content in retainable list", retainableProps);
45
46     params.addCategoryEnhancements(new CategoryEnhancementDummy2());
47
48     List<CategoryEnhancement> enhancements = params
49         .getCategoryEnhancements();
50
51     assertEquals("Wrong number of enhancements", 2, enhancements.size());
52
53     assertTrue("Wrong first enhancement",
54         enhancements.get(0) instanceof CategoryEnhancementDummy1);
55     assertTrue("Wrong second enhancement",
56         enhancements.get(1) instanceof CategoryEnhancementDummy2);
57
58     // re-check retainable properties 
59     retainableProps = params.getRetainableProperties();
60     assertNotNull("Unexpected empty retainable list", retainableProps);
61     assertEquals("Unexpected size of retainable list", 1, retainableProps
62         .size());
63     assertEquals("Wrong property in retainable list", DummyProperty.class,
64         retainableProps.get(0));
65
66   }
67 }