use of com.yahoo.feedhandler.NullFeedMetric 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.feedhandler.NullFeedMetric 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.feedhandler.NullFeedMetric 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.feedhandler.NullFeedMetric in project vespa by vespa-engine.
the class VisitorSearcherTestCase method create.
public VisitSearcher create() throws Exception {
ClusterListConfig.Storage.Builder storageCluster = new ClusterListConfig.Storage.Builder().configid("storage/cluster.foobar").name("foobar");
ClusterListConfig clusterListCfg = new ClusterListConfig(new ClusterListConfig.Builder().storage(storageCluster));
ClusterList clusterList = new ClusterList(clusterListCfg);
return new VisitSearcher(new FeedContext(new MessagePropertyProcessor(new FeederConfig(new FeederConfig.Builder().timeout(458).route("riksveg18").retryenabled(true)), new LoadTypeConfig(new LoadTypeConfig.Builder())), factory, docMan, clusterList, new NullFeedMetric()));
}
use of com.yahoo.feedhandler.NullFeedMetric in project vespa by vespa-engine.
the class VespaFeeder method parseFiles.
void parseFiles(InputStream stdin, PrintStream output) throws Exception {
FeedContext context = new FeedContext(args.getPropertyProcessor(), args.getSessionFactory(), manager, new ClusterList(), new NullFeedMetric());
final BufferedInputStream input = new BufferedInputStream(stdin);
VespaFeedHandler handler = VespaFeedHandler.createFromContext(context, threadPool);
if (args.getFiles().isEmpty()) {
InputStreamRequest req = new InputStreamRequest(input);
setProperties(req, input);
FeedResponse response = (FeedResponse) handler.handle(req.toRequest(), createProgressCallback(output));
if (!response.isSuccess()) {
throw renderErrors(response.getErrorList());
}
} else {
if (args.isVerbose()) {
for (String fileName : args.getFiles()) {
long thisSize = new File(fileName).length();
output.println("Size of file '" + fileName + "' is " + thisSize + " B.");
}
}
for (String fileName : args.getFiles()) {
File f = new File(fileName);
FileRequest req = new FileRequest(f);
final BufferedInputStream inputSnooper = new BufferedInputStream(new FileInputStream(fileName));
setProperties(req, inputSnooper);
inputSnooper.close();
FeedResponse response = (FeedResponse) handler.handle(req.toRequest(), createProgressCallback(output));
if (!response.isSuccess()) {
throw renderErrors(response.getErrorList());
}
}
}
}
Aggregations