Examples of RequestExecutor


Examples of org.apache.sling.testing.tools.http.RequestExecutor

   
    @Test
    public void testScriptableTest() throws Exception {
       
        // Execute all available scriptable tests and count failures
        final RequestExecutor executor = testClient.runTests(
                "org.apache.sling.junit.scriptable.ScriptableTestsProvider",
                null,
                "json"
                );
        executor.assertContentType("application/json");
        final JSONArray json = new JSONArray(new JSONTokener((executor.getContent())));
       
        int testsCount = 0;
        final List<String> failures = new ArrayList<String>();
        for(int i = 0 ; i < json.length(); i++) {
            final JSONObject obj = json.getJSONObject(i);
View Full Code Here

Examples of org.apache.sling.testing.tools.http.RequestExecutor

       final String testClassesSelector = method.getMethod().getDeclaringClass().getName();
       final String methodName = method.getMethod().getName();
      
       final RemoteTestHttpClient testHttpClient = new RemoteTestHttpClient(remoteUrl, remoteUsername, remotePassword, false);
       testHttpClient.setRequestCustomizer(this);
       final RequestExecutor executor = testHttpClient.runTests(
               testClassesSelector, methodName, "serialized"
       );
       log.debug("Ran test {} method {} at URL {}",
               new Object[] { testClassesSelector, methodName, remoteUrl });
      
       final HttpEntity entity = executor.getResponse().getEntity();
       if (entity != null) {
           try {
               final Object o = new ObjectInputStream(entity.getContent()).readObject();
               if( !(o instanceof ExecutionResult) ) {
                   throw new IllegalStateException("Expected an ExecutionResult, got a " + o.getClass().getName());
View Full Code Here

Examples of org.apache.sling.testing.tools.http.RequestExecutor

        if(testParameters instanceof RequestCustomizer) {
            testHttpClient.setRequestCustomizer((RequestCustomizer)testParameters);
        }
       
        // Run tests remotely and get response
        final RequestExecutor executor = testHttpClient.runTests(
                testParameters.getTestClassesSelector(),
                testParameters.getTestMethodSelector(),
                "json"
                );
        executor.assertContentType("application/json");
        final JSONArray json = new JSONArray(new JSONTokener((executor.getContent())));

        // Response contains an array of objects identified by
        // their INFO_TYPE, extract the tests
        // based on this vlaue
        for(int i = 0 ; i < json.length(); i++) {
View Full Code Here

Examples of org.apache.sling.testing.tools.http.RequestExecutor

    public TestResults runTests(String testPackageOrClassName) throws Exception {
        final RemoteTestHttpClient testClient = new RemoteTestHttpClient(serverBaseUrl + "/system/sling/junit",serverUsername,serverPassword,true);
        final TestResults r = new TestResults();
        final Map<String, String> options = new HashMap<String, String>();
        options.put("forceReload", "true");
        final RequestExecutor executor = testClient.runTests(testPackageOrClassName, null, "json", options);
        executor.assertContentType("application/json");
        String content = executor.getContent();
        final JSONArray json = new JSONArray(new JSONTokener(content));

        for(int i = 0 ; i < json.length(); i++) {
            final JSONObject obj = json.getJSONObject(i);
            if("test".equals(obj.getString("INFO_TYPE"))) {
View Full Code Here

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

            this.request = request;
            this.tracker = tracker;
        }
        @Override
        public void run() {
            RequestExecutor executor = new RequestExecutor(pooledHttpClient);
            long start = System.currentTimeMillis();
            Long rtt;
            try {
                executor.execute(request).assertStatus(200);
                content = null; //do not store content for successfull resutls
                rtt = System.currentTimeMillis()-start;
            } catch (Throwable e) {
                log.warn("Error while sending Request ",e);
                tracker.failed(request,content,executor);
                rtt = null;
                return;
            }
            IndexedMGraph graph = new IndexedMGraph();
            try {
                rdfParser.parse(graph,executor.getStream(), executor.getContentType().getMimeType());
            } catch (Exception e) {
                log.warn("Exception while parsing Enhancement Response",e);
                tracker.failed(request, content, executor);
                return;
            }
            Iterator<Triple> ciIt = graph.filter(null, Properties.ENHANCER_EXTRACTED_FROM, null);
            Assert.assertTrue("Enhancement Results do not caontain a single Enhancement",ciIt.hasNext());
            Resource contentItemUri = ciIt.next().getObject();
            Assert.assertTrue("ContentItem URI is not an UriRef but an instance of "
                    + contentItemUri.getClass().getSimpleName(), contentItemUri instanceof UriRef);
            tracker.succeed(request, (UriRef) contentItemUri, graph, rtt, executor.getContent().length());
        }
View Full Code Here

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

        return " %$&+,/:;=?@<>#%".indexOf(ch) >= 0;
    }

    @Test
    public void testCRUD() throws Exception {
        RequestExecutor request;

        // The needed Web resources to GET from.
        executor.execute(builder.buildGetRequest(SESSION_URI).withHeader("Accept", KRFormat.TURTLE))
                .assertStatus(200);
        log.info("Request: " + SESSION_URI + " ... DONE");

        String tempScopeUri = SESSION_URI + "/" + getClass().getCanonicalName() + "-"
                              + System.currentTimeMillis();

        // Scope should not be there
        request = executor.execute(builder.buildGetRequest(tempScopeUri)
                .withHeader("Accept", KRFormat.TURTLE));
        request.assertStatus(404);
        log.info("Request: " + tempScopeUri + " (should return 404) ... DONE");

        // Create scope
        executor.execute(builder.buildOtherRequest(new HttpPut(builder.buildUrl(tempScopeUri))));
        log.info("PUT Request: " + tempScopeUri + " ... DONE");

        // Scope should be there now
        request = executor.execute(builder.buildGetRequest(tempScopeUri)
                .withHeader("Accept", KRFormat.TURTLE));
        request.assertStatus(200).assertContentContains(tempScopeUri);
        log.info("Request: " + tempScopeUri + " ... DONE");

        // TODO the U of CRUD

        // Delete scope
        executor.execute(builder.buildOtherRequest(new HttpDelete(builder.buildUrl(tempScopeUri))));
        log.info("DELETE Request: " + tempScopeUri + " ... DONE");

        // Scope should not be there
        request = executor.execute(builder.buildGetRequest(tempScopeUri)
                .withHeader("Accept", KRFormat.TURTLE));
        request.assertStatus(404);
        log.info("Request: " + tempScopeUri + " (should return 404) ... DONE");
    }
View Full Code Here

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

    @Test
    public void testRemovalOfAccept() throws IOException, JSONException {
        //now test the removal of headers
        //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,
                "header_Accept","") //empty value to remove
            .withHeader("Accept", "application/rdf+xml")); //MUST override the rdf+xml
        re.assertStatus(200);
        //The default format (JSON) is expected
        assertEntity(re.getContent(), id, DBPEDIA_SITE_ID);
    }
View Full Code Here

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

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

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

        test.assertStatus(201);
    }

    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);
View Full Code Here

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

    private void testEntityUpdate() throws IOException, JSONException {
        InputStream in = EntityhubTest.class.getClassLoader().getResourceAsStream("mod_doap_Stanbol.rdf");
        Assert.assertNotNull("Unable to load test resource 'mod_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, false, stanbolProjectUri));
        //assert that the entity was created
        test.assertStatus(200);
        //check that the updated entity was returned
        assertEntity(test.getContent(), stanbolProjectUri, "entityhub");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.