Search in sources :

Example 31 with ComponentId

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());
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) Version(com.yahoo.component.Version) ComponentId(com.yahoo.component.ComponentId) ComponentClass(com.yahoo.component.provider.ComponentClass) ConfigInstance(com.yahoo.config.ConfigInstance) Test(org.junit.Test)

Example 32 with ComponentId

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));
}
Also used : AccessLog(com.yahoo.container.logging.AccessLog) AccessLogInterface(com.yahoo.container.logging.AccessLogInterface) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) ComponentId(com.yahoo.component.ComponentId) Before(org.junit.Before)

Example 33 with ComponentId

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;
}
Also used : PageTemplate(com.yahoo.search.pagetemplates.PageTemplate) Element(org.w3c.dom.Element) NamedReader(com.yahoo.io.reader.NamedReader) ComponentId(com.yahoo.component.ComponentId)

Example 34 with ComponentId

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);
        }
    }
}
Also used : PageTemplate(com.yahoo.search.pagetemplates.PageTemplate) Element(org.w3c.dom.Element) ComponentId(com.yahoo.component.ComponentId)

Example 35 with ComponentId

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!"));
    }
}
Also used : Rot13DocumentProcessor(com.yahoo.application.container.docprocs.Rot13DocumentProcessor) DocumentProcessor(com.yahoo.docproc.DocumentProcessor) DocumentPut(com.yahoo.document.DocumentPut) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) ApplicationBuilder(com.yahoo.application.ApplicationBuilder) Application(com.yahoo.application.Application) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Aggregations

ComponentId (com.yahoo.component.ComponentId)68 Test (org.junit.Test)25 Result (com.yahoo.search.Result)14 Query (com.yahoo.search.Query)13 Execution (com.yahoo.search.searchchain.Execution)13 ArrayList (java.util.ArrayList)10 Chain (com.yahoo.component.chain.Chain)8 Searcher (com.yahoo.search.Searcher)8 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)7 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)7 FederationSearcher (com.yahoo.search.federation.FederationSearcher)6 Hit (com.yahoo.search.result.Hit)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)4 ChainsConfig (com.yahoo.container.core.ChainsConfig)4 FilterChainRepository (com.yahoo.container.http.filter.FilterChainRepository)4 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)4 QueryProfileTypeRegistry (com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)4 Component (com.yahoo.vespa.model.container.component.Component)4 HashMap (java.util.HashMap)4