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

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


        Assert.assertEquals(expected, actual);
    }
   
    @Test
    public void querySingleFactMultiResults() throws Exception {
        Request r1 = builder
        .buildOtherRequest(
            new HttpPut(builder.buildUrl("/factstore/facts/"
                                         + encodeURI("http://iks-project.eu/ont/emplOf"))))
        .withContent(
            "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"@types\":{\"person\":\"iks:person\",\"organization\":\"iks:organization\"}}}")
        .withHeader("Content-Type", "application/json");
        executor.execute(r1).assertStatus(201);

        Request r2 = builder
        .buildOtherRequest(new HttpPost(builder.buildUrl("/factstore/facts/")))
        .withContent(
            "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@profile\":\"iks:emplOf\",\"person\":{\"@iri\":\"upb:jim\"},\"organization\":{\"@iri\":\"http://upb.de\"}}")
        .withHeader("Content-Type", "application/json");
        executor.execute(r2).assertStatus(200);
       
        Request r3 = builder
        .buildOtherRequest(new HttpPost(builder.buildUrl("/factstore/facts/")))
        .withContent(
            "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@profile\":\"iks:emplOf\",\"person\":{\"@iri\":\"upb:john\"},\"organization\":{\"@iri\":\"http://upb.de\"}}")
        .withHeader("Content-Type", "application/json");
        executor.execute(r3).assertStatus(200);
       
        Request r4 = builder
        .buildOtherRequest(new HttpPost(builder.buildUrl("/factstore/facts/")))
        .withContent(
            "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\",\"upb\":\"http://upb.de/persons/\"},\"@profile\":\"iks:emplOf\",\"person\":{\"@iri\":\"upb:james\"},\"organization\":{\"@iri\":\"http://upb.de\"}}")
        .withHeader("Content-Type", "application/json");
        executor.execute(r4).assertStatus(200);
       
        String queryString = "{\"@context\":{\"iks\":\"http://iks-project.eu/ont/\"},\"select\":[\"person\"],\"from\":\"iks:emplOf\",\"where\":[{\"=\":{\"organization\":{\"@iri\":\"http://upb.de\"}}}]}";
        Request q = builder
        .buildOtherRequest(new HttpPost(builder.buildUrl("/factstore/query/")))
        .withContent(queryString)
        .withHeader("Content-Type", "application/json")
        .withHeader("Accept", "application/json");
               
View Full Code Here


     * updated (PUT).
     * @param uri if not <code>null</code> only data of this URI are imported by
     * specifying the id parameter
     */
    protected Request buildImportRdfData(String file, boolean create, String uri){
        Request request;
        String path;
        if(uri != null){
            path = builder.buildUrl("/entity", "id",uri);
        } else {
            path = builder.buildUrl("/entity");
        }
        if(create){
            request = builder.buildPostRequest(path);
        } else {
            request = builder.buildOtherRequest(new HttpPut(path));
        }
        //set the HttpEntity (both PUT and POST are HttpEntityEnclosingRequests)
        ((HttpEntityEnclosingRequest)request.getRequest()).setEntity(
            new InputStreamEntity(
                EntityhubTest.class.getClassLoader().getResourceAsStream(file),
                -1));
        //finally set the correct content-type of the provided data
        //currently fixed to "application/rdf+xml"
        request.getRequest().setHeader("Content-Type", "application/rdf+xml");
       
        return request;
    }
View Full Code Here

        }
    }

    @Test
    public void maximumSchemaURNLength() throws Exception {
        Request r = builder
                .buildOtherRequest(
                    new HttpPut(
                            builder
                                    .buildUrl("/factstore/facts/"
                                              + encodeURI("http://www.test.de/this/urn/is/a/bit/too/long/to/be/used/in/this/fact/store/implementation/with/derby"))))
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

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.