Search in sources :

Example 16 with QueryProfileXMLReader

use of com.yahoo.search.query.profile.config.QueryProfileXMLReader in project vespa by vespa-engine.

the class XmlReadingTestCase method testVersionRefs.

@Test
public void testVersionRefs() {
    CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/versionrefs").compile();
    Query query = new Query(HttpRequest.createTestRequest("?query=test", Method.GET), registry.getComponent("default"));
    assertEquals("MyProfile:1.0.2", query.properties().get("profile1.name"));
}
Also used : CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 17 with QueryProfileXMLReader

use of com.yahoo.search.query.profile.config.QueryProfileXMLReader in project vespa by vespa-engine.

the class XmlReadingTestCase method testInvalid2.

@Test
public void testInvalid2() {
    try {
        new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/invalidxml2");
        fail("Should have failed");
    } catch (IllegalArgumentException e) {
        assertEquals("Could not parse 'unparseable.xml', error at line 2, column 21: Element type \"query-profile\" must be followed by either attribute specifications, \">\" or \"/>\".", Exceptions.toMessageString(e));
    }
}
Also used : QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 18 with QueryProfileXMLReader

use of com.yahoo.search.query.profile.config.QueryProfileXMLReader in project vespa by vespa-engine.

the class XmlReadingTestCase method testSystemtest.

/**
 * Tests a subset of the configuration in the system test of this
 */
@Test
public void testSystemtest() {
    String queryString = "?query=test";
    QueryProfileXMLReader reader = new QueryProfileXMLReader();
    CompiledQueryProfileRegistry registry = reader.read("src/test/java/com/yahoo/search/query/profile/config/test/systemtest/").compile();
    HttpRequest request = HttpRequest.createTestRequest(queryString, Method.GET);
    CompiledQueryProfile profile = registry.findQueryProfile("default");
    Query query = new Query(request, profile);
    Properties p = query.properties();
    assertEquals("test", query.getModel().getQueryString());
    assertEquals("test", p.get("query"));
    assertEquals("test", p.get("QueRY"));
    assertEquals("test", p.get("model.queryString"));
    assertEquals("bar", p.get("foo"));
    assertEquals(5, p.get("hits"));
    assertEquals("tit", p.get("subst"));
    assertEquals("le", p.get("subst.end"));
    assertEquals("title", p.get("model.defaultIndex"));
    Map<String, Object> ps = p.listProperties();
    assertEquals(6, ps.size());
    assertEquals("bar", ps.get("foo"));
    assertEquals("5", ps.get("hits"));
    assertEquals("tit", ps.get("subst"));
    assertEquals("le", ps.get("subst.end"));
    assertEquals("title", ps.get("model.defaultIndex"));
    assertEquals("test", ps.get("model.queryString"));
}
Also used : HttpRequest(com.yahoo.container.jdisc.HttpRequest) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) Query(com.yahoo.search.Query) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Properties(com.yahoo.search.query.Properties) Test(org.junit.Test)

Example 19 with QueryProfileXMLReader

use of com.yahoo.search.query.profile.config.QueryProfileXMLReader in project vespa by vespa-engine.

the class XmlReadingTestCase method testQueryProfileVariants.

@Test
public void testQueryProfileVariants() {
    String query = "?query=test&dim1=yahoo&dim2=uk&dim3=test";
    QueryProfileXMLReader reader = new QueryProfileXMLReader();
    CompiledQueryProfileRegistry registry = reader.read("src/test/java/com/yahoo/search/query/profile/config/test/news/").compile();
    HttpRequest request = HttpRequest.createTestRequest(query, Method.GET);
    CompiledQueryProfile profile = registry.findQueryProfile("default");
    Query q = new Query(request, profile);
    assertEquals("c", q.properties().get("a.c"));
    assertEquals("b", q.properties().get("a.b"));
}
Also used : HttpRequest(com.yahoo.container.jdisc.HttpRequest) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) Query(com.yahoo.search.Query) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 20 with QueryProfileXMLReader

use of com.yahoo.search.query.profile.config.QueryProfileXMLReader in project vespa by vespa-engine.

the class XmlReadingTestCase method testInvalid3.

@Test
public void testInvalid3() {
    try {
        new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/invalidxml3");
        fail("Should have failed");
    } catch (IllegalArgumentException e) {
        assertEquals("The file name of query profile 'MyProfile' must be 'MyProfile.xml' but was 'default.xml'", Exceptions.toMessageString(e));
    }
}
Also used : QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Aggregations

QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)23 Test (org.junit.Test)21 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)14 Query (com.yahoo.search.Query)13 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)8 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)5 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)4 HttpRequest (com.yahoo.container.jdisc.HttpRequest)3 QueryProfile (com.yahoo.search.query.profile.QueryProfile)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CompoundName (com.yahoo.processing.request.CompoundName)1 Properties (com.yahoo.search.query.Properties)1 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)1 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)1 File (java.io.File)1