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

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


                "'inclusive': true," +
                "}]" +
            "}",
            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


                .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));
                    }
                }
                log.info("Entityhub services checked, all present");
View Full Code Here

     */
//    @Test
    public void testEntityCreation() throws IOException {
        String singleImportResource = "";
        //create a POST request with a test RDF file
        RequestExecutor test = executor.execute(
            buildImportRdfData(singleImportResource, true, SINGLE_IMPORT_ENTITY_ID));
        //assert that the entity was created
        test.assertStatus(201);
       
        //NOTE: the check for the imported ID(s) is part of the
        // testEntityRetrieval test Method
       
    }
View Full Code Here

    }
//    @Test
    public void testMultipleEntityCreation() throws IOException {
        String multipleImportResource = "";
        //create a POST request with a test RDF file
        RequestExecutor test = executor.execute(
            buildImportRdfData(multipleImportResource, true, null));
        //assert that the entity was created
        test.assertStatus(201);
       
        //NOTE: the check for the imported ID(s) is part of the
        // testEntityRetrieval test Method
       
    }
View Full Code Here

    public void testEntityUpdates() throws IOException {
        String singleUpdateResource = "";
        //create a POST request with a test RDF file that contains updated data
        //of the one used for testEntityCreation
        //create a POST request with a test RDF file
        RequestExecutor test = executor.execute(
            buildImportRdfData(singleUpdateResource, false, SINGLE_IMPORT_ENTITY_ID));
        test.assertStatus(200);
        //TODO: validate that the entity was updated
       
    }
View Full Code Here

//    @Test
    public void testMultipleEntityUpdates() throws IOException {
        String nultipleUpdateResource = "";
        //create a POST request with a test RDF file that contains updated data
        //of the one used for testMultipleEntityCreation
        RequestExecutor test = executor.execute(
            buildImportRdfData(nultipleUpdateResource, false, null));
        test.assertStatus(200);
        //TODO: validate that the entity was updated
       
        //check for the updates to be applied
        //check the metadata to be updated (creation date != modification date)
    }
View Full Code Here

        return " %$&+,/:;=?@<>#%".indexOf(ch) >= 0;
    }

    @Test
    public void testActive() throws Exception {
        RequestExecutor request;

        String tempActiveScopeUri = BASE_SCOPES_URI + "/" + getClass().getCanonicalName() + "-testActive-"
                                    + System.currentTimeMillis() + "-active";
        String tempInactiveScopeUri = BASE_SCOPES_URI + "/" + getClass().getCanonicalName() + "-testActive-"
                                      + System.currentTimeMillis() + "-inactive";

        // Scopes should not be there
        request = executor.execute(builder.buildGetRequest(tempActiveScopeUri).withHeader("Accept",
            KRFormat.TURTLE));
        request.assertStatus(404);
        log.info("Request: " + tempActiveScopeUri + " (should return 404) ... DONE");
        request = executor.execute(builder.buildGetRequest(tempInactiveScopeUri).withHeader("Accept",
            KRFormat.TURTLE));
        request.assertStatus(404);
        log.info("Request: " + tempInactiveScopeUri + " (should return 404) ... DONE");

        // Create scopes, only activate one
        executor.execute(builder.buildOtherRequest(new HttpPut(builder.buildUrl(tempActiveScopeUri
                                                                                + "?activate=true"))));
View Full Code Here

        // We won't test here if deletion succeeded.
    }

    @Test
    public void testCRUD() throws Exception {
        RequestExecutor request;

        // The needed Web resources to GET from.
        executor.execute(builder.buildGetRequest(BASE_SCOPES_URI).withHeader("Accept", KRFormat.TURTLE))
                .assertStatus(200);
        log.info("Request: " + BASE_SCOPES_URI + " ... DONE");

        String tempScopeUri = BASE_SCOPES_URI + "/" + getClass().getCanonicalName() + "-"
                              + System.currentTimeMillis();

        // Scope should not be there
        request = executor.execute(builder.buildGetRequest(tempScopeUri)
                .withHeader("Accept", KRFormat.TURTLE));
        request.assertStatus(404);
        log.info("Request: " + tempScopeUri + " (should return 404) ... DONE");

        // Create scope
        executor.execute(builder.buildOtherRequest(new HttpPut(builder.buildUrl(tempScopeUri))));
        log.info("PUT Request: " + tempScopeUri + " ... DONE");

        // Scope should be there now
        request = executor.execute(builder.buildGetRequest(tempScopeUri)
                .withHeader("Accept", KRFormat.TURTLE));
        request.assertStatus(200).assertContentContains(tempScopeUri);
        log.info("Request: " + tempScopeUri + " ... DONE");
       
        // TODO the U of CRUD

        // Delete scope
        executor.execute(builder.buildOtherRequest(new HttpDelete(builder.buildUrl(tempScopeUri))));
        log.info("DELETE Request: " + tempScopeUri + " ... DONE");

        // Scope should not be there
        request = executor.execute(builder.buildGetRequest(tempScopeUri)
                .withHeader("Accept", KRFormat.TURTLE));
        request.assertStatus(404);
        log.info("Request: " + tempScopeUri + " (should return 404) ... DONE");
    }
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

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.