protected Response postNonRDFSource(String slug, String file, String mimeType) throws IOException { // Make sure we can post binary resources return buildBaseRequestSpecification() .header(SLUG, slug) .body(IOUtils.toByteArray(getClass().getResourceAsStream("/" + file))) .contentType(mimeType) .expect() .statusCode(HttpStatus.SC_CREATED) .header(LOCATION, HeaderMatchers.headerPresent()) .when() .post(container); }
@Test( groups = {MUST}, description = "LDP servers MUST support the HTTP HEAD method. ") @SpecTest( specRefUri = LdpTestSuite.SPEC_URI + "#ldpr-head-must", testMethod = METHOD.AUTOMATED, approval = STATUS.WG_APPROVED) public void testHead() { assertTrue(supports(HttpMethod.HEAD), "HTTP HEAD is not listed in the Allow response header on HTTP OPTIONS requests for resource <" + getResourceUri() + ">"); buildBaseRequestSpecification().expect().statusCode(isSuccessful()).when().head(getResourceUri()); }
@Test( groups = {MUST}, description = "LDP servers MUST support the HTTP OPTIONS method. ") @SpecTest( specRefUri = LdpTestSuite.SPEC_URI + "#ldpr-options-must", testMethod = METHOD.AUTOMATED, approval = STATUS.WG_APPROVED) public void testOptions() { buildBaseRequestSpecification().expect().statusCode(isSuccessful()).when().options(getResourceUri()); }
@Test( groups = {MUST}, description = "LDP servers MUST support the HTTP GET Method for LDPRs") @SpecTest( specRefUri = LdpTestSuite.SPEC_URI + "#ldpr-get-must", testMethod = METHOD.AUTOMATED, approval = STATUS.WG_APPROVED) public void testGetResource() { assertTrue(supports(HttpMethod.GET), "HTTP GET is not listed in the Allow response header on HTTP OPTIONS requests for resource <" + getResourceUri() + ">"); buildBaseRequestSpecification() .expect().statusCode(isSuccessful()) .when().get(getResourceUri()); }
protected void expectPut4xxConstrainedBy(String invalidProp) { Response putResponse = expectPut4xxStatus(invalidProp); final String uri = getResourceUri(); String constrainedBy = getFirstLinkForRelation(uri, LINK_REL_CONSTRAINEDBY, uri, putResponse); assertNotNull(constrainedBy, "Response did not contain a Link header with rel=\"http://www.w3.org/ns/ldp#constrainedBy\""); // Make sure we can GET the constrainedBy link. buildBaseRequestSpecification() .expect() .statusCode(isSuccessful()) .when() .get(constrainedBy); }
private String post(Model content, String slug) { RequestSpecification spec = buildBaseRequestSpecification().contentType(TEXT_TURTLE); if (slug != null) { spec.header(SLUG, slug); } Response post = spec.body(content, new RdfObjectMapper()).expect() .statusCode(HttpStatus.SC_CREATED).when() .post(getResourceUri()); String location = post.getHeader(LOCATION); assertNotNull(location, MSG_LOC_NOTFOUND); return location; }
public Model getResourceAsModel(String uri, String mediaType) { return buildBaseRequestSpecification() .header(ACCEPT, mediaType) .expect() .statusCode(isSuccessful()) .when() .get(uri).as(Model.class, new RdfObjectMapper(uri)); }
protected static void assertCreateUser(User user){ given() .contentType("application/json;charset=UTF-8") .accept("application/json") .body(user) .expect().log().ifError() .statusCode(HttpStatus.SC_CREATED) .when() .post(getHost() + CONTEXT_PATH + "/users"); }
protected static UserDTO assertUserExists(String path){ Response response = given() .expect().log().ifError() .statusCode(HttpStatus.SC_OK) .when() .get(getHost() + CONTEXT_PATH + path + JSON_SUFFIX); return deserialize(response.getBody().asString()); } }
@Test public void testGetConnectors_badDefinition() throws Exception { given().expect() // .statusCode(400) // .log().ifValidationFails() // // TODO: check returned error .body(Matchers.containsString("definitionClass")) // .get(getVersionPrefix() + "/properties/{name}/connectors", DATA_SET_DEFINITION_NAME); }
private final Query queryResource(URL contextURL, String path) throws IOException { Response response= given(). accept(TEXT_TURTLE). baseUri(contextURL.toString()). expect(). statusCode(OK). contentType(TEXT_TURTLE). when(). get(path); return QueryResponseHelper.getQuery(contextURL, path, response.asString()); }
@Test public void testGetIcon_svgImageTypeFound() throws Exception { given().expect() // .statusCode(200).log().ifError() // .body(Matchers.containsString("</svg>")) // .contentType(IMAGE_SVG_VALUE) // .get(getVersionPrefix() + "/properties/{name}/icon/{type}", DATA_SET_DEFINITION_NAME, DefinitionImageType.SVG_ICON); }
@Test public void testGetIcon_imageTypeNotFound() throws Exception { given().expect() // .statusCode(404) // .log().ifValidationFails() // .get(getVersionPrefix() + "/properties/{name}/icon/{type}", DATA_STORE_DEFINITION_NAME, DefinitionImageType.SVG_ICON); }
@Test public void testValidateProperties() throws Exception { ObjectNode validationResult = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataStoreFormData()) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/validate").as(ObjectNode.class); assertNotNull(validationResult); assertEquals("OK", validationResult.get("status").textValue()); }
@Test public void testValidatePropertiesJsonio() throws Exception { ObjectNode validationResult = given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataStoreSerProps()) // .contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/validate").as(ObjectNode.class); assertNotNull(validationResult); assertEquals("OK", validationResult.get("status").textValue()); }
@Test public void testGetProperties() throws Exception { given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with().port(localServerPort) // .get(getVersionPrefix() + "/properties/{name}", DATA_STORE_DEFINITION_NAME); }
@Test public void testGetDatasetPropertiesFromUiSpecs() throws Exception { given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataStoreFormData()) // .contentType(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/dataset"); }
@Test public void testGetDatasetPropertiesFromSer() throws Exception { given().accept(ServiceConstants.UI_SPEC_CONTENT_TYPE) // .expect() // .statusCode(200).log().ifError() // .with() // .content(buildTestDataStoreSerProps()) // .contentType(ServiceConstants.JSONIO_CONTENT_TYPE) // .post(getVersionPrefix() + "/properties/dataset"); }
@Test public void validateDataStoreConnection() throws java.io.IOException { // given UiSpecsPropertiesDto properties = new UiSpecsPropertiesDto(); properties.setProperties(getJdbcDataStoreProperties()); // when given().content(properties).contentType(APPLICATION_JSON_UTF8_VALUE) // .accept(APPLICATION_JSON_UTF8_VALUE) // .expect().statusCode(200).log().ifError() // .post(getVersionPrefix() + "/runtimes/check"); }