You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by al...@apache.org on 2012/02/27 16:27:02 UTC

svn commit: r1294184 - in /incubator/stanbol/trunk/integration-tests: pom.xml src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java

Author: alexdma
Date: Mon Feb 27 15:27:02 2012
New Revision: 1294184

URL: http://svn.apache.org/viewvc?rev=1294184&view=rev
Log:
- Some OntoNet integration tests back in place (STANBOL-472)
- Reinstated Reasoners endpoint integration test (STANBOL-379)

Modified:
    incubator/stanbol/trunk/integration-tests/pom.xml
    incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java
    incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java

Modified: incubator/stanbol/trunk/integration-tests/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/pom.xml?rev=1294184&r1=1294183&r2=1294184&view=diff
==============================================================================
--- incubator/stanbol/trunk/integration-tests/pom.xml (original)
+++ incubator/stanbol/trunk/integration-tests/pom.xml Mon Feb 27 15:27:02 2012
@@ -178,12 +178,14 @@
             <server.ready.path.4>/contenthub:Recently uploaded Content Items</server.ready.path.4>
             <server.ready.path.5>/entityhub:The RESTful API of the Entityhub</server.ready.path.5>
             <server.ready.path.6>/ontonet:Apache Stanbol OntoNet</server.ready.path.6>
