use of com.yahoo.component.ComponentId in project vespa by vespa-engine.
the class ComponentClassTestCase method testNullIdComponent.
/**
* Verifies that ComponentClass sets the ComponentId when a component that takes a ComponentId as
* constructor argument fails to call super(id).
*/
@Test
public void testNullIdComponent() throws NoSuchMethodException {
ComponentClass<NullIdComponent> testClass = new ComponentClass<>(NullIdComponent.class);
NullIdComponent component = testClass.createComponent(new ComponentId("null-test", new Version(1)), new HashMap<ConfigKey, ConfigInstance>(), null);
assertEquals("null-test", component.getId().getName());
assertEquals(1, component.getId().getVersion().getMajor());
}
use of com.yahoo.component.ComponentId in project vespa by vespa-engine.
the class LoggingRequestHandlerTestCase method setUp.
@Before
public void setUp() throws Exception {
accessLogging = new StartTimePusher();
ComponentRegistry<AccessLogInterface> implementers = new ComponentRegistry<>();
implementers.register(new ComponentId("nalle"), accessLogging);
implementers.freeze();
executor = Executors.newCachedThreadPool();
handler = new AccessLogTestHandler(executor, new AccessLog(implementers));
}
use of com.yahoo.component.ComponentId in project vespa by vespa-engine.
the class PageTemplateXMLReader method createPages.
private Map<ComponentId, Element> createPages(List<NamedReader> pageReaders, boolean validateReaderNames) {
Map<ComponentId, Element> pageElementsByPageId = new LinkedHashMap<>();
for (NamedReader reader : pageReaders) {
Element pageElement = XML.getDocument(reader).getDocumentElement();
if (!pageElement.getNodeName().equals("page")) {
logger.info("Ignoring '" + reader.getName() + "': Expected XML root element 'page' but was '" + pageElement.getNodeName() + "'");
continue;
}
String idString = pageElement.getAttribute("id");
if (idString == null || idString.isEmpty())
throw new IllegalArgumentException("Page template '" + reader.getName() + "' has no 'id' attribute in the root element");
ComponentId id = new ComponentId(idString);
if (validateReaderNames)
validateFileName(reader.getName(), id, "page template");
registry.register(new PageTemplate(id));
pageElementsByPageId.put(id, pageElement);
}
return pageElementsByPageId;
}
use of com.yahoo.component.ComponentId in project vespa by vespa-engine.
the class PageTemplateXMLReader method readPages.
private void readPages() {
for (Map.Entry<ComponentId, Element> pageElement : pageElementsByPageId.entrySet()) {
try {
PageTemplate page = registry.getComponent(pageElement.getValue().getAttribute("id"));
readPageContent(pageElement.getValue(), page);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Could not read page template '" + pageElement.getKey() + "'", e);
}
}
}
use of com.yahoo.component.ComponentId in project vespa by vespa-engine.
the class JDiscContainerDocprocTest method requireThatBasicDocumentProcessingWorks.
@Test
public void requireThatBasicDocumentProcessingWorks() throws Exception {
try (Application app = new ApplicationBuilder().servicesXml(getXML(CHAIN_NAME, Rot13DocumentProcessor.class.getCanonicalName())).documentType("music", DOCUMENT).build()) {
JDisc container = app.getJDisc("container");
DocumentProcessing docProc = container.documentProcessing();
DocumentType type = docProc.getDocumentTypes().get("music");
ChainRegistry<DocumentProcessor> chains = docProc.getChains();
assertTrue(chains.allComponentsById().containsKey(new ComponentId(CHAIN_NAME)));
Document doc = new Document(type, "doc:this:is:a:great:album");
doc.setFieldValue("title", "Great Album!");
com.yahoo.docproc.Processing processing;
DocumentProcessor.Progress progress;
DocumentPut put = new DocumentPut(doc);
processing = com.yahoo.docproc.Processing.of(put);
progress = docProc.process(ComponentSpecification.fromString(CHAIN_NAME), processing);
assertThat(progress, sameInstance(DocumentProcessor.Progress.DONE));
assertThat(doc.getFieldValue("title").toString(), equalTo("Terng Nyohz!"));
processing = com.yahoo.docproc.Processing.of(put);
progress = docProc.process(ComponentSpecification.fromString(CHAIN_NAME), processing);
assertThat(progress, sameInstance(DocumentProcessor.Progress.DONE));
assertThat(doc.getFieldValue("title").toString(), equalTo("Great Album!"));
}
}
Aggregations