Examples of RequestExecutor


Examples of org.apache.stanbol.commons.testing.http.RequestExecutor

    @Before
    public void waitForServerReady() throws Exception {
        // initialize instance request builder and HTTP client
        builder = new RequestBuilder(serverBaseUrl);
        httpClient = new DefaultHttpClient();
        executor = new RequestExecutor(httpClient);

        if (serverReady) {
            return;
        }
View Full Code Here

Examples of org.apache.stanbol.commons.testing.http.RequestExecutor

     * @throws JSONException
     */
    @Test
    public void testRetrievel() throws IOException, JSONException {
        String id = "http://dbpedia.org/resource/Paris";
        RequestExecutor re = executor.execute(
            builder.buildGetRequest(DBPEDIA_SITE_PATH+"/entity",
                "id",id)
            .withHeader("Accept", "application/json"));
        re.assertStatus(200);
        JSONObject jEntity = assertEntity(re.getContent(), id, DBPEDIA_SITE_ID);
        assertRepresentation(jEntity.getJSONObject("representation"),
            DBPEDIA_DEFAULTDATA_REQUIRED_FIELDS,
            DBPEDIA_DEFAULTDATA_OPTIONAL_FIELDS);

    }
View Full Code Here

Examples of org.apache.stanbol.commons.testing.http.RequestExecutor

     * @throws JSONException
     */
    @Test
    public void testRetrievel() throws IOException, JSONException {
        String id = "http://dbpedia.org/resource/Paris";
        RequestExecutor re = executor.execute(
            builder.buildGetRequest(SITES_MANAGER_PATH+"/entity",
                "id",id)
            .withHeader("Accept", "application/json"));
        re.assertStatus(200);
        //do not check for the site of the entity, because this might change
        JSONObject jEntity = assertEntity(re.getContent(), id, null);
        assertRepresentation(jEntity.getJSONObject("representation"),
            DBPEDIA_DEFAULTDATA_REQUIRED_FIELDS,
            DBPEDIA_DEFAULTDATA_OPTIONAL_FIELDS);
    }
View Full Code Here

Examples of org.apache.stanbol.commons.testing.http.RequestExecutor

     */
    @Test
    public void testGetAccept() throws IOException, JSONException {
        //first a normal request with application/rdf+xml
        String id = "http://dbpedia.org/resource/Paris";
        RequestExecutor re = executor.execute(
            builder.buildGetRequest(DBPEDIA_SITE_PATH+"/entity",
                "id",id)
            .withHeader("Accept", "application/rdf+xml"));
        re.assertStatus(200);
        re.assertContentType("application/rdf+xml");
        re.assertContentContains(
            "<rdf:Description rdf:about=\"http://dbpedia.org/resource/Paris\">",
            "<rdfs:label xml:lang=\"en\">Paris</rdfs:label>");
        //now test the default Accept
        re = executor.execute(
            builder.buildGetRequest(DBPEDIA_SITE_PATH+"/entity",
                "id",id));
        re.assertContentType("application/json");
        re.assertStatus(200);
        assertEntity(re.getContent(), id, DBPEDIA_SITE_ID);
    }
View Full Code Here

Examples of org.apache.stanbol.commons.testing.http.RequestExecutor

    }
    @Test
    public void testSetAccept() throws IOException {
        //first a normal request with application/rdf+xml
        String id = "http://dbpedia.org/resource/Paris";
        RequestExecutor re = executor.execute(
            builder.buildGetRequest(DBPEDIA_SITE_PATH+"/entity",
                "id",id,
                "header_Accept","text/rdf+nt")); //parse the rdf+nt format as query parameter
        re.assertStatus(200);
        re.assertContentType("text/rdf+nt");
        re.assertContentContains(
            "<http://dbpedia.org/resource/Paris> " +
            "<http://www.w3.org/2000/01/rdf-schema#label> " +
            "\"Paris\"@en .");
    }
View Full Code Here

Examples of org.apache.stanbol.commons.testing.http.RequestExecutor

    }
    @Test
    public void testOverrideAccept() throws IOException {
        //first a normal request with application/rdf+xml
        String id = "http://dbpedia.org/resource/Paris";
        RequestExecutor re = executor.execute(
            builder.buildGetRequest(DBPEDIA_SITE_PATH+"/entity",
                "id",id,
                "header_Accept","text/rdf+nt") //parse the rdf+nt format as query parameter
            .withHeader("Accept", "application/rdf+xml")); //MUST override the rdf+xml
        re.assertStatus(200);
        re.assertContentType("text/rdf+nt");
        re.assertContentContains(
            "<http://dbpedia.org/resource/Paris> " +
            "<http://www.w3.org/2000/01/rdf-schema#label> " +
            "\"Paris\"@en .");
    }
View Full Code Here

Examples of org.apache.stanbol.commons.testing.http.RequestExecutor

                .assertContentType("text/html");               
                /*  List of expected referencedSites could also be made
                 *  configurable via system properties, but we don't expect it
                 *  to change often.
                 */
                RequestExecutor re = executor.execute(
                        builder.buildGetRequest("/entityhub/sites/referenced")
                        .withHeader("Accept", "application/json"));
                re.assertStatus(200);
                re.assertContentType("application/json");
                //check if all the required referenced sites are available
                for(String referencedSite : referencedSites){
                    if(referencedSite != null && !referencedSite.isEmpty()){
                        re.assertContentRegexp(String.format(
                            "http:\\\\/\\\\/.*\\\\/entityhub\\\\/site\\\\/%s\\\\/",
                            referencedSite));
                    }
                }
                //this ensures that all sites are initialized
View Full Code Here

Examples of org.apache.stanbol.commons.testing.http.RequestExecutor

        Request request = builder.buildPostRequest(endpointPath+test.getServicePath());
        for(Entry<String,String> header : test.getHeaders().entrySet()){
            request.withHeader(header.getKey(), header.getValue());
        }
        request.withContent(test.getContent());
        RequestExecutor re = executor.execute(request);
        assertQueryResults(re, test);
        return re;
    }
View Full Code Here

Examples of org.apache.stanbol.commons.testing.http.RequestExecutor

     * @throws JSONException
     */
    @Test
    public void testDefaultsParameter() throws IOException, JSONException {
        FindQueryTestCase test = new FindQueryTestCase("non_existant_"+UUID.randomUUID().toString(), false);
        RequestExecutor re = executeQuery(test);
        JSONObject jQuery = assertResponseQuery(re.getContent());
        assertTrue("Result Query does not contain Limit property",jQuery.has("limit"));
        assertTrue("Returned limit is <= 0",jQuery.getInt("limit") > 0);
       
        assertTrue("Result Query does not contain offset property",jQuery.has("offset"));
        assertTrue("Returned offset is != 0",jQuery.getInt("offset") == 0);
View Full Code Here

Examples of org.apache.stanbol.commons.testing.http.RequestExecutor

    @Test
    public void testCustomFieldParameter() throws IOException, JSONException {
        FindQueryTestCase test = new FindQueryTestCase("non_existant_"+UUID.randomUUID().toString(), false);
        String testField = "http://www.test.org/test#test_"+UUID.randomUUID();
        test.setField(testField);
        RequestExecutor re = executeQuery(test);
        JSONObject jQuery = assertResponseQuery(re.getContent());
        assertSelectedField(jQuery, testField);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.