-            <!-- server.ready.path.7>/reasoners:Apache Stanbol Reasoners</server.ready.path.7 -->
+            <server.ready.path.7>/reasoners:The Stanbol Reasoners provides</server.ready.path.7>
           </systemPropertyVariables>
           <excludes>
             <!-- TODO: remove before commit -->
             <!-- <exclude>**/enhancer/it/*.java</exclude> -->
+            <!--
             <exclude>**/ontologymanager/web/it/*.java</exclude>
+            -->
           </excludes>
         </configuration>
       </plugin>

Modified: incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java?rev=1294184&r1=1294183&r2=1294184&view=diff
==============================================================================
--- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java (original)
+++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java Mon Feb 27 15:27:02 2012
@@ -1,215 +1,152 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.ontologymanager.web.it;
 
-import java.io.IOException;
-
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.methods.HttpDelete;
 import org.apache.http.client.methods.HttpPut;
 import org.apache.stanbol.commons.testing.http.RequestExecutor;
 import org.apache.stanbol.commons.testing.stanbol.StanbolTestBase;
-
 import org.apache.stanbol.commons.web.base.format.KRFormat;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+public class ScopeTest extends StanbolTestBase {
 
-public class ScopeTest extends StanbolTestBase{
+    private static final String _ROOT_URI = "/ontonet";
 
-    public static final String ROOT_URI = "/ontonet";
+    private static final String BASE_SCOPES_URI = _ROOT_URI + "/ontology";
 
-    public static final String ONTOLOGY_URI = ROOT_URI + "/ontology";
+    private static final Logger log = LoggerFactory.getLogger(ScopeTest.class);
 
-    public static final String ONT_FOAF_URI = "http://xmlns.com/foaf/spec/index.rdf";
+    private static final String ONT_FOAF_URI = "http://xmlns.com/foaf/spec/index.rdf";
 
-    public static final String ONT_PIZZA_URI = "http://www.co-ode.org/ontologies/pizza/2007/02/12/pizza.owl";
+    private static final String ONT_PIZZA_URI = "http://www.co-ode.org/ontologies/pizza/2007/02/12/pizza.owl";
 
-    public static final String ONT_WINE_URI = "http://www.schemaweb.info/webservices/rest/GetRDFByID.aspx?id=62";
+    private static final String ONT_WINE_URI = "http://www.schemaweb.info/webservices/rest/GetRDFByID.aspx?id=62";
 
-    public static final String REG_TEST_URI = "http://www.ontologydesignpatterns.org/registry/krestest.owl";
+    private static final String REG_TEST_URI = "http://www.ontologydesignpatterns.org/registry/krestest.owl";
 
-    public static final String SCOPE_BIZ_URI = ONTOLOGY_URI + "/" + "Biz";
+    private static final String SCOPE_BIZ_URI = BASE_SCOPES_URI + "/" + "Biz";
 
-    public static final String SCOPE_DRUNK_URI = ONTOLOGY_URI + "/" + "Drunk";
+    private static final String SCOPE_DRUNK_URI = BASE_SCOPES_URI + "/" + "Drunk";
 
-    public static final String SCOPE_USER_URI = ONTOLOGY_URI + "/" + "User";
+    private static final String SCOPE_USER_URI = BASE_SCOPES_URI + "/" + "User";
 
-    public static final String SCOPE1_URI = ONTOLOGY_URI + "/" + "Pippo%20Baudo";
+    private static final String SCOPE1_URI = BASE_SCOPES_URI + "/" + "Pippo%20Baudo";
 
-    public static final String SCOPE2_URI = ONTOLOGY_URI + "/" + "TestScope2";
+    private static final String SCOPE2_URI = BASE_SCOPES_URI + "/" + "TestScope2";
 
-    private static final Logger log = LoggerFactory.getLogger(ScopeTest.class);
+    private String encodeURI(String s) {
+        StringBuilder o = new StringBuilder();
+        for (char ch : s.toCharArray()) {
+            if (isUnsafe(ch)) {
+                o.append('%');
+                o.append(toHex(ch / 16));
+                o.append(toHex(ch % 16));
+            } else o.append(ch);
+        }
+        return o.toString();
+    }
 
-    @Test
-    public void testGetScopes() throws ClientProtocolException, IOException {
-        RequestExecutor request;
+    private boolean isUnsafe(char ch) {
+        if (ch > 128 || ch < 0) return true;
+        return " %$&+,/:;=?@<>#%".indexOf(ch) >= 0;
+    }
 
-        // RDF_XML format
-        request = executor.execute(
-            builder.buildGetRequest(ONTOLOGY_URI)
-            .withHeader("Accept",KRFormat.RDF_XML)
-        );
-
-        request
-        .assertStatus(200)
-        .assertContentContains("<imports rdf:resource=\"http://www.ontologydesignpatterns.org/schemas/meta.owl\"/>");
-
-        log.debug("Request: "+ONTOLOGY_URI+"\n"+request.getContent());
-
-        // TURTLE format
-        request = executor.execute(
-            builder.buildGetRequest(ONTOLOGY_URI)
-            .withHeader("Accept",KRFormat.TURTLE)
-        );
-
-        request
-        .assertStatus(200)
-        .assertContentContains("owl:imports <http://www.ontologydesignpatterns.org/schemas/meta.owl>");
-        
-        log.debug("Request: "+ONTOLOGY_URI+"\n"+request.getContent());
+    @Test
+    public void testActive() throws Exception {
 
     }
 
     @Test
-    public void testRemoval() throws Exception {
-
-        executor.execute(
-            builder.buildOtherRequest( 
-                new HttpPut(
-                    builder.buildUrl(SCOPE_DRUNK_URI+"?corereg=" + encodeURI(REG_TEST_URI))))
-        );
+    public void testCRUD() throws Exception {
+        RequestExecutor request;
 
-        executor.execute(
-            builder.buildOtherRequest( 
-                new HttpDelete(
-                    builder.buildUrl(SCOPE_DRUNK_URI+"?ontology=" + encodeURI(ONT_WINE_URI))
-                )
-            )
-        );
+        // The needed Web resources to GET from.
+        executor.execute(builder.buildGetRequest(BASE_SCOPES_URI).withHeader("Accept", KRFormat.TURTLE))
+                .assertStatus(200);
+        log.info("Request: " + BASE_SCOPES_URI + " ... DONE");
+
+        String tempScopeUri = BASE_SCOPES_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 not be there
+        request = executor.execute(builder.buildGetRequest(tempScopeUri)
+                .withHeader("Accept", KRFormat.TURTLE));
+        request.assertStatus(200);
+        log.info("Request: " + tempScopeUri + " ... DONE");
+
+        // 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");
     }
 
     @Test
     public void testLocking() throws Exception {
-        // Create a scope with a core ontology and a custom registry.
-        executor.execute(
-            builder.buildOtherRequest( 
-                new HttpPut(
-                    builder.buildUrl(SCOPE2_URI+"?customont="+encodeURI(ONT_PIZZA_URI)+"&corereg=" + encodeURI(REG_TEST_URI))
-                )
-            )
-        );
-
-        executor.execute(
-            builder.buildPostRequest(SCOPE2_URI +
-                "?location" + encodeURI(ONT_PIZZA_URI) +
-            "&registry=false")
-        );
-
-        // get in RDF_XML format
-        executor.execute(
-            builder.buildGetRequest(SCOPE2_URI)
-            .withHeader("Accept",KRFormat.RDF_XML)
-        ).assertStatus(200);
 
     }
 
-
-    /**
-     * Tests that the creation of active and inactive scopes is reflected in the RDF version of the scope set,
-     * whether it is set to display all scopes or only the active ones.
-     */
     @Test
