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

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


        Assert.assertEquals("http://stanbol.apache.org/downloads/", downloadValues.iterator().next().get(0));
    }
   
    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


            builder.buildGetRequest("/entityhub/entity","id",id)
            .withHeader("Accept", "application/json"));
        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

     * specifying the id parameter
     */
    protected Request buildImportRdfData(InputStream in, String contentType, boolean create, String uri){
        Assert.assertNotNull(in);
        Assert.assertNotNull(contentType);
        Request request;
        String path;
        if(uri != null){
            path = builder.buildUrl("/entityhub/entity", "id",uri);
        } else {
            path = builder.buildUrl("/entityhub/entity");
        }
        if(create){
            request = builder.buildOtherRequest(new HttpPost(path));
        } else {
            request = builder.buildOtherRequest(new HttpPut(path));
        }
        //set the HttpEntity (both PUT and POST are HttpEntityEnclosingRequests)
        ((HttpEntityEnclosingRequest)request.getRequest()).setEntity(
            new InputStreamEntity(in, -1));
        //finally set the correct content-type of the provided data
        //currently fixed to "application/rdf+xml"
        request.getRequest().setHeader("Content-Type", contentType);
        return request;
    }
View Full Code Here

            Math.max(100, settings.getNumThreads()*5));
        String rdfFormat = System.getProperty(PROPERTY_RDF_FORMAT,DEFAULT_RDF_FORMAT);
        int testNum;
        for(testNum = 0;testDataIterator.hasNext() && testNum < settings.getMaxRequests(); testNum++){
            String test = testDataIterator.next();
            Request request = builder.buildPostRequest(getEndpoint())
                    .withHeader("Accept",rdfFormat)
                    .withContent(test);
            tracker.register(request,test);
            if(testNum%100 == 0){
                log.info("  ... sent {} Requests ({} finished, {} pending, {} failed",
View Full Code Here

       
        for(String s : allServices() ){
            for(String t : TASKS){
                StringBuilder sb = new StringBuilder(REASONERS_PATH);
                sb.append(s).append(t).append("/job");
                Request request = buildMultipartRequest(sb.toString(),multiPart);
                executeAndPingSingleJob(request);
            }
        }
    }
View Full Code Here

        List<String> locations = new ArrayList<String>();
        for(String s : allServices() ){
            for(String t : TASKS){
                StringBuilder sb = new StringBuilder(REASONERS_PATH);
                sb.append(s).append(t).append("/job");
                Request request = buildMultipartRequest(sb.toString(), multiPart);
                String location = createJob(request);
                log.info("Started job {}", location);
                locations.add(location);
            }
        }
View Full Code Here

     */
    protected void pingSingleJob(String location) throws Exception{
        log.info("Start pinging {} ... ", location);
        boolean waiting = true;
        while(waiting){
            Request req = builder.buildOtherRequest(new HttpGet(location));
            req.withHeader("Accept", "application/json");
            log.info("Ping method: {}", req.getRequest().getMethod());
            log.info("Ping location: {}", req.getRequest().getURI());
            req.getRequest().setHeader("Accept","application/json");
            log.info("headers:");
            for(Header h : req.getRequest().getAllHeaders()){
                log.info("{}: {}", h.getName(), h.getValue());
            }
            log.info("Request line:\n\n {} \n\n", req.getRequest().getRequestLine().toString());
            try{
                String content = executor.execute(req).assertStatus(200).assertContentType("application/json").getContent();
                log.info("JSON content:\n\n {} \n\n",content);
                JSONObject json = new JSONObject(content);
                String status = json.getString("status");
View Full Code Here

     * @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;
    }
View Full Code Here

        executor.execute(r).assertStatus(400);
    }

    @Test
    public void createSimpleFactSchema() throws Exception {
        Request r = builder
                .buildOtherRequest(new HttpPut(builder.buildUrl("/factstore/facts/TestFactSchema")))
                .withContent(
                    "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"@types\":{\"organization\":\"iks:organization\",\"person\":\"iks:person\"}}}")
                .withHeader("Content-Type", "application/json");
View Full Code Here

        executor.execute(r).assertStatus(201);
    }

    @Test
    public void createURNFactSchema() throws Exception {
        Request r = builder
                .buildOtherRequest(
                    new HttpPut(builder.buildUrl("/factstore/facts/"
                                                 + encodeURI("http://www.iks-project.eu/ont/test"))))
                .withContent(
                    "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"@types\":{\"organization\":\"iks:organization\",\"person\":\"iks:person\"}}}")
View Full Code Here

TOP

Related Classes of org.apache.stanbol.commons.testing.http.Request

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.