use of org.apache.stanbol.commons.testing.http.RequestExecutor in project stanbol by apache.
the class HttpQueryHeaderGetTest method testGetAccept.
/**
* Validates that parsing rdf+xml normally as Accept header and that
* JSON is the default if no header is parsed.
* NOTE: This does not actually test the http query header, but checks
* the assumptions behind all the following tests.
* @throws IOException
* @throws JSONException
*/
@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\">", "<rdf:type rdf:resource=\"http://dbpedia.org/ontology/Place\"/>");
//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);
}
use of org.apache.stanbol.commons.testing.http.RequestExecutor in project stanbol by apache.
the class EntityhubTest method testEntityCreated.
private void testEntityCreated() 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);
//test values of two properties we will update in a following test
Set<List<String>> pmcValues = data.get("http://projects.apache.org/ns/asfext#pmc");
Assert.assertNotNull(pmcValues);
Assert.assertEquals(1, pmcValues.size());
Assert.assertEquals("http://incubator.apache.org", pmcValues.iterator().next().get(0));
Set<List<String>> downloadValues = data.get("http://usefulinc.com/ns/doap#download-page");
Assert.assertNotNull(downloadValues);
Assert.assertEquals(1, downloadValues.size());
Assert.assertEquals("http://stanbol.apache.org", downloadValues.iterator().next().get(0));
}
use of org.apache.stanbol.commons.testing.http.RequestExecutor in project stanbol by apache.
the class EntityhubTest method testEntityCreation.
private void testEntityCreation() throws IOException {
InputStream in = EntityhubTest.class.getClassLoader().getResourceAsStream("doap_Stanbol.rdf");
Assert.assertNotNull("Unable to load test resource 'doap_Stanbol.rdf'", in);
String stanbolProjectUri = "http://stanbol.apache.org";
//create a POST request with a test RDF file
RequestExecutor test = executor.execute(buildImportRdfData(in, RDF_XML, true, stanbolProjectUri));
//assert that the entity was created
test.assertStatus(201);
}
use of org.apache.stanbol.commons.testing.http.RequestExecutor in project stanbol by apache.
the class EntityhubTest method testEntityUpdated.
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());
Assert.assertEquals("http://stanbol.apache.org", pmcValues.iterator().next().get(0));
Set<List<String>> downloadValues = data.get("http://usefulinc.com/ns/doap#download-page");
Assert.assertNotNull(downloadValues);
Assert.assertEquals(1, downloadValues.size());
Assert.assertEquals("http://stanbol.apache.org/downloads/", downloadValues.iterator().next().get(0));
}
use of org.apache.stanbol.commons.testing.http.RequestExecutor in project stanbol by apache.
the class EntityhubTest method testEntityDeleteAll.
private void testEntityDeleteAll() throws IOException {
Request request = builder.buildOtherRequest(new HttpDelete(builder.buildUrl("/entityhub/entity", "id", "*")));
RequestExecutor re = executor.execute(request);
re.assertStatus(200);
}
Aggregations