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"));
}
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));
}
}
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"));
}
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"));
}
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));
}
}
Aggregations