marmotta-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wik...@apache.org
Subject [33/50] [abbrv] marmotta git commit: MARMOTTA-631: added test to reproduce the issue
Date Mon, 02 May 2016 09:50:10 GMT
MARMOTTA-631: added test to reproduce the issue


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/8710b7e2
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/8710b7e2
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/8710b7e2

Branch: refs/heads/MARMOTTA-584
Commit: 8710b7e26934c78fc3c2813f61dc1611b0e90359
Parents: 528b341
Author: Sergio Fernández <wikier@apache.org>
Authored: Thu Mar 3 11:25:32 2016 +0100
Committer: Sergio Fernández <wikier@apache.org>
Committed: Thu Mar 3 11:25:32 2016 +0100

----------------------------------------------------------------------
 .../test/triplestore/ContextServiceTest.java    | 78 ++++++++++++++++++++
 1 file changed, 78 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/8710b7e2/platform/marmotta-core/src/test/java/org/apache/marmotta/platform/core/test/triplestore/ContextServiceTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/test/java/org/apache/marmotta/platform/core/test/triplestore/ContextServiceTest.java
b/platform/marmotta-core/src/test/java/org/apache/marmotta/platform/core/test/triplestore/ContextServiceTest.java
new file mode 100644
index 0000000..eec0d30
--- /dev/null
+++ b/platform/marmotta-core/src/test/java/org/apache/marmotta/platform/core/test/triplestore/ContextServiceTest.java
@@ -0,0 +1,78 @@
+package org.apache.marmotta.platform.core.test.triplestore;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+import com.jayway.restassured.RestAssured;
+import org.apache.marmotta.platform.core.api.config.ConfigurationService;
+import org.apache.marmotta.platform.core.api.importer.ImportService;
+import org.apache.marmotta.platform.core.api.triplestore.ContextService;
+import org.apache.marmotta.platform.core.api.user.UserService;
+import org.apache.marmotta.platform.core.exception.io.MarmottaImportException;
+import org.apache.marmotta.platform.core.test.base.JettyMarmotta;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openrdf.model.URI;
+
+import java.io.InputStream;
+import java.net.URISyntaxException;
+import java.util.List;
+
+/**
+ * Some basic test for context service
+ *
+ * @author Sergio Fernández
+ */
+public class ContextServiceTest {
+
+    private static JettyMarmotta marmotta;
+    private static ConfigurationService configurationService;
+    private static ContextService contextService;
+
+    @BeforeClass
+    public static void setUp() {
+        marmotta = new JettyMarmotta("/marmotta");
+        configurationService = marmotta.getService(ConfigurationService.class);
+        contextService = marmotta.getService(ContextService.class);
+
+        RestAssured.baseURI = "http://localhost";
+        RestAssured.port = marmotta.getPort();
+        RestAssured.basePath = marmotta.getContext();
+    }
+
+    @AfterClass
+    public static void tearDown() {
+        marmotta.shutdown();
+    }
+
+    @Test
+    public void testEmpty() {
+        final List<URI> contexts = contextService.listContexts();
+        Assert.assertEquals(0, contexts.size());
+    }
+
+    @Test
+    public void testMarmotta631() {
+        final List<URI> contexts = contextService.listContexts();
+        Assert.assertTrue(contexts.size() >= 1);
+        Assert.assertTrue(Collections2.transform(contexts, new Function<URI, String>()
{
+            @Override
+            public String apply(URI input) {
+                return input.stringValue();
+            }
+        }).contains(configurationService.getDefaultContext()));
+    }
+
+    @Test
+    public void testMarmotta631AfterImporting() throws URISyntaxException, MarmottaImportException
{
+        final ImportService importService = marmotta.getService(ImportService.class);
+        final InputStream is = ContextServiceTest.class.getResourceAsStream("/org/apache/marmotta/platform/core/test/sesame/demo-data.foaf");
+        importService.importData(is, "application/rdf+xml", marmotta.getService(UserService.class).getAnonymousUser(),
contextService.getDefaultContext());
+
+        final List<URI> contexts = contextService.listContexts();
+        Assert.assertTrue(contexts.size() >= 1);
+        Assert.assertTrue(contexts.contains(contextService.getDefaultContext()));
+    }
+
+}


Mime
View raw message