Package org.apache.xindice.core.data

Examples of org.apache.xindice.core.data.NodeSet


    public void testQueryWithKeySet() throws Exception {
        TextQueryResolver res = new TextQueryResolver();

        Key[] keys = new Key[] {new Key("key1"), new Key("key3"), new Key("key4")};
        NodeSet set = res.query(collection, "test1:test", null, keys);
        int count = 0;
        while (set.hasMoreNodes()) {
            set.getNextNode();
            count++;
        }
        assertEquals("Number of elements in a result", 2, count);
    }
View Full Code Here


        resolver = new XPathQueryResolver();
    }

    public void testElementXPathQuery() throws Exception {
        for (int i = 0; i < ELEMENT_QUERY.length; i++) {
            NodeSet nodeSet = resolver.query(col, ELEMENT_QUERY[i], null, null);
            int results = 0;
            Element element = null;
            while(nodeSet.hasMoreNodes()) {
                element = (Element)nodeSet.getNextNode();
                assertNotNull("NodeSet.getNextNode must be not null", element);
                results++;
            }

            assertEquals("Results count", ELEMENT_COUNT[i], results);
View Full Code Here

        list = doc.getDocumentElement().getElementsByTagName("content");
    }

    public void testTermQuery() throws Exception {
        Searcher searcher = new Searcher(list, new SimpleAnalyzer());
        NodeSet res = searcher.search("underlying");

        int count = 0;
        while (res.hasMoreNodes()) {
            count++;
            res.getNextNode();
        }
        assertTrue(count == 3);
    }
View Full Code Here

        }
    }

    public void testNumberXPathQuery() throws Exception {
        for (int i = 0; i < NUMBER_QUERY.length; i++) {
            NodeSet nodeSet = resolver.query(col, NUMBER_QUERY[i], null, null);
            assertTrue("Expected one result", nodeSet.hasMoreNodes());
            Text element = (Text)nodeSet.getNextNode();
            assertNotNull("NodeSet.getNextNode must be not null", element);
            assertEquals("Result value", new Double(NUMBER_VALUE[i]).toString(), element.getNodeValue());
        }
    }
View Full Code Here

        assertTrue(count == 3);
    }

    public void testBooleanQuery() throws Exception {
        Searcher searcher = new Searcher(list, new SimpleAnalyzer());
        NodeSet res = searcher.search("underlying AND automatically");

        int count = 0;
        while (res.hasMoreNodes()) {
            count++;
            res.getNextNode();
        }
        assertTrue(count == 1);
    }
View Full Code Here

        }
    }

    public void testTextXPathQuery() throws Exception {
        for (int i = 0; i < TEXT_QUERY.length; i++) {
            NodeSet nodeSet = resolver.query(col, TEXT_QUERY[i], null, null);
            int results = 0;
            Text element = null;
            while(nodeSet.hasMoreNodes()) {
                element = (Text)nodeSet.getNextNode();
                assertNotNull("NodeSet.getNextNode must be not null", element);
                results++;
            }

            assertEquals("Results count for " + TEXT_QUERY[i], TEXT_COUNT[i], results);
View Full Code Here

        assertTrue(count == 1);
    }

    public void testPhraseQuery() throws Exception {
        Searcher searcher = new Searcher(list, new SimpleAnalyzer());
        NodeSet res = searcher.search("\"underlying method\"");

        int count = 0;
        while (res.hasMoreNodes()) {
            count++;
            res.getNextNode();
        }
        assertTrue(count == 2);
    }
View Full Code Here

        assertTrue(count == 2);
    }

    public void testWildcardQuery1() throws Exception {
        Searcher searcher = new Searcher(list, new SimpleAnalyzer());
        NodeSet res = searcher.search("invoke?");

        int count = 0;
        while (res.hasMoreNodes()) {
            count++;
            res.getNextNode();
        }
        assertTrue(count == 2);
    }
View Full Code Here

    }

  public void testComplexXPathQuery() throws Exception {
    Object node = null;
    XPathQueryResolver queryResolv = new XPathQueryResolver();
    NodeSet nodeSet =
      queryResolv.query(
        col,
        "/terrainmap[coordinates/top-left/latlong/latitude[(number(text()) + 180) >= 0] and coordinates/top-left/latlong/longitude[(number(text()) + 90) <= 0] and coordinates/bottom-right/latlong/latitude[(number(text()) + 180) <= 0] and coordinates/bottom-right/latlong/longitude[(number(text()) + 90) >= 0]]",
        null,
        null);
    if (nodeSet.hasMoreNodes()) {
      node = nodeSet.getNextNode();
    }
    assertNotNull("Complex query didn't return a node", node);
  }
View Full Code Here

        assertTrue(count == 2);
    }

    public void testWildcardQuery2() throws Exception {
        Searcher searcher = new Searcher(list, new SimpleAnalyzer());
        NodeSet res = searcher.search("invoke*");

        int count = 0;
        while (res.hasMoreNodes()) {
            count++;
            res.getNextNode();
        }
        assertTrue(count == 3);
    }
View Full Code Here

TOP

Related Classes of org.apache.xindice.core.data.NodeSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.