You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stanbol.apache.org by Fabian Christ <ch...@googlemail.com> on 2011/06/28 10:23:00 UTC
Re: svn commit: r1140324 - in /incubator/stanbol/trunk:
integration-tests/ integration-tests/src/test/java/org/apache/stanbol/ontologymanager/
integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/ integration-tests/src/test/java/org
Hi,
I have some problems with this patch:
1) testHomepageExamples fails
testHomepageExamples(org.apache.stanbol.ontologymanager.web.it.HomepageTest)
Time elapsed: 11.96 sec <<< FAILURE!
java.lang.AssertionError: GET request to
http://localhost:59205/ontonet: expecting status 200 expected:<200>
but was:<404>
2) Instead of using the server.ready.path feature introduced by
StanbolTestBase there is now a new class OntonetTestBase with a
function checkEnginesReady() that tries to do the same. The existing
server.ready.path in the pom.xml were deactivated (commented out).
IMO this is not the way the integration-test should be implemented.
Best,
- Fabian
2011/6/27 <en...@apache.org>:
> Author: enridaga
> Date: Mon Jun 27 21:17:10 2011
> New Revision: 1140324
>
> URL: http://svn.apache.org/viewvc?rev=1140324&view=rev
> Log:
> Committed patch submitted at STANBOL-177
> * Moving ontologymanager/web tests to integration-tests
> * Added ontonet and web modules to full launcher
>
> Added:
> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/
> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/
> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/
> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java
> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java
> 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
> Removed:
> incubator/stanbol/trunk/ontologymanager/web/src/test/java/org/apache/stanbol/ontologymanager/web/JettyServerTest.java
> Modified:
> incubator/stanbol/trunk/integration-tests/pom.xml
> incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml
> incubator/stanbol/trunk/ontologymanager/web/pom.xml
> incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java
>
> Modified: incubator/stanbol/trunk/integration-tests/pom.xml
> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/pom.xml?rev=1140324&r1=1140323&r2=1140324&view=diff
> ==============================================================================
> --- incubator/stanbol/trunk/integration-tests/pom.xml (original)
> +++ incubator/stanbol/trunk/integration-tests/pom.xml Mon Jun 27 21:17:10 2011
> @@ -46,6 +46,12 @@
> <version>0.9-SNAPSHOT</version>
> <scope>test</scope>
> </dependency>
> + <dependency>
> + <groupId>org.apache.stanbol</groupId>
> + <artifactId>org.apache.stanbol.commons.web.base</artifactId>
> + <version>0.9-SNAPSHOT</version>
> + <scope>test</scope>
> + </dependency>
> <dependency>
> <groupId>org.apache.stanbol</groupId>
> <artifactId>org.apache.stanbol.commons.testing.http</artifactId>
> @@ -130,9 +136,9 @@
> <keepJarRunning>${keepJarRunning}</keepJarRunning>
> <server.ready.timeout.seconds>180</server.ready.timeout.seconds>
> <server.ready.path.1>/:stanbol.css</server.ready.path.1>
> - <server.ready.path.2>/engines:There are currently</server.ready.path.2>
> + <!--<server.ready.path.2>/engines:There are currently</server.ready.path.2>
> <server.ready.path.3>/contenthub:Recently uploaded Content Items</server.ready.path.3>
> - <server.ready.path.4>/factstore:The FactStore implements a store</server.ready.path.4>
> + <server.ready.path.4>/factstore:The FactStore implements a store</server.ready.path.4>-->
> </systemPropertyVariables>
> </configuration>
> </plugin>
>
> Added: incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java
> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java?rev=1140324&view=auto
> ==============================================================================
> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java (added)
> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java Mon Jun 27 21:17:10 2011
> @@ -0,0 +1,31 @@
> +
> +package org.apache.stanbol.ontologymanager.web.it;
> +
> +import org.apache.stanbol.commons.testing.stanbol.StanbolTestBase;
> +import org.junit.Test;
> +
> +/**
> + * Test the ontonet homepage and demonstrate the test classes.
> + *
> + * @author alberto musetti
> + */
> +
> +public class HomepageTest extends StanbolTestBase {
> +
> + @Test
> + public void testHomepageExamples() throws Exception {
> +
> + executor.execute(
> + builder.buildGetRequest("/ontonet")
> + .withHeader("Accept", "text/html")
> + )
> + .assertStatus(200)
> + .assertContentType("text/html")
> + .assertContentContains(
> + "/static/home/style/stanbol.css",
> + "The RESTful Semantic Engine")
> + .assertContentRegexp(
> + "stylesheet.*stanbol.css",
> + "<title.*[Ss]tanbol");
> + }
> +}
> \ No newline at end of file
>
> Added: incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java
> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java?rev=1140324&view=auto
> ==============================================================================
> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java (added)
> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java Mon Jun 27 21:17:10 2011
> @@ -0,0 +1,74 @@
> +package org.apache.stanbol.ontologymanager.web.it;
> +
> +import static org.junit.Assert.fail;
> +
> +import org.slf4j.Logger;
> +import org.slf4j.LoggerFactory;
> +
> +import org.apache.stanbol.commons.testing.http.RetryLoop;
> +import org.apache.stanbol.commons.testing.stanbol.StanbolTestBase;
> +import org.junit.Before;
> +
> +/**
> + * Inherit from this to wait for all to be up before running tests.
> + */
> +public class OntonetTestBase extends StanbolTestBase {
> +
> + private final Logger log = LoggerFactory.getLogger(getClass());
> +
> + // TODO configurable via system properties??
> + public static final int ENGINES_TIMEOUT_SECONDS = 60;
> + public static final int WAIT_BETWEEN_TRIES_MSEC = 1000;
> +
> + static boolean enginesReady;
> + static boolean timedOut;
> +
> + @Before
> + public void checkEnginesReady() throws Exception {
> +
> + // Check only once per test run
> + if(enginesReady) {
> + return;
> + }
> +
> + // If we timed out previously, don't waste time checking again
> + if(timedOut) {
> + fail("Timeout in previous check of ontonet engine, cannot run tests");
> + }
> +
> + final RetryLoop.Condition c = new RetryLoop.Condition() {
> +
> + @Override
> + public boolean isTrue() throws Exception {
> + executor.execute(
> + builder.buildGetRequest("/ontonet")
> + .withHeader("Accept", "text/html")
> + )
> + .assertStatus(200)
> + .assertContentType("text/html");
> +
> + log.info("Ontonet checked, engine is ready.");
> + return true;
> + }
> +
> + @Override
> + public String getDescription() {
> + return "Checking that Ontonet engine is ready";
> + }
> + };
> +
> + new RetryLoop(c, ENGINES_TIMEOUT_SECONDS, WAIT_BETWEEN_TRIES_MSEC) {
> + @Override
> + protected void reportException(Throwable t) {
> + log.info("Exception in RetryLoop, will retry for up to "
> + + getRemainingTimeSeconds() + " seconds: " + t);
> + }
> +
> + protected void onTimeout() {
> + timedOut = true;
> + }
> + };
> +
> + enginesReady = true;
> + }
> +}
>
> Added: 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=1140324&view=auto
> ==============================================================================
> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java (added)
> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java Mon Jun 27 21:17:10 2011
> @@ -0,0 +1,205 @@
> +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.web.base.format.KRFormat;
> +
> +
> +public class ScopeTest extends OntonetTestBase{
> +
> + public static final String ROOT_URI = "/ontonet";
> +
> + public static final String ONTOLOGY_URI = ROOT_URI + "/ontology";
> +
> + public 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";
> +
> + public 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";
> +
> + public static final String SCOPE_BIZ_URI = ONTOLOGY_URI + "/" + "Biz";
> +
> + public static final String SCOPE_DRUNK_URI = ONTOLOGY_URI + "/" + "Drunk";
> +
> + public static final String SCOPE_USER_URI = ONTOLOGY_URI + "/" + "User";
> +
> + public static final String SCOPE1_URI = ONTOLOGY_URI + "/" + "Pippo%20Baudo";
> +
> + public static final String SCOPE2_URI = ONTOLOGY_URI + "/" + "TestScope2";
> +
> + private static final Logger log = LoggerFactory.getLogger(ScopeTest.class);
> +
> + @Test
> + public void testGetScopes() throws ClientProtocolException, IOException {
> + RequestExecutor request;
> +
> + // 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>\n] .");
> +
> + log.debug("Request: "+ONTOLOGY_URI+"\n"+request.getContent());
> +
> + }
> +
> + @Test
> + public void testRemoval() throws Exception {
> +
> + executor.execute(
> + builder.buildOtherRequest(
> + new HttpPut(
> + builder.buildUrl(SCOPE_DRUNK_URI+"?corereg=" + encodeURI(REG_TEST_URI))))
> + );
> +
> + executor.execute(
> + builder.buildOtherRequest(
> + new HttpDelete(
> + builder.buildUrl(SCOPE_DRUNK_URI+"?ontology=" + encodeURI(ONT_WINE_URI))
> + )
> + )
> + );
> + }
> +
> + @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) +
> + "®istry=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.
> + log.debug("Request: "+ONTOLOGY_URI);
> + RequestExecutor resActive = executor.execute(
> + builder.buildGetRequest(ONTOLOGY_URI)
> + );
> + log.debug(resActive.getContent());
> + log.info("Request: "+ONTOLOGY_URI +" ... DONE");
> +
> + log.debug("Request: "+ONTOLOGY_URI+"?with-inactive=true");
> + RequestExecutor resAllScopes = executor.execute(
> + builder.buildGetRequest(ONTOLOGY_URI+"?with-inactive=true")
> + );
> + log.debug(resAllScopes.getContent());
> + log.info("Request: "+ONTOLOGY_URI+"?with-inactive=true"+" ... DONE");
> +
> + // Put a simple, inactive scope.
> + log.debug("Request: "+SCOPE_USER_URI+"?coreont=" + ONT_FOAF_URI);
> + 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")
> + ).assertContentContains(SCOPE_USER_URI);
> +
> + // Check that it is not in the list of active scopes.
> + executor.execute(
> + builder.buildGetRequest(SCOPE_USER_URI)
> + ).assertContentContains(SCOPE_USER_URI);
> +
> +
> + // Now create a scope that is active on startup.
> + log.debug("Request: "+SCOPE_BIZ_URI+"?activate=true&coreont=" + ONT_PIZZA_URI);
> + 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)
> + ).assertContentContains(SCOPE_BIZ_URI);
> +
> + executor.execute(
> + builder.buildGetRequest(ONTOLOGY_URI+"?with-inactive=true")
> + ).assertContentContains(SCOPE_BIZ_URI);*/
> +
> + //log.info(executor.execute(builder.buildGetRequest(ONTOLOGY_URI)).getContent());
> +
> + //log.info(executor.execute(builder.buildGetRequest(ONTOLOGY_URI+"?with-inactive=true")).getContent());
> +
> + }
> +
> +
> + 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();
> + }
> +
> + 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;
> + }
> +
> +}
>
> Added: 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=1140324&view=auto
> ==============================================================================
> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java (added)
> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java Mon Jun 27 21:17:10 2011
> @@ -0,0 +1,29 @@
> +package org.apache.stanbol.ontologymanager.web.it;
> +
> +import static org.junit.Assert.assertTrue;
> +
> +import java.io.IOException;
> +
> +import org.junit.Test;
> +
> +import org.apache.http.client.ClientProtocolException;
> +
> +import org.apache.stanbol.commons.web.base.format.KRFormat;
> +
> +public class SessionTest extends OntonetTestBase{
> +
> + public static final String ROOT_URI = "/ontonet";
> +
> + public static final String SESSION_URI = ROOT_URI + "/session";
> +
> + @Test
> + public void testSessionCreation() throws ClientProtocolException, IOException {
> +
> + /*executor.execute(
> + builder.buildPostRequest(SESSION_URI)
> + .withHeader("Accept",KRFormat.RDF_XML)
> + ).assertStatus(200);*/
> +
> + assertTrue(true);
> + }
> +}
>
> Modified: incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml
> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml?rev=1140324&r1=1140323&r2=1140324&view=diff
> ==============================================================================
> --- incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml (original)
> +++ incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml Mon Jun 27 21:17:10 2011
> @@ -473,6 +473,25 @@
> <version>0.9-SNAPSHOT</version>
> </bundle>
> </startLevel>
> +
> + <!-- KReS -->
> + <startLevel level="22">
> + <bundle>
> + <groupId>org.apache.stanbol</groupId>
> + <artifactId>org.apache.stanbol.owl</artifactId>
> + <version>0.9-SNAPSHOT</version>
> + </bundle>
> + <bundle>
> + <groupId>org.apache.stanbol</groupId>
> + <artifactId>org.apache.stanbol.ontologymanager.ontonet</artifactId>
> + <version>0.9-SNAPSHOT</version>
> + </bundle>
> + <bundle>
> + <groupId>org.apache.stanbol</groupId>
> + <artifactId>org.apache.stanbol.ontologymanager.web</artifactId>
> + <version>0.9-SNAPSHOT</version>
> + </bundle>
> + </startLevel>
>
> <!-- Persistence Store Bundles
> <startLevel level="22">
>
> Modified: incubator/stanbol/trunk/ontologymanager/web/pom.xml
> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/web/pom.xml?rev=1140324&r1=1140323&r2=1140324&view=diff
> ==============================================================================
> --- incubator/stanbol/trunk/ontologymanager/web/pom.xml (original)
> +++ incubator/stanbol/trunk/ontologymanager/web/pom.xml Mon Jun 27 21:17:10 2011
> @@ -41,21 +41,6 @@
> <url>http://incubator.apache.org/stanbol/</url>
> </scm>
>
> -
> - <properties>
> - <!-- Set this to run the server on a specific port -->
> - <http.port></http.port>
> -
> - <!-- Set this to run tests against an existing server instance -->
> - <test.server.url></test.server.url>
> -
> - <!-- Options for the VM that executes our runnable jar -->
> - <jar.executor.vm.options>-Xmx512m -Dorg.apache.stanbol.offline.mode=true</jar.executor.vm.options>
> -
> - <!-- Set this to true to keep the runnable jar running - useful to debug tests -->
> - <keepJarRunning>false</keepJarRunning>
> - </properties>
> -
> <build>
> <!-- make it an OSGi bundle -->
> <plugins>
> @@ -83,73 +68,10 @@
> </instructions>
> </configuration>
> </plugin>
> - <plugin>
> - <groupId>org.apache.maven.plugins</groupId>
> - <artifactId>maven-dependency-plugin</artifactId>
> - <executions>
> - <execution>
> - <id>copy-runnable-jar</id>
> - <goals>
> - <goal>copy-dependencies</goal>
> - </goals>
> - <phase>process-resources</phase>
> - <configuration>
> - <includeArtifactIds>org.apache.stanbol.launchers.full</includeArtifactIds>
> - <excludeTransitive>true</excludeTransitive>
> - <overWriteReleases>false</overWriteReleases>
> - <overWriteSnapshots>false</overWriteSnapshots>
> - </configuration>
> - </execution>
> - </executions>
> - </plugin>
> - <plugin>
> - <!-- Find free ports to run our server -->
> - <groupId>org.codehaus.mojo</groupId>
> - <artifactId>build-helper-maven-plugin</artifactId>
> - <executions>
> - <execution>
> - <id>reserve-server-port</id>
> - <goals>
> - <goal>reserve-network-port</goal>
> - </goals>
> - <phase>process-resources</phase>
> - <configuration>
> - <portNames>
> - <portName>http.port</portName>
> - </portNames>
> - </configuration>
> - </execution>
> - </executions>
> - </plugin>
> - <plugin>
> - <groupId>org.apache.maven.plugins</groupId>
> - <artifactId>maven-surefire-plugin</artifactId>
> - <configuration>
> - <systemPropertyVariables>
> - <test.server.url>${test.server.url}</test.server.url>
> - <jar.executor.server.port>${http.port}</jar.executor.server.port>
> - <jar.executor.vm.options>${jar.executor.vm.options}</jar.executor.vm.options>
> - <jar.executor.jar.folder>${project.basedir}/target/dependency</jar.executor.jar.folder>
> - <jar.executor.jar.name.regexp>org.apache.stanbol.*full.*jar$</jar.executor.jar.name.regexp>
> - <jar.executor.workingdirectory>${project.build.directory}/launchdir</jar.executor.workingdirectory>
> - <keepJarRunning>${keepJarRunning}</keepJarRunning>
> - <server.ready.timeout.seconds>180</server.ready.timeout.seconds>
> - <server.ready.path.1>/:stanbol.css</server.ready.path.1>
> - <server.ready.path.2>/engines:There are currently</server.ready.path.2>
> - <server.ready.path.3>/contenthub:Recently uploaded Content Items</server.ready.path.3>
> - </systemPropertyVariables>
> - </configuration>
> - </plugin>
> </plugins>
> </build>
>
> <dependencies>
> - <dependency>
> - <groupId>org.apache.stanbol</groupId>
> - <artifactId>org.apache.stanbol.launchers.full</artifactId>
> - <version>0.9-SNAPSHOT</version>
> - <scope>provided</scope>
> - </dependency>
> <!-- dependencies on other IKS modules -->
> <dependency>
> <groupId>org.apache.clerezza</groupId>
> @@ -300,7 +222,7 @@
> </dependency>
>
> <!-- Stanbol deps -->
> - <dependency>
> + <dependency>
> <groupId>org.apache.stanbol</groupId>
> <artifactId>org.apache.stanbol.commons.web.base</artifactId>
> <version>${stanbol-version}</version>
> @@ -338,18 +260,6 @@
> <artifactId>junit</artifactId>
> <scope>test</scope>
> </dependency>
> - <dependency>
> - <groupId>org.apache.stanbol</groupId>
> - <artifactId>org.apache.stanbol.commons.testing.jarexec</artifactId>
> - <version>${stanbol-version}</version>
> - <scope>test</scope>
> - </dependency>
> - <dependency>
> - <groupId>org.apache.stanbol</groupId>
> - <artifactId>org.apache.stanbol.commons.testing.stanbol</artifactId>
> - <version>${stanbol-version}</version>
> - <scope>test</scope>
> - </dependency>
> </dependencies>
>
> <repositories>
>
> Modified: incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java
> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java?rev=1140324&r1=1140323&r2=1140324&view=diff
> ==============================================================================
> --- incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java (original)
> +++ incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java Mon Jun 27 21:17:10 2011
> @@ -19,6 +19,7 @@ import javax.ws.rs.core.Response;
> import javax.ws.rs.core.UriInfo;
>
> import org.apache.clerezza.rdf.core.access.TcManager;
> +import org.apache.stanbol.commons.web.base.ContextHelper;
> import org.apache.stanbol.commons.web.base.format.KRFormat;
> import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
> import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
> @@ -54,7 +55,9 @@ public class GraphsResource extends Base
> storage = (ClerezzaOntologyStorage) (servletContext.getAttribute(ClerezzaOntologyStorage.class
> .getName()));
> tcManager = (TcManager) servletContext.getAttribute(TcManager.class.getName());
> - onManager = (ONManager) (servletContext.getAttribute(ONManager.class.getName()));
> +
> + onManager = (ONManager) ContextHelper.getServiceFromContext(ONManager.class, servletContext);
> + //onManager = (ONManager) (servletContext.getAttribute(ONManager.class.getName()));
> if (onManager == null) {
> throw new IllegalStateException("OntologyStorage missing in ServletContext");
> } else {
>
>
>
--
Fabian
Re: svn commit: r1140324 - in /incubator/stanbol/trunk:
integration-tests/ integration-tests/src/test/java/org/apache/stanbol/ontologymanager/
integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/ integration-tests/src/test/java/org
Posted by Fabian Christ <ch...@googlemail.com>.
Hi,
okay great! You should just add another server.ready.path to the
integration-tests POM for ontonet. That should be sufficient to ensure
that ontonet is up before test are executed.
Best,
- Fabian
2011/6/28 Alberto Musetti <mu...@cs.unibo.it>:
> Hi,
>
>> 2) Instead of using the server.ready.path feature introduced by
>> StanbolTestBase there is now a new class OntonetTestBase with a
>> function checkEnginesReady() that tries to do the same. The existing
>> server.ready.path in the pom.xml were deactivated (commented out).
>>
>> IMO this is not the way the integration-test should be implemented.
>
> Ok, I'm sorry for the problem!
> I have built the ontologymanager integration test similar to enhancer.it.
> Now I align ontologymanager.it to StanbolTestBase
>
> thanks!
> Alberto
>
>>
>> Best,
>> - Fabian
>>
>> 2011/6/27 <en...@apache.org>:
>>> Author: enridaga
>>> Date: Mon Jun 27 21:17:10 2011
>>> New Revision: 1140324
>>>
>>> URL: http://svn.apache.org/viewvc?rev=1140324&view=rev
>>> Log:
>>> Committed patch submitted at STANBOL-177
>>> * Moving ontologymanager/web tests to integration-tests
>>> * Added ontonet and web modules to full launcher
>>>
>>> Added:
>>> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/
>>> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/
>>> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/
>>> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java
>>> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java
>>> 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
>>> Removed:
>>> incubator/stanbol/trunk/ontologymanager/web/src/test/java/org/apache/stanbol/ontologymanager/web/JettyServerTest.java
>>> Modified:
>>> incubator/stanbol/trunk/integration-tests/pom.xml
>>> incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml
>>> incubator/stanbol/trunk/ontologymanager/web/pom.xml
>>> incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java
>>>
>>> Modified: incubator/stanbol/trunk/integration-tests/pom.xml
>>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/pom.xml?rev=1140324&r1=1140323&r2=1140324&view=diff
>>> ==============================================================================
>>> --- incubator/stanbol/trunk/integration-tests/pom.xml (original)
>>> +++ incubator/stanbol/trunk/integration-tests/pom.xml Mon Jun 27 21:17:10 2011
>>> @@ -46,6 +46,12 @@
>>> <version>0.9-SNAPSHOT</version>
>>> <scope>test</scope>
>>> </dependency>
>>> + <dependency>
>>> + <groupId>org.apache.stanbol</groupId>
>>> + <artifactId>org.apache.stanbol.commons.web.base</artifactId>
>>> + <version>0.9-SNAPSHOT</version>
>>> + <scope>test</scope>
>>> + </dependency>
>>> <dependency>
>>> <groupId>org.apache.stanbol</groupId>
>>> <artifactId>org.apache.stanbol.commons.testing.http</artifactId>
>>> @@ -130,9 +136,9 @@
>>> <keepJarRunning>${keepJarRunning}</keepJarRunning>
>>> <server.ready.timeout.seconds>180</server.ready.timeout.seconds>
>>> <server.ready.path.1>/:stanbol.css</server.ready.path.1>
>>> - <server.ready.path.2>/engines:There are currently</server.ready.path.2>
>>> + <!--<server.ready.path.2>/engines:There are currently</server.ready.path.2>
>>> <server.ready.path.3>/contenthub:Recently uploaded Content Items</server.ready.path.3>
>>> - <server.ready.path.4>/factstore:The FactStore implements a store</server.ready.path.4>
>>> + <server.ready.path.4>/factstore:The FactStore implements a store</server.ready.path.4>-->
>>> </systemPropertyVariables>
>>> </configuration>
>>> </plugin>
>>>
>>> Added: incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java
>>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java?rev=1140324&view=auto
>>> ==============================================================================
>>> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java (added)
>>> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java Mon Jun 27 21:17:10 2011
>>> @@ -0,0 +1,31 @@
>>> +
>>> +package org.apache.stanbol.ontologymanager.web.it;
>>> +
>>> +import org.apache.stanbol.commons.testing.stanbol.StanbolTestBase;
>>> +import org.junit.Test;
>>> +
>>> +/**
>>> + * Test the ontonet homepage and demonstrate the test classes.
>>> + *
>>> + * @author alberto musetti
>>> + */
>>> +
>>> +public class HomepageTest extends StanbolTestBase {
>>> +
>>> + @Test
>>> + public void testHomepageExamples() throws Exception {
>>> +
>>> + executor.execute(
>>> + builder.buildGetRequest("/ontonet")
>>> + .withHeader("Accept", "text/html")
>>> + )
>>> + .assertStatus(200)
>>> + .assertContentType("text/html")
>>> + .assertContentContains(
>>> + "/static/home/style/stanbol.css",
>>> + "The RESTful Semantic Engine")
>>> + .assertContentRegexp(
>>> + "stylesheet.*stanbol.css",
>>> + "<title.*[Ss]tanbol");
>>> + }
>>> +}
>>> \ No newline at end of file
>>>
>>> Added: incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java
>>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java?rev=1140324&view=auto
>>> ==============================================================================
>>> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java (added)
>>> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java Mon Jun 27 21:17:10 2011
>>> @@ -0,0 +1,74 @@
>>> +package org.apache.stanbol.ontologymanager.web.it;
>>> +
>>> +import static org.junit.Assert.fail;
>>> +
>>> +import org.slf4j.Logger;
>>> +import org.slf4j.LoggerFactory;
>>> +
>>> +import org.apache.stanbol.commons.testing.http.RetryLoop;
>>> +import org.apache.stanbol.commons.testing.stanbol.StanbolTestBase;
>>> +import org.junit.Before;
>>> +
>>> +/**
>>> + * Inherit from this to wait for all to be up before running tests.
>>> + */
>>> +public class OntonetTestBase extends StanbolTestBase {
>>> +
>>> + private final Logger log = LoggerFactory.getLogger(getClass());
>>> +
>>> + // TODO configurable via system properties??
>>> + public static final int ENGINES_TIMEOUT_SECONDS = 60;
>>> + public static final int WAIT_BETWEEN_TRIES_MSEC = 1000;
>>> +
>>> + static boolean enginesReady;
>>> + static boolean timedOut;
>>> +
>>> + @Before
>>> + public void checkEnginesReady() throws Exception {
>>> +
>>> + // Check only once per test run
>>> + if(enginesReady) {
>>> + return;
>>> + }
>>> +
>>> + // If we timed out previously, don't waste time checking again
>>> + if(timedOut) {
>>> + fail("Timeout in previous check of ontonet engine, cannot run tests");
>>> + }
>>> +
>>> + final RetryLoop.Condition c = new RetryLoop.Condition() {
>>> +
>>> + @Override
>>> + public boolean isTrue() throws Exception {
>>> + executor.execute(
>>> + builder.buildGetRequest("/ontonet")
>>> + .withHeader("Accept", "text/html")
>>> + )
>>> + .assertStatus(200)
>>> + .assertContentType("text/html");
>>> +
>>> + log.info("Ontonet checked, engine is ready.");
>>> + return true;
>>> + }
>>> +
>>> + @Override
>>> + public String getDescription() {
>>> + return "Checking that Ontonet engine is ready";
>>> + }
>>> + };
>>> +
>>> + new RetryLoop(c, ENGINES_TIMEOUT_SECONDS, WAIT_BETWEEN_TRIES_MSEC) {
>>> + @Override
>>> + protected void reportException(Throwable t) {
>>> + log.info("Exception in RetryLoop, will retry for up to "
>>> + + getRemainingTimeSeconds() + " seconds: " + t);
>>> + }
>>> +
>>> + protected void onTimeout() {
>>> + timedOut = true;
>>> + }
>>> + };
>>> +
>>> + enginesReady = true;
>>> + }
>>> +}
>>>
>>> Added: 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=1140324&view=auto
>>> ==============================================================================
>>> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java (added)
>>> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java Mon Jun 27 21:17:10 2011
>>> @@ -0,0 +1,205 @@
>>> +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.web.base.format.KRFormat;
>>> +
>>> +
>>> +public class ScopeTest extends OntonetTestBase{
>>> +
>>> + public static final String ROOT_URI = "/ontonet";
>>> +
>>> + public static final String ONTOLOGY_URI = ROOT_URI + "/ontology";
>>> +
>>> + public 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";
>>> +
>>> + public 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";
>>> +
>>> + public static final String SCOPE_BIZ_URI = ONTOLOGY_URI + "/" + "Biz";
>>> +
>>> + public static final String SCOPE_DRUNK_URI = ONTOLOGY_URI + "/" + "Drunk";
>>> +
>>> + public static final String SCOPE_USER_URI = ONTOLOGY_URI + "/" + "User";
>>> +
>>> + public static final String SCOPE1_URI = ONTOLOGY_URI + "/" + "Pippo%20Baudo";
>>> +
>>> + public static final String SCOPE2_URI = ONTOLOGY_URI + "/" + "TestScope2";
>>> +
>>> + private static final Logger log = LoggerFactory.getLogger(ScopeTest.class);
>>> +
>>> + @Test
>>> + public void testGetScopes() throws ClientProtocolException, IOException {
>>> + RequestExecutor request;
>>> +
>>> + // 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>\n] .");
>>> +
>>> + log.debug("Request: "+ONTOLOGY_URI+"\n"+request.getContent());
>>> +
>>> + }
>>> +
>>> + @Test
>>> + public void testRemoval() throws Exception {
>>> +
>>> + executor.execute(
>>> + builder.buildOtherRequest(
>>> + new HttpPut(
>>> + builder.buildUrl(SCOPE_DRUNK_URI+"?corereg=" + encodeURI(REG_TEST_URI))))
>>> + );
>>> +
>>> + executor.execute(
>>> + builder.buildOtherRequest(
>>> + new HttpDelete(
>>> + builder.buildUrl(SCOPE_DRUNK_URI+"?ontology=" + encodeURI(ONT_WINE_URI))
>>> + )
>>> + )
>>> + );
>>> + }
>>> +
>>> + @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) +
>>> + "®istry=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.
>>> + log.debug("Request: "+ONTOLOGY_URI);
>>> + RequestExecutor resActive = executor.execute(
>>> + builder.buildGetRequest(ONTOLOGY_URI)
>>> + );
>>> + log.debug(resActive.getContent());
>>> + log.info("Request: "+ONTOLOGY_URI +" ... DONE");
>>> +
>>> + log.debug("Request: "+ONTOLOGY_URI+"?with-inactive=true");
>>> + RequestExecutor resAllScopes = executor.execute(
>>> + builder.buildGetRequest(ONTOLOGY_URI+"?with-inactive=true")
>>> + );
>>> + log.debug(resAllScopes.getContent());
>>> + log.info("Request: "+ONTOLOGY_URI+"?with-inactive=true"+" ... DONE");
>>> +
>>> + // Put a simple, inactive scope.
>>> + log.debug("Request: "+SCOPE_USER_URI+"?coreont=" + ONT_FOAF_URI);
>>> + 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")
>>> + ).assertContentContains(SCOPE_USER_URI);
>>> +
>>> + // Check that it is not in the list of active scopes.
>>> + executor.execute(
>>> + builder.buildGetRequest(SCOPE_USER_URI)
>>> + ).assertContentContains(SCOPE_USER_URI);
>>> +
>>> +
>>> + // Now create a scope that is active on startup.
>>> + log.debug("Request: "+SCOPE_BIZ_URI+"?activate=true&coreont=" + ONT_PIZZA_URI);
>>> + 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)
>>> + ).assertContentContains(SCOPE_BIZ_URI);
>>> +
>>> + executor.execute(
>>> + builder.buildGetRequest(ONTOLOGY_URI+"?with-inactive=true")
>>> + ).assertContentContains(SCOPE_BIZ_URI);*/
>>> +
>>> + //log.info(executor.execute(builder.buildGetRequest(ONTOLOGY_URI)).getContent());
>>> +
>>> + //log.info(executor.execute(builder.buildGetRequest(ONTOLOGY_URI+"?with-inactive=true")).getContent());
>>> +
>>> + }
>>> +
>>> +
>>> + 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();
>>> + }
>>> +
>>> + 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;
>>> + }
>>> +
>>> +}
>>>
>>> Added: 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=1140324&view=auto
>>> ==============================================================================
>>> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java (added)
>>> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java Mon Jun 27 21:17:10 2011
>>> @@ -0,0 +1,29 @@
>>> +package org.apache.stanbol.ontologymanager.web.it;
>>> +
>>> +import static org.junit.Assert.assertTrue;
>>> +
>>> +import java.io.IOException;
>>> +
>>> +import org.junit.Test;
>>> +
>>> +import org.apache.http.client.ClientProtocolException;
>>> +
>>> +import org.apache.stanbol.commons.web.base.format.KRFormat;
>>> +
>>> +public class SessionTest extends OntonetTestBase{
>>> +
>>> + public static final String ROOT_URI = "/ontonet";
>>> +
>>> + public static final String SESSION_URI = ROOT_URI + "/session";
>>> +
>>> + @Test
>>> + public void testSessionCreation() throws ClientProtocolException, IOException {
>>> +
>>> + /*executor.execute(
>>> + builder.buildPostRequest(SESSION_URI)
>>> + .withHeader("Accept",KRFormat.RDF_XML)
>>> + ).assertStatus(200);*/
>>> +
>>> + assertTrue(true);
>>> + }
>>> +}
>>>
>>> Modified: incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml
>>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml?rev=1140324&r1=1140323&r2=1140324&view=diff
>>> ==============================================================================
>>> --- incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml (original)
>>> +++ incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml Mon Jun 27 21:17:10 2011
>>> @@ -473,6 +473,25 @@
>>> <version>0.9-SNAPSHOT</version>
>>> </bundle>
>>> </startLevel>
>>> +
>>> + <!-- KReS -->
>>> + <startLevel level="22">
>>> + <bundle>
>>> + <groupId>org.apache.stanbol</groupId>
>>> + <artifactId>org.apache.stanbol.owl</artifactId>
>>> + <version>0.9-SNAPSHOT</version>
>>> + </bundle>
>>> + <bundle>
>>> + <groupId>org.apache.stanbol</groupId>
>>> + <artifactId>org.apache.stanbol.ontologymanager.ontonet</artifactId>
>>> + <version>0.9-SNAPSHOT</version>
>>> + </bundle>
>>> + <bundle>
>>> + <groupId>org.apache.stanbol</groupId>
>>> + <artifactId>org.apache.stanbol.ontologymanager.web</artifactId>
>>> + <version>0.9-SNAPSHOT</version>
>>> + </bundle>
>>> + </startLevel>
>>>
>>> <!-- Persistence Store Bundles
>>> <startLevel level="22">
>>>
>>> Modified: incubator/stanbol/trunk/ontologymanager/web/pom.xml
>>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/web/pom.xml?rev=1140324&r1=1140323&r2=1140324&view=diff
>>> ==============================================================================
>>> --- incubator/stanbol/trunk/ontologymanager/web/pom.xml (original)
>>> +++ incubator/stanbol/trunk/ontologymanager/web/pom.xml Mon Jun 27 21:17:10 2011
>>> @@ -41,21 +41,6 @@
>>> <url>http://incubator.apache.org/stanbol/</url>
>>> </scm>
>>>
>>> -
>>> - <properties>
>>> - <!-- Set this to run the server on a specific port -->
>>> - <http.port></http.port>
>>> -
>>> - <!-- Set this to run tests against an existing server instance -->
>>> - <test.server.url></test.server.url>
>>> -
>>> - <!-- Options for the VM that executes our runnable jar -->
>>> - <jar.executor.vm.options>-Xmx512m -Dorg.apache.stanbol.offline.mode=true</jar.executor.vm.options>
>>> -
>>> - <!-- Set this to true to keep the runnable jar running - useful to debug tests -->
>>> - <keepJarRunning>false</keepJarRunning>
>>> - </properties>
>>> -
>>> <build>
>>> <!-- make it an OSGi bundle -->
>>> <plugins>
>>> @@ -83,73 +68,10 @@
>>> </instructions>
>>> </configuration>
>>> </plugin>
>>> - <plugin>
>>> - <groupId>org.apache.maven.plugins</groupId>
>>> - <artifactId>maven-dependency-plugin</artifactId>
>>> - <executions>
>>> - <execution>
>>> - <id>copy-runnable-jar</id>
>>> - <goals>
>>> - <goal>copy-dependencies</goal>
>>> - </goals>
>>> - <phase>process-resources</phase>
>>> - <configuration>
>>> - <includeArtifactIds>org.apache.stanbol.launchers.full</includeArtifactIds>
>>> - <excludeTransitive>true</excludeTransitive>
>>> - <overWriteReleases>false</overWriteReleases>
>>> - <overWriteSnapshots>false</overWriteSnapshots>
>>> - </configuration>
>>> - </execution>
>>> - </executions>
>>> - </plugin>
>>> - <plugin>
>>> - <!-- Find free ports to run our server -->
>>> - <groupId>org.codehaus.mojo</groupId>
>>> - <artifactId>build-helper-maven-plugin</artifactId>
>>> - <executions>
>>> - <execution>
>>> - <id>reserve-server-port</id>
>>> - <goals>
>>> - <goal>reserve-network-port</goal>
>>> - </goals>
>>> - <phase>process-resources</phase>
>>> - <configuration>
>>> - <portNames>
>>> - <portName>http.port</portName>
>>> - </portNames>
>>> - </configuration>
>>> - </execution>
>>> - </executions>
>>> - </plugin>
>>> - <plugin>
>>> - <groupId>org.apache.maven.plugins</groupId>
>>> - <artifactId>maven-surefire-plugin</artifactId>
>>> - <configuration>
>>> - <systemPropertyVariables>
>>> - <test.server.url>${test.server.url}</test.server.url>
>>> - <jar.executor.server.port>${http.port}</jar.executor.server.port>
>>> - <jar.executor.vm.options>${jar.executor.vm.options}</jar.executor.vm.options>
>>> - <jar.executor.jar.folder>${project.basedir}/target/dependency</jar.executor.jar.folder>
>>> - <jar.executor.jar.name.regexp>org.apache.stanbol.*full.*jar$</jar.executor.jar.name.regexp>
>>> - <jar.executor.workingdirectory>${project.build.directory}/launchdir</jar.executor.workingdirectory>
>>> - <keepJarRunning>${keepJarRunning}</keepJarRunning>
>>> - <server.ready.timeout.seconds>180</server.ready.timeout.seconds>
>>> - <server.ready.path.1>/:stanbol.css</server.ready.path.1>
>>> - <server.ready.path.2>/engines:There are currently</server.ready.path.2>
>>> - <server.ready.path.3>/contenthub:Recently uploaded Content Items</server.ready.path.3>
>>> - </systemPropertyVariables>
>>> - </configuration>
>>> - </plugin>
>>> </plugins>
>>> </build>
>>>
>>> <dependencies>
>>> - <dependency>
>>> - <groupId>org.apache.stanbol</groupId>
>>> - <artifactId>org.apache.stanbol.launchers.full</artifactId>
>>> - <version>0.9-SNAPSHOT</version>
>>> - <scope>provided</scope>
>>> - </dependency>
>>> <!-- dependencies on other IKS modules -->
>>> <dependency>
>>> <groupId>org.apache.clerezza</groupId>
>>> @@ -300,7 +222,7 @@
>>> </dependency>
>>>
>>> <!-- Stanbol deps -->
>>> - <dependency>
>>> + <dependency>
>>> <groupId>org.apache.stanbol</groupId>
>>> <artifactId>org.apache.stanbol.commons.web.base</artifactId>
>>> <version>${stanbol-version}</version>
>>> @@ -338,18 +260,6 @@
>>> <artifactId>junit</artifactId>
>>> <scope>test</scope>
>>> </dependency>
>>> - <dependency>
>>> - <groupId>org.apache.stanbol</groupId>
>>> - <artifactId>org.apache.stanbol.commons.testing.jarexec</artifactId>
>>> - <version>${stanbol-version}</version>
>>> - <scope>test</scope>
>>> - </dependency>
>>> - <dependency>
>>> - <groupId>org.apache.stanbol</groupId>
>>> - <artifactId>org.apache.stanbol.commons.testing.stanbol</artifactId>
>>> - <version>${stanbol-version}</version>
>>> - <scope>test</scope>
>>> - </dependency>
>>> </dependencies>
>>>
>>> <repositories>
>>>
>>> Modified: incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java
>>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java?rev=1140324&r1=1140323&r2=1140324&view=diff
>>> ==============================================================================
>>> --- incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java (original)
>>> +++ incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java Mon Jun 27 21:17:10 2011
>>> @@ -19,6 +19,7 @@ import javax.ws.rs.core.Response;
>>> import javax.ws.rs.core.UriInfo;
>>>
>>> import org.apache.clerezza.rdf.core.access.TcManager;
>>> +import org.apache.stanbol.commons.web.base.ContextHelper;
>>> import org.apache.stanbol.commons.web.base.format.KRFormat;
>>> import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
>>> import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
>>> @@ -54,7 +55,9 @@ public class GraphsResource extends Base
>>> storage = (ClerezzaOntologyStorage) (servletContext.getAttribute(ClerezzaOntologyStorage.class
>>> .getName()));
>>> tcManager = (TcManager) servletContext.getAttribute(TcManager.class.getName());
>>> - onManager = (ONManager) (servletContext.getAttribute(ONManager.class.getName()));
>>> +
>>> + onManager = (ONManager) ContextHelper.getServiceFromContext(ONManager.class, servletContext);
>>> + //onManager = (ONManager) (servletContext.getAttribute(ONManager.class.getName()));
>>> if (onManager == null) {
>>> throw new IllegalStateException("OntologyStorage missing in ServletContext");
>>> } else {
>>>
>>>
>>>
>>
>>
>>
>> --
>> Fabian
>
>
--
Fabian
Re: svn commit: r1140324 - in /incubator/stanbol/trunk: integration-tests/ integration-tests/src/test/java/org/apache/stanbol/ontologymanager/ integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/ integration-tests/src/test/java/org
Posted by Alberto Musetti <mu...@cs.unibo.it>.
Hi,
> 2) Instead of using the server.ready.path feature introduced by
> StanbolTestBase there is now a new class OntonetTestBase with a
> function checkEnginesReady() that tries to do the same. The existing
> server.ready.path in the pom.xml were deactivated (commented out).
>
> IMO this is not the way the integration-test should be implemented.
Ok, I'm sorry for the problem!
I have built the ontologymanager integration test similar to enhancer.it.
Now I align ontologymanager.it to StanbolTestBase
thanks!
Alberto
>
> Best,
> - Fabian
>
> 2011/6/27 <en...@apache.org>:
>> Author: enridaga
>> Date: Mon Jun 27 21:17:10 2011
>> New Revision: 1140324
>>
>> URL: http://svn.apache.org/viewvc?rev=1140324&view=rev
>> Log:
>> Committed patch submitted at STANBOL-177
>> * Moving ontologymanager/web tests to integration-tests
>> * Added ontonet and web modules to full launcher
>>
>> Added:
>> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/
>> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/
>> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/
>> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java
>> incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java
>> 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
>> Removed:
>> incubator/stanbol/trunk/ontologymanager/web/src/test/java/org/apache/stanbol/ontologymanager/web/JettyServerTest.java
>> Modified:
>> incubator/stanbol/trunk/integration-tests/pom.xml
>> incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml
>> incubator/stanbol/trunk/ontologymanager/web/pom.xml
>> incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java
>>
>> Modified: incubator/stanbol/trunk/integration-tests/pom.xml
>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/pom.xml?rev=1140324&r1=1140323&r2=1140324&view=diff
>> ==============================================================================
>> --- incubator/stanbol/trunk/integration-tests/pom.xml (original)
>> +++ incubator/stanbol/trunk/integration-tests/pom.xml Mon Jun 27 21:17:10 2011
>> @@ -46,6 +46,12 @@
>> <version>0.9-SNAPSHOT</version>
>> <scope>test</scope>
>> </dependency>
>> + <dependency>
>> + <groupId>org.apache.stanbol</groupId>
>> + <artifactId>org.apache.stanbol.commons.web.base</artifactId>
>> + <version>0.9-SNAPSHOT</version>
>> + <scope>test</scope>
>> + </dependency>
>> <dependency>
>> <groupId>org.apache.stanbol</groupId>
>> <artifactId>org.apache.stanbol.commons.testing.http</artifactId>
>> @@ -130,9 +136,9 @@
>> <keepJarRunning>${keepJarRunning}</keepJarRunning>
>> <server.ready.timeout.seconds>180</server.ready.timeout.seconds>
>> <server.ready.path.1>/:stanbol.css</server.ready.path.1>
>> - <server.ready.path.2>/engines:There are currently</server.ready.path.2>
>> + <!--<server.ready.path.2>/engines:There are currently</server.ready.path.2>
>> <server.ready.path.3>/contenthub:Recently uploaded Content Items</server.ready.path.3>
>> - <server.ready.path.4>/factstore:The FactStore implements a store</server.ready.path.4>
>> + <server.ready.path.4>/factstore:The FactStore implements a store</server.ready.path.4>-->
>> </systemPropertyVariables>
>> </configuration>
>> </plugin>
>>
>> Added: incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java
>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java?rev=1140324&view=auto
>> ==============================================================================
>> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java (added)
>> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/HomepageTest.java Mon Jun 27 21:17:10 2011
>> @@ -0,0 +1,31 @@
>> +
>> +package org.apache.stanbol.ontologymanager.web.it;
>> +
>> +import org.apache.stanbol.commons.testing.stanbol.StanbolTestBase;
>> +import org.junit.Test;
>> +
>> +/**
>> + * Test the ontonet homepage and demonstrate the test classes.
>> + *
>> + * @author alberto musetti
>> + */
>> +
>> +public class HomepageTest extends StanbolTestBase {
>> +
>> + @Test
>> + public void testHomepageExamples() throws Exception {
>> +
>> + executor.execute(
>> + builder.buildGetRequest("/ontonet")
>> + .withHeader("Accept", "text/html")
>> + )
>> + .assertStatus(200)
>> + .assertContentType("text/html")
>> + .assertContentContains(
>> + "/static/home/style/stanbol.css",
>> + "The RESTful Semantic Engine")
>> + .assertContentRegexp(
>> + "stylesheet.*stanbol.css",
>> + "<title.*[Ss]tanbol");
>> + }
>> +}
>> \ No newline at end of file
>>
>> Added: incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java
>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java?rev=1140324&view=auto
>> ==============================================================================
>> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java (added)
>> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/OntonetTestBase.java Mon Jun 27 21:17:10 2011
>> @@ -0,0 +1,74 @@
>> +package org.apache.stanbol.ontologymanager.web.it;
>> +
>> +import static org.junit.Assert.fail;
>> +
>> +import org.slf4j.Logger;
>> +import org.slf4j.LoggerFactory;
>> +
>> +import org.apache.stanbol.commons.testing.http.RetryLoop;
>> +import org.apache.stanbol.commons.testing.stanbol.StanbolTestBase;
>> +import org.junit.Before;
>> +
>> +/**
>> + * Inherit from this to wait for all to be up before running tests.
>> + */
>> +public class OntonetTestBase extends StanbolTestBase {
>> +
>> + private final Logger log = LoggerFactory.getLogger(getClass());
>> +
>> + // TODO configurable via system properties??
>> + public static final int ENGINES_TIMEOUT_SECONDS = 60;
>> + public static final int WAIT_BETWEEN_TRIES_MSEC = 1000;
>> +
>> + static boolean enginesReady;
>> + static boolean timedOut;
>> +
>> + @Before
>> + public void checkEnginesReady() throws Exception {
>> +
>> + // Check only once per test run
>> + if(enginesReady) {
>> + return;
>> + }
>> +
>> + // If we timed out previously, don't waste time checking again
>> + if(timedOut) {
>> + fail("Timeout in previous check of ontonet engine, cannot run tests");
>> + }
>> +
>> + final RetryLoop.Condition c = new RetryLoop.Condition() {
>> +
>> + @Override
>> + public boolean isTrue() throws Exception {
>> + executor.execute(
>> + builder.buildGetRequest("/ontonet")
>> + .withHeader("Accept", "text/html")
>> + )
>> + .assertStatus(200)
>> + .assertContentType("text/html");
>> +
>> + log.info("Ontonet checked, engine is ready.");
>> + return true;
>> + }
>> +
>> + @Override
>> + public String getDescription() {
>> + return "Checking that Ontonet engine is ready";
>> + }
>> + };
>> +
>> + new RetryLoop(c, ENGINES_TIMEOUT_SECONDS, WAIT_BETWEEN_TRIES_MSEC) {
>> + @Override
>> + protected void reportException(Throwable t) {
>> + log.info("Exception in RetryLoop, will retry for up to "
>> + + getRemainingTimeSeconds() + " seconds: " + t);
>> + }
>> +
>> + protected void onTimeout() {
>> + timedOut = true;
>> + }
>> + };
>> +
>> + enginesReady = true;
>> + }
>> +}
>>
>> Added: 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=1140324&view=auto
>> ==============================================================================
>> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java (added)
>> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/ScopeTest.java Mon Jun 27 21:17:10 2011
>> @@ -0,0 +1,205 @@
>> +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.web.base.format.KRFormat;
>> +
>> +
>> +public class ScopeTest extends OntonetTestBase{
>> +
>> + public static final String ROOT_URI = "/ontonet";
>> +
>> + public static final String ONTOLOGY_URI = ROOT_URI + "/ontology";
>> +
>> + public 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";
>> +
>> + public 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";
>> +
>> + public static final String SCOPE_BIZ_URI = ONTOLOGY_URI + "/" + "Biz";
>> +
>> + public static final String SCOPE_DRUNK_URI = ONTOLOGY_URI + "/" + "Drunk";
>> +
>> + public static final String SCOPE_USER_URI = ONTOLOGY_URI + "/" + "User";
>> +
>> + public static final String SCOPE1_URI = ONTOLOGY_URI + "/" + "Pippo%20Baudo";
>> +
>> + public static final String SCOPE2_URI = ONTOLOGY_URI + "/" + "TestScope2";
>> +
>> + private static final Logger log = LoggerFactory.getLogger(ScopeTest.class);
>> +
>> + @Test
>> + public void testGetScopes() throws ClientProtocolException, IOException {
>> + RequestExecutor request;
>> +
>> + // 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>\n] .");
>> +
>> + log.debug("Request: "+ONTOLOGY_URI+"\n"+request.getContent());
>> +
>> + }
>> +
>> + @Test
>> + public void testRemoval() throws Exception {
>> +
>> + executor.execute(
>> + builder.buildOtherRequest(
>> + new HttpPut(
>> + builder.buildUrl(SCOPE_DRUNK_URI+"?corereg=" + encodeURI(REG_TEST_URI))))
>> + );
>> +
>> + executor.execute(
>> + builder.buildOtherRequest(
>> + new HttpDelete(
>> + builder.buildUrl(SCOPE_DRUNK_URI+"?ontology=" + encodeURI(ONT_WINE_URI))
>> + )
>> + )
>> + );
>> + }
>> +
>> + @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) +
>> + "®istry=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.
>> + log.debug("Request: "+ONTOLOGY_URI);
>> + RequestExecutor resActive = executor.execute(
>> + builder.buildGetRequest(ONTOLOGY_URI)
>> + );
>> + log.debug(resActive.getContent());
>> + log.info("Request: "+ONTOLOGY_URI +" ... DONE");
>> +
>> + log.debug("Request: "+ONTOLOGY_URI+"?with-inactive=true");
>> + RequestExecutor resAllScopes = executor.execute(
>> + builder.buildGetRequest(ONTOLOGY_URI+"?with-inactive=true")
>> + );
>> + log.debug(resAllScopes.getContent());
>> + log.info("Request: "+ONTOLOGY_URI+"?with-inactive=true"+" ... DONE");
>> +
>> + // Put a simple, inactive scope.
>> + log.debug("Request: "+SCOPE_USER_URI+"?coreont=" + ONT_FOAF_URI);
>> + 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")
>> + ).assertContentContains(SCOPE_USER_URI);
>> +
>> + // Check that it is not in the list of active scopes.
>> + executor.execute(
>> + builder.buildGetRequest(SCOPE_USER_URI)
>> + ).assertContentContains(SCOPE_USER_URI);
>> +
>> +
>> + // Now create a scope that is active on startup.
>> + log.debug("Request: "+SCOPE_BIZ_URI+"?activate=true&coreont=" + ONT_PIZZA_URI);
>> + 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)
>> + ).assertContentContains(SCOPE_BIZ_URI);
>> +
>> + executor.execute(
>> + builder.buildGetRequest(ONTOLOGY_URI+"?with-inactive=true")
>> + ).assertContentContains(SCOPE_BIZ_URI);*/
>> +
>> + //log.info(executor.execute(builder.buildGetRequest(ONTOLOGY_URI)).getContent());
>> +
>> + //log.info(executor.execute(builder.buildGetRequest(ONTOLOGY_URI+"?with-inactive=true")).getContent());
>> +
>> + }
>> +
>> +
>> + 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();
>> + }
>> +
>> + 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;
>> + }
>> +
>> +}
>>
>> Added: 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=1140324&view=auto
>> ==============================================================================
>> --- incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java (added)
>> +++ incubator/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/ontologymanager/web/it/SessionTest.java Mon Jun 27 21:17:10 2011
>> @@ -0,0 +1,29 @@
>> +package org.apache.stanbol.ontologymanager.web.it;
>> +
>> +import static org.junit.Assert.assertTrue;
>> +
>> +import java.io.IOException;
>> +
>> +import org.junit.Test;
>> +
>> +import org.apache.http.client.ClientProtocolException;
>> +
>> +import org.apache.stanbol.commons.web.base.format.KRFormat;
>> +
>> +public class SessionTest extends OntonetTestBase{
>> +
>> + public static final String ROOT_URI = "/ontonet";
>> +
>> + public static final String SESSION_URI = ROOT_URI + "/session";
>> +
>> + @Test
>> + public void testSessionCreation() throws ClientProtocolException, IOException {
>> +
>> + /*executor.execute(
>> + builder.buildPostRequest(SESSION_URI)
>> + .withHeader("Accept",KRFormat.RDF_XML)
>> + ).assertStatus(200);*/
>> +
>> + assertTrue(true);
>> + }
>> +}
>>
>> Modified: incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml
>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml?rev=1140324&r1=1140323&r2=1140324&view=diff
>> ==============================================================================
>> --- incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml (original)
>> +++ incubator/stanbol/trunk/launchers/full/src/main/bundles/list.xml Mon Jun 27 21:17:10 2011
>> @@ -473,6 +473,25 @@
>> <version>0.9-SNAPSHOT</version>
>> </bundle>
>> </startLevel>
>> +
>> + <!-- KReS -->
>> + <startLevel level="22">
>> + <bundle>
>> + <groupId>org.apache.stanbol</groupId>
>> + <artifactId>org.apache.stanbol.owl</artifactId>
>> + <version>0.9-SNAPSHOT</version>
>> + </bundle>
>> + <bundle>
>> + <groupId>org.apache.stanbol</groupId>
>> + <artifactId>org.apache.stanbol.ontologymanager.ontonet</artifactId>
>> + <version>0.9-SNAPSHOT</version>
>> + </bundle>
>> + <bundle>
>> + <groupId>org.apache.stanbol</groupId>
>> + <artifactId>org.apache.stanbol.ontologymanager.web</artifactId>
>> + <version>0.9-SNAPSHOT</version>
>> + </bundle>
>> + </startLevel>
>>
>> <!-- Persistence Store Bundles
>> <startLevel level="22">
>>
>> Modified: incubator/stanbol/trunk/ontologymanager/web/pom.xml
>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/web/pom.xml?rev=1140324&r1=1140323&r2=1140324&view=diff
>> ==============================================================================
>> --- incubator/stanbol/trunk/ontologymanager/web/pom.xml (original)
>> +++ incubator/stanbol/trunk/ontologymanager/web/pom.xml Mon Jun 27 21:17:10 2011
>> @@ -41,21 +41,6 @@
>> <url>http://incubator.apache.org/stanbol/</url>
>> </scm>
>>
>> -
>> - <properties>
>> - <!-- Set this to run the server on a specific port -->
>> - <http.port></http.port>
>> -
>> - <!-- Set this to run tests against an existing server instance -->
>> - <test.server.url></test.server.url>
>> -
>> - <!-- Options for the VM that executes our runnable jar -->
>> - <jar.executor.vm.options>-Xmx512m -Dorg.apache.stanbol.offline.mode=true</jar.executor.vm.options>
>> -
>> - <!-- Set this to true to keep the runnable jar running - useful to debug tests -->
>> - <keepJarRunning>false</keepJarRunning>
>> - </properties>
>> -
>> <build>
>> <!-- make it an OSGi bundle -->
>> <plugins>
>> @@ -83,73 +68,10 @@
>> </instructions>
>> </configuration>
>> </plugin>
>> - <plugin>
>> - <groupId>org.apache.maven.plugins</groupId>
>> - <artifactId>maven-dependency-plugin</artifactId>
>> - <executions>
>> - <execution>
>> - <id>copy-runnable-jar</id>
>> - <goals>
>> - <goal>copy-dependencies</goal>
>> - </goals>
>> - <phase>process-resources</phase>
>> - <configuration>
>> - <includeArtifactIds>org.apache.stanbol.launchers.full</includeArtifactIds>
>> - <excludeTransitive>true</excludeTransitive>
>> - <overWriteReleases>false</overWriteReleases>
>> - <overWriteSnapshots>false</overWriteSnapshots>
>> - </configuration>
>> - </execution>
>> - </executions>
>> - </plugin>
>> - <plugin>
>> - <!-- Find free ports to run our server -->
>> - <groupId>org.codehaus.mojo</groupId>
>> - <artifactId>build-helper-maven-plugin</artifactId>
>> - <executions>
>> - <execution>
>> - <id>reserve-server-port</id>
>> - <goals>
>> - <goal>reserve-network-port</goal>
>> - </goals>
>> - <phase>process-resources</phase>
>> - <configuration>
>> - <portNames>
>> - <portName>http.port</portName>
>> - </portNames>
>> - </configuration>
>> - </execution>
>> - </executions>
>> - </plugin>
>> - <plugin>
>> - <groupId>org.apache.maven.plugins</groupId>
>> - <artifactId>maven-surefire-plugin</artifactId>
>> - <configuration>
>> - <systemPropertyVariables>
>> - <test.server.url>${test.server.url}</test.server.url>
>> - <jar.executor.server.port>${http.port}</jar.executor.server.port>
>> - <jar.executor.vm.options>${jar.executor.vm.options}</jar.executor.vm.options>
>> - <jar.executor.jar.folder>${project.basedir}/target/dependency</jar.executor.jar.folder>
>> - <jar.executor.jar.name.regexp>org.apache.stanbol.*full.*jar$</jar.executor.jar.name.regexp>
>> - <jar.executor.workingdirectory>${project.build.directory}/launchdir</jar.executor.workingdirectory>
>> - <keepJarRunning>${keepJarRunning}</keepJarRunning>
>> - <server.ready.timeout.seconds>180</server.ready.timeout.seconds>
>> - <server.ready.path.1>/:stanbol.css</server.ready.path.1>
>> - <server.ready.path.2>/engines:There are currently</server.ready.path.2>
>> - <server.ready.path.3>/contenthub:Recently uploaded Content Items</server.ready.path.3>
>> - </systemPropertyVariables>
>> - </configuration>
>> - </plugin>
>> </plugins>
>> </build>
>>
>> <dependencies>
>> - <dependency>
>> - <groupId>org.apache.stanbol</groupId>
>> - <artifactId>org.apache.stanbol.launchers.full</artifactId>
>> - <version>0.9-SNAPSHOT</version>
>> - <scope>provided</scope>
>> - </dependency>
>> <!-- dependencies on other IKS modules -->
>> <dependency>
>> <groupId>org.apache.clerezza</groupId>
>> @@ -300,7 +222,7 @@
>> </dependency>
>>
>> <!-- Stanbol deps -->
>> - <dependency>
>> + <dependency>
>> <groupId>org.apache.stanbol</groupId>
>> <artifactId>org.apache.stanbol.commons.web.base</artifactId>
>> <version>${stanbol-version}</version>
>> @@ -338,18 +260,6 @@
>> <artifactId>junit</artifactId>
>> <scope>test</scope>
>> </dependency>
>> - <dependency>
>> - <groupId>org.apache.stanbol</groupId>
>> - <artifactId>org.apache.stanbol.commons.testing.jarexec</artifactId>
>> - <version>${stanbol-version}</version>
>> - <scope>test</scope>
>> - </dependency>
>> - <dependency>
>> - <groupId>org.apache.stanbol</groupId>
>> - <artifactId>org.apache.stanbol.commons.testing.stanbol</artifactId>
>> - <version>${stanbol-version}</version>
>> - <scope>test</scope>
>> - </dependency>
>> </dependencies>
>>
>> <repositories>
>>
>> Modified: incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java
>> URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java?rev=1140324&r1=1140323&r2=1140324&view=diff
>> ==============================================================================
>> --- incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java (original)
>> +++ incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/GraphsResource.java Mon Jun 27 21:17:10 2011
>> @@ -19,6 +19,7 @@ import javax.ws.rs.core.Response;
>> import javax.ws.rs.core.UriInfo;
>>
>> import org.apache.clerezza.rdf.core.access.TcManager;
>> +import org.apache.stanbol.commons.web.base.ContextHelper;
>> import org.apache.stanbol.commons.web.base.format.KRFormat;
>> import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
>> import org.apache.stanbol.ontologymanager.ontonet.api.ONManager;
>> @@ -54,7 +55,9 @@ public class GraphsResource extends Base
>> storage = (ClerezzaOntologyStorage) (servletContext.getAttribute(ClerezzaOntologyStorage.class
>> .getName()));
>> tcManager = (TcManager) servletContext.getAttribute(TcManager.class.getName());
>> - onManager = (ONManager) (servletContext.getAttribute(ONManager.class.getName()));
>> +
>> + onManager = (ONManager) ContextHelper.getServiceFromContext(ONManager.class, servletContext);
>> + //onManager = (ONManager) (servletContext.getAttribute(ONManager.class.getName()));
>> if (onManager == null) {
>> throw new IllegalStateException("OntologyStorage missing in ServletContext");
>> } else {
>>
>>
>>
>
>
>
> --
> Fabian