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\"><>\"&</error>\n", writer.toString());
}
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++;
}
}
Aggregations