Package org.opensolaris.opengrok.search

Examples of org.opensolaris.opengrok.search.QueryBuilder.build()


        // Search with no results
        in = new StringReader("abc def ghi\n");
        out = hitList ? null : new StringWriter();
        hits = hitList ? new ArrayList<Hit>() : null;
        qb = new QueryBuilder().setFreetext("no_match");
        c = new Context(qb.build(), qb.getQueries());
        assertFalse(c.getContext(in, out, "", "", "", null, limit, qb.isDefSearch(), hits));
        if (hitList) {
            assertEquals(0, hits.size());
        } else {
            assertEquals("", out.toString());
View Full Code Here


        // History search (should not show source context)
        in = new StringReader("abc def ghi\n");
        out = hitList ? null : new StringWriter();
        hits = hitList ? new ArrayList<Hit>() : null;
        qb = new QueryBuilder().setHist("abc");
        c = new Context(qb.build(), qb.getQueries());
        assertFalse(c.getContext(in, out, "", "", "", null, limit, qb.isDefSearch(), hits));
        if (hitList) {
            assertEquals(0, hits.size());
        } else {
            assertEquals("", out.toString());
View Full Code Here

        System.arraycopy(substring, 0,
                chars, Context.MAXFILEREAD - substring.length,
                substring.length);
        Reader in = new CharArrayReader(chars);
        QueryBuilder qb = new QueryBuilder().setFreetext("test");
        Context c = new Context(qb.build(), qb.getQueries());
        StringWriter out = new StringWriter();
        boolean match =
                c.getContext(in, out, "", "", "", null, true, qb.isDefSearch(),null);
        assertTrue("No match found", match);
        String s = out.toString();
View Full Code Here

        }
        Reader in = new StringReader(sb.toString());
        StringWriter out = new StringWriter();

        QueryBuilder qb = new QueryBuilder().setFreetext("search_for_me");
        Context c = new Context(qb.build(), qb.getQueries());

        boolean match =
                c.getContext(in, out, "", "", "", null, true, qb.isDefSearch(), null);
        assertTrue("No match found", match);
        String s = out.toString();
View Full Code Here

        Reader in = new StringReader(sb.toString());
        StringWriter out = new StringWriter();

        QueryBuilder qb = new QueryBuilder().setFreetext("search_for_me");
        Context c = new Context(qb.build(), qb.getQueries());

        boolean match =
                c.getContext(in, out, "", "", "", null, true, qb.isDefSearch(), null);
        assertTrue("No match found", match);
        String s = out.toString();
View Full Code Here

        // Search for a multi-token phrase that spans multiple lines in the
        // input file. The generated HTML fragment is inserted inside a root
        // element so that the StringWriter contains a valid XML document.
        QueryBuilder qb = new QueryBuilder().setFreetext("\"a b c\"");
        Context c = new Context(qb.build(), qb.getQueries());
        assertTrue(
                "No match found",
                c.getContext(in, out, "", "", "", null, true, qb.isDefSearch(), null));

        // Close the XML document body
View Full Code Here

    @Test
    public void bug16848() throws Exception {
        StringReader in = new StringReader("Mixed case: abc AbC dEf\n");
        StringWriter out = new StringWriter();
        QueryBuilder qb = new QueryBuilder().setFreetext("mixed");
        Context c = new Context(qb.build(), qb.getQueries());
        assertTrue(c.getContext(in, out, "", "", "", null, false, qb.isDefSearch(), null));
        assertEquals("<a class=\"s\" href=\"#0\"><span class=\"l\">0</span> "
                + "<b>Mixed</b> case: abc AbC dEf</a><br/>",
                out.toString());
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.