Package org.apache.stanbol.commons.testing.http

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


    }
    @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


    }
    @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

                .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

        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

     * @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

    @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

                    "'value': 'http:\\/\\/www.test.org\\/test#NonExistingValue', "+
                "}]"+
            "}",
            false); //success but no result
        //now execute the test
        RequestExecutor re = executeQuery(test);
        JSONObject jQuery = assertResponseQuery(re.getContent());
        assertTrue("Result Query does not contain offset property",jQuery.has("offset"));
        assertTrue("Returned offset is != 0",jQuery.getInt("offset") == 0);
    }
View Full Code Here

                    "'value': 'http:\\/\\/www.test.org\\/test#NonExistingValue', "+
                "}]"+
            "}",
            false); //success but no result
        //now execute the test
        RequestExecutor re = executeQuery(test);
        //test the of the limit was set correctly set to the default (> 0)
        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);
    }
View Full Code Here

                "'field': 'http:\\/\\/www.test.org\\/test#field'" +
                "}]," +
            "}",
            false); //expect BadRequest
        //now execute the test
        RequestExecutor re = executeQuery(test);
        JSONObject jQuery = assertResponseQuery(re.getContent());
        JSONArray jConstraints = jQuery.optJSONArray("constraints");
        assertNotNull("Result Query does not contain the constraints Array",jConstraints);
        assertTrue("Result Query Constraint Array does not contain the expected Constraint",
            jConstraints.length() == 1);
        JSONObject jConstraint = jConstraints.optJSONObject(0);
View Full Code Here

                "'field': 'http:\\/\\/www.test.org\\/test#field', " +
                "}]" +
            "}",
            false); //expect BadRequest
        //now execute the test
        RequestExecutor re = executeQuery(test);
        JSONObject jQuery = assertResponseQuery(re.getContent());
        JSONArray jConstraints = jQuery.optJSONArray("constraints");
        assertNotNull("Result Query does not contain the constraints Array",jConstraints);
        assertTrue("Result Query Constraint Array does not contain the expected Constraint",
            jConstraints.length() == 1);
        JSONObject jConstraint = jConstraints.optJSONObject(0);
View Full Code Here

TOP

Related Classes of org.apache.stanbol.commons.testing.http.RequestExecutor$PreemptiveAuthInterceptor

Copyright © 2018 www.massapicom. 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.