Examples of RequestExecutor


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

        assertEntity(test.getContent(), stanbolProjectUri, "entityhub");
    }

    private void testEntityUpdated() throws IOException, JSONException {
        String id = "http://stanbol.apache.org";
        RequestExecutor re = executor.execute(
            builder.buildGetRequest("/entityhub/entity","id",id)
            .withHeader("Accept", "application/json"));
        re.assertStatus(200);

        JSONObject jEntity = assertEntity(re.getContent(), id, "entityhub");
        Map<String,Set<List<String>>> data = assertRepresentation(jEntity.getJSONObject("representation"),
            EXPECTED_DOAP_FIELDS, null);
        Set<List<String>> pmcValues = data.get("http://projects.apache.org/ns/asfext#pmc");
        Assert.assertNotNull(pmcValues);
        Assert.assertEquals(1, pmcValues.size());
View Full Code Here

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

   
    private void testEntityDelete() throws IOException {
        String stanbolProjectUri = "http://stanbol.apache.org";
        Request request = builder.buildOtherRequest(new HttpDelete(
            builder.buildUrl("/entityhub/entity", "id", stanbolProjectUri)));
        RequestExecutor re = executor.execute(request);
        re.assertStatus(200);
    }
View Full Code Here

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

        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

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

        re.assertStatus(200);
    }

    private void testEntityDeleted() throws IOException {
        String id = "http://stanbol.apache.org";
        RequestExecutor re = executor.execute(
            builder.buildGetRequest("/entityhub/entity","id",id)
            .withHeader("Accept", "application/json"));
        re.assertStatus(404);
    }
View Full Code Here

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

        re.assertStatus(404);
    }
    private void testEntityDeleteAll() throws IOException {
        Request request = builder.buildOtherRequest(new HttpDelete(
            builder.buildUrl("/entityhub/entity", "id", "*")));
        RequestExecutor re = executor.execute(request);
        re.assertStatus(200);
    }
View Full Code Here

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

        // 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

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

        RequestExecutor re = executor.execute(request);
        re.assertStatus(200);
    }
    private void testAllEntitiesDeleted() throws IOException {
        String id = "http://xml.apache.org/xerces-c/";
        RequestExecutor re = executor.execute(
            builder.buildGetRequest("/entityhub/entity","id",id)
            .withHeader("Accept", "application/json"));
        re.assertStatus(404);
    }
View Full Code Here

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

    }
    @Test
    public void testEntityLookup() throws IOException, JSONException {
        String uri = "http://dbpedia.org/resource/Paris";
        //first check that lookup without create returns 404
        RequestExecutor re = executor.execute(builder.buildGetRequest(
            "/entityhub/lookup", "id",uri));
        re.assertStatus(404);
        //Now check that lookup with create does work
        re = executor.execute(builder.buildGetRequest(
            "/entityhub/lookup", "id",uri,"create","true"));
        re.assertStatus(200);
        JSONObject entity = assertEntity(re.getContent(), null, "entityhub");
        String ehUri = entity.optString("id", null);
       
        //try to retrieve the entity with the generated id
        re = executor.execute(builder.buildGetRequest(
            "/entityhub/entity", "id",ehUri));
        re.assertStatus(200);
        assertEntity(re.getContent(), ehUri, "entityhub");
       
        //no try again to lookup the entity without create
        re = executor.execute(builder.buildGetRequest(
            "/entityhub/lookup", "id",uri));
        re.assertStatus(200);
        assertEntity(re.getContent(), ehUri, "entityhub");
       
        //finally delete the entity
        re = executor.execute(builder.buildOtherRequest(new HttpDelete(
            builder.buildUrl("/entityhub/entity", "id", ehUri))));
        re.assertStatus(200);

    }
View Full Code Here

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

        }
        Assert.assertNotNull(f.isFile());
        ZipFile archive = new ZipFile(f);
        for(Enumeration<? extends ZipEntry> e = archive.entries();e.hasMoreElements();){
            ZipEntry entry = e.nextElement();
            RequestExecutor re = executor.execute(
                buildImportRdfData(archive.getInputStream(entry) ,RDF_XML, false, null));
            //assert that the entity was created (or already existed)
            //some projects seams to have more than a single doap file
            int status = re.getResponse().getStatusLine().getStatusCode();
            Assert.assertTrue(status == 200 || status == 304);
        }
       
        testFindNameQuery();
        testFindWildcards();
        testFindLimitAndOffsetQuery();
        testFieldQueryTextConstraints();
        //finally delete all added entity
        RequestExecutor re = executor.execute(builder.buildOtherRequest(new HttpDelete(
            builder.buildUrl("/entityhub/entity", "id", "*"))));
        re.assertStatus(200);

    }
View Full Code Here

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

                    "http://xmlgraphics.apache.org/fop"),
            null);
        test.setField("http://usefulinc.com/ns/doap#description");
        test.setLimit(10);
        test.setLanguage(null);
        RequestExecutor re = executeQuery(test);
        //get the list of results (will assert the response twice)
        //to check the expected limit and offset results
        List<String> resultList = assertQueryResults(re,test);
        List<String> expected = resultList.subList(2, 4); //3rd and 4th element
        List<String> excluded = new ArrayList<String>(); //all other
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.