protected Request buildMultipartRequest(String path,MultipartEntity multiPart) { HttpPost httpPost = new HttpPost(builder.buildUrl(path)); httpPost.setEntity(multiPart); /** * In case of Multipart requests, we must __NOT__ set the content-type header to multipart/form-data. * If we do it, we have a 400 response (bad request). */ return this.builder.buildOtherRequest(httpPost); }
/** * Build a GET request to specified path with optional query * parameters. See {@link #buildUrl(String, String...)} for * queryParameters semantics. */ public Request buildGetRequest(String path, String... queryParameters) { return new Request(new HttpGet(buildUrl(path, queryParameters))); }
log.debug("> before {}#waitForServerReady()",getClass().getSimpleName()); builder = new RequestBuilder(serverBaseUrl);
/** * Executes a {@link QueryTestCase} by sending the * {@link QueryTestCase#getContent() query} as an POST request to the * <code>{@link #endpointPath}/{@link QueryTestCase#getServicePath()}</Code>. * @param path the path to perform the field query. "/query" is added to the * parsed value * @param test the field query test * @return the result executor used for the test * @throws IOException on any exception while connecting to the entityhub * @throws JSONException if the returned results are not valid JSON */ protected RequestExecutor executeQuery(QueryTestCase test) throws IOException, JSONException { 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; } /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
boolean waiting = true; while(waiting){ Request req = builder.buildOtherRequest(new HttpGet(location)); req.withHeader("Accept", "application/json"); log.info("Ping method: {}", req.getRequest().getMethod());
builder.buildGetRequest("/entityhub") .withHeader("Accept", "text/html") builder.buildGetRequest("/entityhub/sites/referenced") .withHeader("Accept", "application/json")); re.assertStatus(200); builder.buildGetRequest("/entityhub/site/"+referencedSite) .withHeader("Accept", "application/json")); //check JSON serializer re.assertStatus(200); re.assertContentType("application/json"); re = executor.execute(builder.buildGetRequest("/entityhub/site/"+referencedSite) .withHeader("Accept", "application/rdf+xml"));//check RDF serializer re.assertStatus(200);
/** * Build a POST request to specified path with optional query * parameters. See {@link #buildUrl(String, String...)} for * queryParameters semantics. */ public Request buildPostRequest(String path) { return new Request(new HttpPost(buildUrl(path))); }
log.debug("> before {}#waitForServerReady()",getClass().getSimpleName()); builder = new RequestBuilder(serverBaseUrl);