use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class GetSearcherTestCase method testResultWithNullDocument.
@Test
public void testResultWithNullDocument() throws Exception {
DocumentSessionFactory factory = new DocumentSessionFactory(docType, null, true);
factory.setNullReply(true);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id[0]=userdoc:kittens:55:bad_document_id"));
// Document not found does not produce any hit at all, error or otherwise
assertNull(result.hits().getErrorHit());
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "</result>\n", result);
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class GetSearcherTestCase method testBadPriorityValue.
@Test
public void testBadPriorityValue() throws Exception {
DocumentSessionFactory factory = new DocumentSessionFactory(docType);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=userdoc:kittens:1:2&priority=onkel_jubalon"));
assertNotNull(result.hits().getErrorHit());
assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<errors>\n" + "<error type=\"searcher\" code=\"3\" message=\"Illegal query: " + "java.lang.IllegalArgumentException: No enum const" + (Util.isJava7Compatible() ? "ant " : " class ") + "com.yahoo.documentapi.messagebus.protocol.DocumentProtocol" + (Util.isJava7Compatible() ? "." : "$") + "Priority.onkel_jubalon\"/>\n" + "</errors>\n" + "</result>\n", result);
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class GetSearcherTestCase method testJsonRendererSetting.
@Test
public void testJsonRendererSetting() throws Exception {
// Needs auto-reply
DocumentSessionFactory factory = new DocumentSessionFactory(docType);
GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
Chain<Searcher> searchChain = new Chain<>(searcher);
Query query = newQuery("?id=userdoc:kittens:1:2&format=json");
Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(query);
assertFalse(result.getTemplating().getTemplates() instanceof DocumentXMLTemplate);
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class FederationSearcherTestCase method testNoCloning.
@Test
public void testNoCloning() {
String sourceName = "cloningcheck";
Query query = new Query(QueryTestCase.httpEncode("?query=test&sources=" + sourceName));
addChained(new QueryCheckSearcher(query), sourceName);
addChained(new MockSearcher(), "mySource1");
Chain<Searcher> mainChain = new Chain<>("default", createStrictFederationSearcher());
Result result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(query);
HitGroup h = (HitGroup) result.hits().get(0);
assertNull(h.getErrorHit());
assertSame(QueryCheckSearcher.OK, h.get(0).getField(QueryCheckSearcher.STATUS));
mainChain = new Chain<>("default", createFederationSearcher());
result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(query);
h = (HitGroup) result.hits().get(0);
assertSame(QueryCheckSearcher.FEDERATION_SEARCHER_HAS_CLONED_THE_QUERY, h.getError().getDetailedMessage());
query = new Query(QueryTestCase.httpEncode("?query=test&sources=" + sourceName + ",mySource1"));
addChained(new QueryCheckSearcher(query), sourceName);
result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(query);
h = (HitGroup) result.hits().get(0);
assertEquals("source:" + sourceName, h.getId().stringValue());
assertSame(QueryCheckSearcher.FEDERATION_SEARCHER_HAS_CLONED_THE_QUERY, h.getError().getDetailedMessage());
assertEquals("source:mySource1", result.hits().get(1).getId().stringValue());
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class FederationSearcherTestCase method testTopLevelHitGroupFieldPropagation.
@Test
public void testTopLevelHitGroupFieldPropagation() {
addChained(new MockSearcher(), "mySource1");
addChained(new AnotherMockSearcher(), "mySource2");
Chain<Searcher> mainChain = new Chain<>("default", createFederationSearcher());
Query q = new Query("?query=test");
Result result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(q);
assertNull(result.hits().getError());
assertEquals("source:mySource1", result.hits().get(0).getId().stringValue());
assertEquals("source:mySource2", result.hits().get(1).getId().stringValue());
assertEquals(AnotherMockSearcher.IS_THIS_PROPAGATED, result.hits().get(1).getField(AnotherMockSearcher.PROPAGATION_KEY));
}
Aggregations