Search in sources :

Example 36 with HttpRequest

use of com.yahoo.container.jdisc.HttpRequest 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 37 with HttpRequest

use of com.yahoo.container.jdisc.HttpRequest 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)

Aggregations

HttpRequest (com.yahoo.container.jdisc.HttpRequest)37 Test (org.junit.Test)23 HttpResponse (com.yahoo.container.jdisc.HttpResponse)18 InputStream (java.io.InputStream)9 HandlerTest (com.yahoo.vespa.config.server.http.HandlerTest)7 SessionHandlerTest (com.yahoo.vespa.config.server.http.SessionHandlerTest)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 Query (com.yahoo.search.Query)4 Joiner (com.google.common.base.Joiner)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 Inject (com.google.inject.Inject)3 Version (com.yahoo.component.Version)3 DeploymentSpec (com.yahoo.config.application.api.DeploymentSpec)3 ApplicationId (com.yahoo.config.provision.ApplicationId)3 ApplicationName (com.yahoo.config.provision.ApplicationName)3 Environment (com.yahoo.config.provision.Environment)3 RegionName (com.yahoo.config.provision.RegionName)3 TenantName (com.yahoo.config.provision.TenantName)3 LoggingRequestHandler (com.yahoo.container.jdisc.LoggingRequestHandler)3 IOUtils (com.yahoo.io.IOUtils)3