pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / facet / src / test / org / apache / lucene / facet / index / attributes / CategoryAttributesIterableTest.java
1 package org.apache.lucene.facet.index.attributes;
2
3 import java.io.IOException;
4 import java.util.ArrayList;
5 import java.util.Iterator;
6 import java.util.List;
7
8 import org.junit.Test;
9
10 import org.apache.lucene.facet.index.CategoryContainerTestBase;
11 import org.apache.lucene.facet.index.attributes.CategoryAttribute;
12 import org.apache.lucene.facet.index.attributes.CategoryAttributesIterable;
13 import org.apache.lucene.facet.taxonomy.CategoryPath;
14
15 /**
16  * Licensed to the Apache Software Foundation (ASF) under one or more
17  * contributor license agreements.  See the NOTICE file distributed with
18  * this work for additional information regarding copyright ownership.
19  * The ASF licenses this file to You under the Apache License, Version 2.0
20  * (the "License"); you may not use this file except in compliance with
21  * the License.  You may obtain a copy of the License at
22  *
23  *     http://www.apache.org/licenses/LICENSE-2.0
24  *
25  * Unless required by applicable law or agreed to in writing, software
26  * distributed under the License is distributed on an "AS IS" BASIS,
27  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28  * See the License for the specific language governing permissions and
29  * limitations under the License.
30  */
31
32 public class CategoryAttributesIterableTest extends CategoryContainerTestBase {
33
34   @Test
35   public void testIterator() throws IOException {
36     List<CategoryPath> categoryList = new ArrayList<CategoryPath>();
37     for (int i = 0; i < initialCatgeories.length; i++) {
38       categoryList.add(initialCatgeories[i]);
39     }
40
41     CategoryAttributesIterable iterable = new CategoryAttributesIterable(
42         categoryList);
43     Iterator<CategoryAttribute> iterator = iterable.iterator();
44
45     // count the number of tokens
46     int nCategories;
47     for (nCategories = 0; iterator.hasNext(); nCategories++) {
48       iterator.next();
49     }
50     assertEquals("Wrong number of tokens", 3, nCategories);
51   }
52
53 }