Search in sources :

Example 6 with ErrorHit

use of com.yahoo.search.result.ErrorHit in project vespa by vespa-engine.

the class ErrorHitRenderTestCase method testXMLEscaping.

@Test
public void testXMLEscaping() throws java.io.IOException {
    ErrorHit h = new DefaultErrorHit("testcase", ErrorMessage.createUnspecifiedError("<>\"&"));
    StringWriter writer = new StringWriter();
    SearchRendererAdaptor.renderMessageDefaultErrorHit(new XMLWriter(writer), h.errors().iterator().next());
    assertEquals("<error source=\"testcase\" error=\"Unspecified error\" code=\"5\">&lt;&gt;\"&amp;</error>\n", writer.toString());
}
Also used : StringWriter(java.io.StringWriter) DefaultErrorHit(com.yahoo.search.result.DefaultErrorHit) ErrorHit(com.yahoo.search.result.ErrorHit) DefaultErrorHit(com.yahoo.search.result.DefaultErrorHit) XMLWriter(com.yahoo.text.XMLWriter) Test(org.junit.Test)

Example 7 with ErrorHit

use of com.yahoo.search.result.ErrorHit in project vespa by vespa-engine.

the class PartialFillTestCase method testMergeErrors.

@Test
public void testMergeErrors() {
    BadFS4 fs4 = new BadFS4();
    Query a = new Query("/?query=foo");
    Query b = new Query("/?query=bar");
    Result r = new Result(new Query("/?query=ignorethis"));
    {
        FastHit h = new FastHit();
        h.setQuery(a);
        h.setFillable();
        r.hits().add(h);
    }
    {
        FastHit h = new FastHit();
        h.setQuery(b);
        h.setFillable();
        r.hits().add(h);
    }
    doFill(fs4, r, "default");
    ErrorHit eh = r.hits().getErrorHit();
    assertNotNull(eh);
    ErrorMessage exp_sub = ErrorMessage.createUnspecifiedError("error");
    int n = 0;
    for (Iterator<? extends com.yahoo.search.result.ErrorMessage> i = eh.errorIterator(); i.hasNext(); ) {
        com.yahoo.search.result.ErrorMessage error = i.next();
        switch(n) {
            case 0:
                assertEquals(exp_sub, error);
                break;
            case 1:
                assertEquals(exp_sub, error);
                break;
            default:
                assertTrue(false);
        }
        n++;
    }
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Query(com.yahoo.search.Query) ErrorHit(com.yahoo.search.result.ErrorHit) ErrorMessage(com.yahoo.search.result.ErrorMessage) ErrorMessage(com.yahoo.search.result.ErrorMessage) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

ErrorHit (com.yahoo.search.result.ErrorHit)7 ErrorMessage (com.yahoo.search.result.ErrorMessage)4 Query (com.yahoo.search.Query)3 Result (com.yahoo.search.Result)3 Test (org.junit.Test)3 DefaultErrorHit (com.yahoo.search.result.DefaultErrorHit)2 Metric (com.yahoo.jdisc.Metric)1 URI (com.yahoo.net.URI)1 FastHit (com.yahoo.prelude.fastsearch.FastHit)1 PosSearcher (com.yahoo.prelude.searcher.PosSearcher)1 ResultBuilder (com.yahoo.search.federation.vespa.ResultBuilder)1 XMLWriter (com.yahoo.text.XMLWriter)1 StringWriter (java.io.StringWriter)1