use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg in project vespa by vespa-engine.
the class ContainerIncludeTest method include_file_with_wrong_root_element_name.
@Test(expected = IllegalArgumentException.class)
public void include_file_with_wrong_root_element_name() {
VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg("src/test/cfg/container/data/containerinclude5/");
creator.create();
}
use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg in project vespa by vespa-engine.
the class ContainerIncludeTest method include.
@Test
public void include() {
VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg("src/test/cfg/container/data/containerinclude/");
VespaModel model = creator.create();
assertThat(model.getContainerClusters().size(), is(1));
ContainerCluster cluster = model.getContainerClusters().values().iterator().next();
assertThat(cluster.getSearchChains(), notNullValue());
Map<String, SearchChain> searchChainMap = new HashMap<>();
for (SearchChain searchChain : cluster.getSearchChains().allChains().allComponents()) {
searchChainMap.put(searchChain.getId().stringValue(), searchChain);
}
assertThat(searchChainMap.get("searchchain1"), notNullValue());
assertThat(searchChainMap.get("searchchain1").getInnerComponents().size(), is(1));
assertThat(searchChainMap.get("searchchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher1"));
assertThat(searchChainMap.get("searchchain2"), notNullValue());
assertThat(searchChainMap.get("searchchain2").getInnerComponents().size(), is(1));
assertThat(searchChainMap.get("searchchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher2"));
assertThat(searchChainMap.get("searchchain3"), notNullValue());
assertThat(searchChainMap.get("searchchain3").getInnerComponents().size(), is(1));
assertThat(searchChainMap.get("searchchain3").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher3"));
assertThat(searchChainMap.get("searchchain4"), notNullValue());
assertThat(searchChainMap.get("searchchain4").getInnerComponents().size(), is(1));
assertThat(searchChainMap.get("searchchain4").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher4"));
assertThat(cluster.getDocprocChains(), notNullValue());
Map<String, DocprocChain> docprocChainMap = new HashMap<>();
for (DocprocChain docprocChain : cluster.getDocprocChains().allChains().allComponents()) {
docprocChainMap.put(docprocChain.getId().stringValue(), docprocChain);
}
assertThat(docprocChainMap.get("docprocchain1"), notNullValue());
assertThat(docprocChainMap.get("docprocchain1").getInnerComponents().size(), is(1));
assertThat(docprocChainMap.get("docprocchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.DocumentProcessor1"));
assertThat(docprocChainMap.get("docprocchain2"), notNullValue());
assertThat(docprocChainMap.get("docprocchain2").getInnerComponents().size(), is(1));
assertThat(docprocChainMap.get("docprocchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.DocumentProcessor2"));
assertThat(cluster.getProcessingChains(), notNullValue());
Map<String, ProcessingChain> processingChainMap = new HashMap<>();
for (ProcessingChain processingChain : cluster.getProcessingChains().allChains().allComponents()) {
processingChainMap.put(processingChain.getId().stringValue(), processingChain);
}
assertThat(processingChainMap.get("processingchain1"), notNullValue());
assertThat(processingChainMap.get("processingchain1").getInnerComponents().size(), is(1));
assertThat(processingChainMap.get("processingchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Processor1"));
assertThat(processingChainMap.get("processingchain2"), notNullValue());
assertThat(processingChainMap.get("processingchain2").getInnerComponents().size(), is(1));
assertThat(processingChainMap.get("processingchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Processor2"));
}
use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg in project vespa by vespa-engine.
the class ContainerIncludeTest method includeAbsolutePath.
@Test(expected = IllegalArgumentException.class)
public void includeAbsolutePath() {
VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg("src/test/cfg/container/data/containerinclude3/");
creator.create();
}
use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg in project vespa by vespa-engine.
the class StreamingValidatorTest method document_references_are_forbidden_in_streaming_search.
@Test
public void document_references_are_forbidden_in_streaming_search() {
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage("For streaming search cluster 'content.ad': Attribute 'campaign_ref' has type 'Reference<campaign>'. " + "Document references and imported fields are not allowed in streaming search.");
new VespaModelCreatorWithFilePkg("src/test/cfg/application/validation/document_references_validation/").create();
}
use of com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg in project vespa by vespa-engine.
the class RoutingTestCase method assertApplication.
/**
* Tests whether or not the given application produces the expected output. When creating new tests, create an
* application directory containing the necessary setup files, and call this method with a TRUE create flag.
*
* @param application The application directory.
*/
private static void assertApplication(File application) throws IOException {
assertTrue(application.isDirectory());
String applicationName = application.getName();
Map<String, File> files = new HashMap<>();
for (File file : application.listFiles(new ContentFilter())) {
files.put(file.getName(), file);
}
String path = null;
try {
path = application.getCanonicalPath();
} catch (IOException e) {
fail("Could not resolve path for application '" + applicationName + "'.");
}
VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg(path);
VespaModel model = creator.create();
List<String> errors = model.getRouting().getErrors();
if (errors.isEmpty()) {
if (files.containsKey("errors.txt")) {
if (WRITE_FILES) {
files.remove("errors.txt").delete();
} else {
fail("Route verification did not fail.");
}
}
MessagebusConfig.Builder mBusB = new MessagebusConfig.Builder();
model.getConfig(mBusB, "");
MessagebusConfig mBus = new MessagebusConfig(mBusB);
assertConfigFileContains(application, files, "messagebus.cfg", mBus);
DocumentrouteselectorpolicyConfig.Builder drB = new DocumentrouteselectorpolicyConfig.Builder();
model.getConfig(drB, "");
DocumentrouteselectorpolicyConfig dr = new DocumentrouteselectorpolicyConfig(drB);
assertConfigFileContains(application, files, "documentrouteselectorpolicy.cfg", dr);
} else {
StringBuilder msg = new StringBuilder();
for (String error : errors) {
msg.append(error).append("\n");
}
assertFileContains(application, files, "errors.txt", msg.toString());
}
}
Aggregations