You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2014/02/04 12:34:24 UTC
git commit: - loader supports now datasets contained in archives (ZIP, tar.gz,
...)
Updated Branches:
refs/heads/develop a7fe31d9b -> 7163de0bc
- loader supports now datasets contained in archives (ZIP, tar.gz, ...)
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/7163de0b
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/7163de0b
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/7163de0b
Branch: refs/heads/develop
Commit: 7163de0bcaf25ca60ba7f3b144287752646d9c35
Parents: a7fe31d
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Tue Feb 4 12:34:19 2014 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Tue Feb 4 12:34:19 2014 +0100
----------------------------------------------------------------------
.../marmotta/loader/api/LoaderOptions.java | 6 +
.../marmotta/loader/core/MarmottaLoader.java | 102 +++++++++++++
.../marmotta/loader/core/test/ArchiveTest.java | 59 ++++++++
.../marmotta/loader/core/test/FilesTest.java | 43 ++++++
.../marmotta/loader/core/test/LoadTest.java | 150 -------------------
.../loader/core/test/LoaderTestBase.java | 139 +++++++++++++++++
.../src/test/resources/demo-data.tar.gz | Bin 0 -> 1405 bytes
.../src/test/resources/demo-data.zip | Bin 0 -> 1457 bytes
8 files changed, 349 insertions(+), 150 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/7163de0b/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/api/LoaderOptions.java
----------------------------------------------------------------------
diff --git a/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/api/LoaderOptions.java b/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/api/LoaderOptions.java
index b8f33cb..389016d 100644
--- a/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/api/LoaderOptions.java
+++ b/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/api/LoaderOptions.java
@@ -47,6 +47,12 @@ public class LoaderOptions {
public static final String DIRS = "loader.dirs";
/**
+ * Paths to archives to import
+ */
+ public static final String ARCHIVES = "loader.archives";
+
+
+ /**
* Enable statistics collection. Configuration value needs to be a boolean.
*/
public static final String STATISTICS_ENABLED = "loader.statistics.enabled";
http://git-wip-us.apache.org/repos/asf/marmotta/blob/7163de0b/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
----------------------------------------------------------------------
diff --git a/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java b/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
index 4ea5f5c..582f508 100644
--- a/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
+++ b/loader/marmotta-loader-core/src/main/java/org/apache/marmotta/loader/core/MarmottaLoader.java
@@ -4,6 +4,13 @@ import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.cli.*;
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveException;
+import org.apache.commons.compress.archivers.ArchiveInputStream;
+import org.apache.commons.compress.archivers.ArchiveStreamFactory;
+import org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.compressors.CompressorException;
import org.apache.commons.compress.compressors.CompressorStreamFactory;
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
@@ -77,6 +84,19 @@ public class MarmottaLoader {
}
}
+ if(configuration.containsKey(LoaderOptions.ARCHIVES)) {
+ for(String archiveName : configuration.getStringArray(LoaderOptions.ARCHIVES)) {
+ File archive = new File(archiveName);
+
+ try {
+ loadArchive(archive, handler, getRDFFormat(configuration.getString(LoaderOptions.FORMAT)));
+ } catch (RDFParseException | IOException | ArchiveException e) {
+ log.warn("error importing directory {}: {}", archive, e.getMessage());
+ }
+ }
+ }
+
+
if(configuration.containsKey(LoaderOptions.FILES)) {
for(String fname : configuration.getStringArray(LoaderOptions.FILES)) {
File f = new File(fname);
@@ -239,6 +259,74 @@ public class MarmottaLoader {
}
}
+
+ public void loadArchive(File archive, LoaderHandler handler, RDFFormat format) throws RDFParseException, IOException, ArchiveException {
+ log.info("loading files in archive {} ...", archive);
+
+ if(archive.exists() && archive.canRead()) {
+ InputStream in;
+
+ String archiveCompression = detectCompression(archive);
+ InputStream fin = new BufferedInputStream(new FileInputStream(archive));
+ if(archiveCompression != null) {
+ if (CompressorStreamFactory.GZIP.equalsIgnoreCase(archiveCompression)) {
+ log.info("auto-detected archive compression: GZIP");
+ in = new GzipCompressorInputStream(fin,true);
+ } else if (CompressorStreamFactory.BZIP2.equalsIgnoreCase(archiveCompression)) {
+ log.info("auto-detected archive compression: BZIP2");
+ in = new BZip2CompressorInputStream(fin, true);
+ } else {
+ in = fin;
+ }
+ } else {
+ in = fin;
+ }
+
+ ArchiveInputStream zipStream = new ArchiveStreamFactory().createArchiveInputStream(new BufferedInputStream(in));
+ logArchiveType(zipStream);
+
+ ArchiveEntry entry;
+ while( (entry = zipStream.getNextEntry()) != null) {
+
+ // detect the file format
+ RDFFormat detectedFormat = RDFFormat.forFileName(entry.getName());
+ if(format == null) {
+ if(detectedFormat != null) {
+ log.info("auto-detected entry format: {}", detectedFormat.getName());
+ format = detectedFormat;
+ } else {
+ throw new RDFParseException("could not detect input format of entry "+ entry.getName());
+ }
+ } else {
+ if(detectedFormat != null && !format.equals(detectedFormat)) {
+ log.warn("user-specified format ({}) overrides auto-detected format ({})", format.getName(), detectedFormat.getName());
+ }
+ }
+
+ load(zipStream,handler,format);
+
+ }
+
+ } else {
+ throw new RDFParseException("could not load files from archive "+archive+": it does not exist or is not readable");
+ }
+
+ }
+
+ private void logArchiveType(ArchiveInputStream stream) {
+ if(log.isInfoEnabled()) {
+ if(stream instanceof ZipArchiveInputStream) {
+ log.info("auto-detected archive format: ZIP");
+ } else if (stream instanceof TarArchiveInputStream) {
+ log.info("auto-detected archive format: TAR");
+ } else if (stream instanceof CpioArchiveInputStream) {
+ log.info("auto-detected archive format: CPIO");
+ } else {
+ log.info("unknown archive format, relying on commons-compress");
+ }
+ }
+ }
+
/**
* Detect the compression format from the filename, or null in case auto-detection failed.
* @param file
@@ -410,6 +498,15 @@ public class MarmottaLoader {
input.addOption(directories);
options.addOptionGroup(input);
+ final Option archives =
+ OptionBuilder.withArgName("archive")
+ .hasArgs(Option.UNLIMITED_VALUES)
+ .withDescription("input archives(s) to load (zip, tar.gz)")
+ .withLongOpt("archive")
+ .create('a');
+ input.addOption(archives);
+ options.addOptionGroup(input);
+
final Option statistics =
OptionBuilder.withArgName("statistics")
@@ -488,6 +585,11 @@ public class MarmottaLoader {
result.setProperty(LoaderOptions.DIRS, Arrays.asList(cmd.getOptionValues('d')));
}
+ if(cmd.hasOption('a')) {
+ result.setProperty(LoaderOptions.ARCHIVES, Arrays.asList(cmd.getOptionValues('a')));
+ }
+
+
if(cmd.hasOption('s')) {
result.setProperty(LoaderOptions.STATISTICS_ENABLED, true);
result.setProperty(LoaderOptions.STATISTICS_GRAPH, cmd.getOptionValue('s'));
http://git-wip-us.apache.org/repos/asf/marmotta/blob/7163de0b/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/ArchiveTest.java
----------------------------------------------------------------------
diff --git a/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/ArchiveTest.java b/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/ArchiveTest.java
new file mode 100644
index 0000000..9e9f9e8
--- /dev/null
+++ b/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/ArchiveTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.marmotta.loader.core.test;
+
+import org.apache.marmotta.loader.api.LoaderOptions;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+@RunWith(Parameterized.class)
+public class ArchiveTest extends LoaderTestBase {
+
+ private static Logger log = LoggerFactory.getLogger(ArchiveTest.class);
+
+ public ArchiveTest(String filename) {
+ super();
+
+ log.info("running test for archive {}", filename);
+
+ cfg.setProperty(LoaderOptions.ARCHIVES, Collections.singletonList(tempDir.toString() + File.separator + filename));
+ }
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> data() {
+ Object[][] data = new Object[][] {
+ { "demo-data.tar.gz"},
+ { "demo-data.zip"}
+ };
+ return Arrays.asList(data);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/7163de0b/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/FilesTest.java
----------------------------------------------------------------------
diff --git a/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/FilesTest.java b/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/FilesTest.java
new file mode 100644
index 0000000..e5dc6dc
--- /dev/null
+++ b/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/FilesTest.java
@@ -0,0 +1,43 @@
+package org.apache.marmotta.loader.core.test;
+
+import org.apache.commons.compress.compressors.CompressorStreamFactory;
+import org.apache.commons.configuration.MapConfiguration;
+import org.apache.marmotta.loader.api.LoaderOptions;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+@RunWith(Parameterized.class)
+public class FilesTest extends LoaderTestBase {
+
+ private static Logger log = LoggerFactory.getLogger(FilesTest.class);
+
+
+ public FilesTest(String compression, String filename) {
+ log.info("running test for file {} (compression: {})", filename, compression);
+
+ cfg = new MapConfiguration(new HashMap<String,Object>());
+ cfg.setProperty(LoaderOptions.FILES, Collections.singletonList(tempDir.toString() + File.separator + filename));
+ cfg.setProperty(LoaderOptions.COMPRESSION, compression);
+ }
+
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> data() {
+ Object[][] data = new Object[][] { { null, "demo-data.rdf"}, { CompressorStreamFactory.GZIP, "demo-data.rdf.gz" }, { CompressorStreamFactory.BZIP2, "demo-data.rdf.bz2" } };
+ return Arrays.asList(data);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/7163de0b/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/LoadTest.java
----------------------------------------------------------------------
diff --git a/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/LoadTest.java b/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/LoadTest.java
deleted file mode 100644
index 71a1204..0000000
--- a/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/LoadTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package org.apache.marmotta.loader.core.test;
-
-import org.apache.commons.compress.compressors.CompressorStreamFactory;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.MapConfiguration;
-import org.apache.commons.io.FileUtils;
-import org.apache.marmotta.loader.api.LoaderHandler;
-import org.apache.marmotta.loader.api.LoaderOptions;
-import org.apache.marmotta.loader.core.MarmottaLoader;
-import org.apache.marmotta.loader.core.test.dummy.DummyLoaderHandler;
-import org.apache.marmotta.loader.wrapper.LoaderHandlerWrapper;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.openrdf.model.Model;
-import org.openrdf.model.URI;
-import org.openrdf.model.impl.URIImpl;
-import org.openrdf.rio.RDFHandlerException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-
-/**
- * Add file description here!
- *
- * @author Sebastian Schaffert (sschaffert@apache.org)
- */
-@RunWith(Parameterized.class)
-public class LoadTest {
-
- private static Logger log = LoggerFactory.getLogger(LoadTest.class);
-
- private static Path tempDir;
-
-
- private String filename;
- private String compression;
-
- private Configuration cfg;
-
- public LoadTest(String compression, String filename) {
- this.filename = filename;
- this.compression = compression;
-
- log.info("running test for file {} (compression: {})", filename, compression);
-
- cfg = new MapConfiguration(new HashMap<String,Object>());
- cfg.setProperty(LoaderOptions.FILES, Collections.singletonList(tempDir.toString() + File.separator + filename));
- cfg.setProperty(LoaderOptions.COMPRESSION, compression);
- }
-
- @BeforeClass
- public static void setup() throws IOException {
- tempDir = Files.createTempDirectory("loader");
-
- log.info("running loader tests from temporary directory {}", tempDir);
-
- for(String filename : new String[] {"demo-data.rdf", "demo-data.rdf.gz", "demo-data.rdf.bz2"}) {
- File data = new File(tempDir.toFile(), filename);
- FileUtils.copyInputStreamToFile(LoadTest.class.getResourceAsStream("/" + filename), data);
- }
- }
-
- @AfterClass
- public static void teardown() throws IOException {
- log.info("cleaning up temporary directory {}", tempDir);
-
- FileUtils.deleteDirectory(tempDir.toFile());
- }
-
- @Parameterized.Parameters
- public static Collection<Object[]> data() {
- Object[][] data = new Object[][] { { null, "demo-data.rdf"}, { CompressorStreamFactory.GZIP, "demo-data.rdf.gz" }, { CompressorStreamFactory.BZIP2, "demo-data.rdf.bz2" } };
- return Arrays.asList(data);
- }
-
-
-
- @Test
- public void testAutoLoad() throws RDFHandlerException {
- log.info("testing automatic loading ...");
-
- MarmottaLoader loader = new MarmottaLoader(cfg);
- DummyLoaderHandler handler = getBase(loader.load());
-
- testData(handler.getModel());
- }
-
- @Test
- public void testStatistics() throws RDFHandlerException {
- log.info("testing statistics loading ...");
-
- cfg.setProperty(LoaderOptions.STATISTICS_ENABLED, true);
- cfg.setProperty(LoaderOptions.STATISTICS_GRAPH, new File(tempDir.toFile(), "stats.png").toString());
-
- MarmottaLoader loader = new MarmottaLoader(cfg);
- DummyLoaderHandler handler = getBase(loader.load());
-
- testData(handler.getModel());
- }
-
- @Test
- public void testContext() throws RDFHandlerException {
- log.info("testing statistics loading ...");
-
- cfg.setProperty(LoaderOptions.CONTEXT, "http://localhost/contexts/mycontext");
-
- MarmottaLoader loader = new MarmottaLoader(cfg);
- DummyLoaderHandler handler = getBase(loader.load());
-
- testData(handler.getModel(), new URIImpl("http://localhost/contexts/mycontext"));
- }
-
-
- private void testData(Model model, URI... contexts) {
- Assert.assertTrue(model.size() > 0);
-
- URI s = new URIImpl("http://localhost:8080/LMF/resource/hans_meier");
- URI p = new URIImpl("http://xmlns.com/foaf/0.1/interest");
- URI o = new URIImpl("http://rdf.freebase.com/ns/en.software_engineering");
-
- Assert.assertTrue(model.contains(s,p,o));
-
- for(URI c : contexts) {
- Assert.assertTrue(model.contains(s,p,o,c));
- }
- }
-
-
- private DummyLoaderHandler getBase(LoaderHandler handler) {
- if(handler instanceof LoaderHandlerWrapper) {
- return getBase(((LoaderHandlerWrapper) handler).getHandlers()[0]);
- } else if(handler instanceof DummyLoaderHandler) {
- return (DummyLoaderHandler) handler;
- } else {
- throw new IllegalStateException("unknown loader type");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/7163de0b/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/LoaderTestBase.java
----------------------------------------------------------------------
diff --git a/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/LoaderTestBase.java b/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/LoaderTestBase.java
new file mode 100644
index 0000000..7cd3872
--- /dev/null
+++ b/loader/marmotta-loader-core/src/test/java/org/apache/marmotta/loader/core/test/LoaderTestBase.java
@@ -0,0 +1,139 @@
+/*
+ * 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.marmotta.loader.core.test;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.MapConfiguration;
+import org.apache.commons.io.FileUtils;
+import org.apache.marmotta.loader.api.LoaderHandler;
+import org.apache.marmotta.loader.api.LoaderOptions;
+import org.apache.marmotta.loader.core.MarmottaLoader;
+import org.apache.marmotta.loader.core.test.dummy.DummyLoaderHandler;
+import org.apache.marmotta.loader.wrapper.LoaderHandlerWrapper;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openrdf.model.Model;
+import org.openrdf.model.URI;
+import org.openrdf.model.impl.URIImpl;
+import org.openrdf.rio.RDFHandlerException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public abstract class LoaderTestBase {
+
+ protected static Path tempDir;
+
+ private static Logger log = LoggerFactory.getLogger(LoaderTestBase.class);
+
+ protected Configuration cfg;
+
+ public LoaderTestBase() {
+ cfg = new MapConfiguration(new HashMap<String,Object>());
+ }
+
+ @BeforeClass
+ public static void setup() throws IOException {
+ tempDir = Files.createTempDirectory("loader");
+
+ log.info("running loader tests from temporary directory {}", tempDir);
+
+ for(String filename : new String[] {"demo-data.rdf", "demo-data.rdf.gz", "demo-data.rdf.bz2", "demo-data.tar.gz", "demo-data.zip"}) {
+ File data = new File(tempDir.toFile(), filename);
+ FileUtils.copyInputStreamToFile(ArchiveTest.class.getResourceAsStream("/" + filename), data);
+ }
+ }
+
+ @AfterClass
+ public static void teardown() throws IOException {
+ log.info("cleaning up temporary directory {}", tempDir);
+
+ FileUtils.deleteDirectory(tempDir.toFile());
+ }
+
+ @Test
+ public void testAutoLoad() throws RDFHandlerException {
+ log.info("testing automatic loading ...");
+
+ MarmottaLoader loader = new MarmottaLoader(cfg);
+ DummyLoaderHandler handler = getBase(loader.load());
+
+ testData(handler.getModel());
+ }
+
+ @Test
+ public void testStatistics() throws RDFHandlerException {
+ log.info("testing statistics loading ...");
+
+ cfg.setProperty(LoaderOptions.STATISTICS_ENABLED, true);
+ cfg.setProperty(LoaderOptions.STATISTICS_GRAPH, new File(tempDir.toFile(), "stats.png").toString());
+
+ MarmottaLoader loader = new MarmottaLoader(cfg);
+ DummyLoaderHandler handler = getBase(loader.load());
+
+ testData(handler.getModel());
+ }
+
+ @Test
+ public void testContext() throws RDFHandlerException {
+ log.info("testing statistics loading ...");
+
+ cfg.setProperty(LoaderOptions.CONTEXT, "http://localhost/contexts/mycontext");
+
+ MarmottaLoader loader = new MarmottaLoader(cfg);
+ DummyLoaderHandler handler = getBase(loader.load());
+
+ testData(handler.getModel(), new URIImpl("http://localhost/contexts/mycontext"));
+ }
+
+ private void testData(Model model, URI... contexts) {
+ Assert.assertTrue(model.size() > 0);
+
+ URI s = new URIImpl("http://localhost:8080/LMF/resource/hans_meier");
+ URI p = new URIImpl("http://xmlns.com/foaf/0.1/interest");
+ URI o = new URIImpl("http://rdf.freebase.com/ns/en.software_engineering");
+
+ Assert.assertTrue(model.contains(s,p,o));
+
+ for(URI c : contexts) {
+ Assert.assertTrue(model.contains(s,p,o,c));
+ }
+ }
+
+ private DummyLoaderHandler getBase(LoaderHandler handler) {
+ if(handler instanceof LoaderHandlerWrapper) {
+ return getBase(((LoaderHandlerWrapper) handler).getHandlers()[0]);
+ } else if(handler instanceof DummyLoaderHandler) {
+ return (DummyLoaderHandler) handler;
+ } else {
+ throw new IllegalStateException("unknown loader type");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/marmotta/blob/7163de0b/loader/marmotta-loader-core/src/test/resources/demo-data.tar.gz
----------------------------------------------------------------------
diff --git a/loader/marmotta-loader-core/src/test/resources/demo-data.tar.gz b/loader/marmotta-loader-core/src/test/resources/demo-data.tar.gz
new file mode 100644
index 0000000..a990535
Binary files /dev/null and b/loader/marmotta-loader-core/src/test/resources/demo-data.tar.gz differ
http://git-wip-us.apache.org/repos/asf/marmotta/blob/7163de0b/loader/marmotta-loader-core/src/test/resources/demo-data.zip
----------------------------------------------------------------------
diff --git a/loader/marmotta-loader-core/src/test/resources/demo-data.zip b/loader/marmotta-loader-core/src/test/resources/demo-data.zip
new file mode 100644
index 0000000..f84f891
Binary files /dev/null and b/loader/marmotta-loader-core/src/test/resources/demo-data.zip differ