-    public void testActiveVsAll() throws Exception {
-
-        // The needed Web resources to GET from.
-        executor.execute(
-            builder.buildGetRequest(ONTOLOGY_URI)
-            .withHeader("Accept",KRFormat.RDF_XML)
-        ).assertStatus(200);
-        log.info("Request: "+ONTOLOGY_URI +" ... DONE");
-
-        executor.execute(
-            builder.buildGetRequest(ONTOLOGY_URI,"with-inactive","true")
-            .withHeader("Accept",KRFormat.RDF_XML)
-        ).assertStatus(200);
-        log.info("Request: "+ONTOLOGY_URI+"?with-inactive=true"+" ... DONE");
-
-        // Put a simple, inactive scope.
-        executor.execute(
-            builder.buildOtherRequest( 
-                new HttpPut(
-                    builder.buildUrl(SCOPE_USER_URI+"?coreont=" + encodeURI(ONT_FOAF_URI))))
-        );
-        log.info("Request: "+SCOPE_USER_URI+"?coreont=" + ONT_FOAF_URI+" ... DONE");
-
-        // Check that it is in the list of all scopes.
-        executor.execute(
-            builder.buildGetRequest(SCOPE_USER_URI,"with-inactive","true")
-        ).assertStatus(200).assertContentContains(SCOPE_USER_URI);
-
-        // Check that it is not in the list of active scopes.
-        executor.execute(
-            builder.buildGetRequest(SCOPE_USER_URI)
-        ).assertStatus(200).assertContentContains(SCOPE_USER_URI);
-
-        // Now create a scope that is active on startup.
-        executor.execute(
-            builder.buildOtherRequest( 
-                new HttpPut(
-                    builder.buildUrl(SCOPE_BIZ_URI+"?activate=true&coreont=" + encodeURI(ONT_PIZZA_URI))))
-        );
-        log.info("Request: "+SCOPE_BIZ_URI+"?activate=true&coreont=" + ONT_PIZZA_URI+" ... DONE");
-
-        // Check that it appears in both sets.
-        executor.execute(
-            builder.buildGetRequest(ONTOLOGY_URI)
-            .withHeader("Accept",KRFormat.RDF_XML)
-        ).assertStatus(200).assertContentContains(SCOPE_BIZ_URI);
-        
-        executor.execute(
-            builder.buildGetRequest(ONTOLOGY_URI,"with-inactive","true")
-            .withHeader("Accept",KRFormat.RDF_XML)
-        ).assertStatus(200).assertContentContains(SCOPE_BIZ_URI);
-
+    public void testSupportedOWLFormats() throws Exception {
+        executor.execute(builder.buildGetRequest(BASE_SCOPES_URI).withHeader("Accept", KRFormat.OWL_XML))
+                .assertStatus(200);
+        log.info("Request: " + BASE_SCOPES_URI + " (Accept: " + KRFormat.OWL_XML + ")" + " ... DONE");
+        executor.execute(
+            builder.buildGetRequest(BASE_SCOPES_URI).withHeader("Accept", KRFormat.MANCHESTER_OWL))
+                .assertStatus(200);
+        log.info("Request: " + BASE_SCOPES_URI + " (Accept: " + KRFormat.MANCHESTER_OWL + ")" + " ... DONE");
+        executor.execute(
+            builder.buildGetRequest(BASE_SCOPES_URI).withHeader("Accept", KRFormat.FUNCTIONAL_OWL))
+                .assertStatus(200);
+        log.info("Request: " + BASE_SCOPES_URI + " (Accept: " + KRFormat.FUNCTIONAL_OWL + ")" + " ... DONE");
     }
 
-
-    private String encodeURI(String s) {
-        StringBuilder o = new StringBuilder();
-        for (char ch : s.toCharArray()) {
-            if (isUnsafe(ch)) {
-                o.append('%');
-                o.append(toHex(ch / 16));
-                o.append(toHex(ch % 16));
-            } else o.append(ch);
-        }
-        return o.toString();
+    @Test
+    public void testSupportedRDFFormats() throws Exception {
+        executor.execute(builder.buildGetRequest(BASE_SCOPES_URI).withHeader("Accept", KRFormat.RDF_XML))
+                .assertStatus(200);
+        log.info("Request: " + BASE_SCOPES_URI + " (Accept: " + KRFormat.RDF_XML + ")" + " ... DONE");
+        executor.execute(builder.buildGetRequest(BASE_SCOPES_URI).withHeader("Accept", KRFormat.RDF_JSON))
+                .assertStatus(200);
+        log.info("Request: " + BASE_SCOPES_URI + " (Accept: " + KRFormat.RDF_JSON + ")" + " ... DONE");
+        executor.execute(builder.buildGetRequest(BASE_SCOPES_URI).withHeader("Accept", KRFormat.TURTLE))
+                .assertStatus(200);
+        log.info("Request: " + BASE_SCOPES_URI + " (Accept: " + KRFormat.TURTLE + ")" + " ... DONE");
     }
 
     private char toHex(int ch) {
         return (char) (ch < 10 ? '0' + ch : 'A' + ch - 10);
     }
 
-    private boolean isUnsafe(char ch) {
-        if (ch > 128 || ch < 0) return true;
-        return " %$&+,/:;=?@<>#%".indexOf(ch) >= 0;
-    }
-
 }

Modified: incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java?rev=1294184&r1=1294183&r2=1294184&view=diff
==============================================================================
--- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java (original)
+++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java Mon Feb 27 15:27:02 2012
@@ -1,59 +1,39 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.ontologymanager.web.it;
 
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 
-import javax.ws.rs.core.MediaType;
-
+import org.apache.http.client.ClientProtocolException;
+import org.apache.stanbol.commons.testing.stanbol.StanbolTestBase;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.http.client.ClientProtocolException;
+public class SessionTest extends StanbolTestBase {
 
-import org.apache.stanbol.commons.testing.stanbol.StanbolTestBase;
-import org.apache.stanbol.commons.web.base.format.KRFormat;
-
-public class SessionTest extends StanbolTestBase{
+    private static final Logger log = LoggerFactory.getLogger(SessionTest.class);
 
     public static final String ROOT_URI = "/ontonet";
 
     public static final String SESSION_URI = ROOT_URI + "/session";
-    
-    private static final Logger log = LoggerFactory.getLogger(SessionTest.class);
 
-    @Test
-    public void testSessionCreation() throws ClientProtocolException, IOException {
-        
-        /*log.info(executor.execute(
-            builder.buildPostRequest(SESSION_URI+"?scope="+encodeURI("http://localhost:8080/ontonet/ontology/User"))
-            .withHeader("Content-type",MediaType.APPLICATION_FORM_URLENCODED)
-            .withHeader("Accept",KRFormat.RDF_XML)
-        ).getContent()); //.assertStatus(200);*/
-        
-        
-        
-        assertTrue(true);
-        
-    }
-    
     private String encodeURI(String s) {
         StringBuilder o = new StringBuilder();
         for (char ch : s.toCharArray()) {
@@ -66,12 +46,26 @@ public class SessionTest extends Stanbol
         return o.toString();
     }
 
-    private char toHex(int ch) {
-        return (char) (ch < 10 ? '0' + ch : 'A' + ch - 10);
-    }
-
     private boolean isUnsafe(char ch) {
         if (ch > 128 || ch < 0) return true;
         return " %$&+,/:;=?@<>#%".indexOf(ch) >= 0;
     }
+
+    @Test
+    public void testSessionCreation() throws ClientProtocolException, IOException {
+
+        /*
+         * log.info(executor.execute(
+         * builder.buildPostRequest(SESSION_URI+"?scope="+encodeURI("http://localhost:8080/ontonet/ontology/User"
+         * )) .withHeader("Content-type",MediaType.APPLICATION_FORM_URLENCODED)
+         * .withHeader("Accept",KRFormat.RDF_XML) ).getContent()); //.assertStatus(200);
+         */
+
+        assertTrue(true);
+
+    }
+
+    private char toHex(int ch) {
+        return (char) (ch < 10 ? '0' + ch : 'A' + ch - 10);
+    }
 }