|
From: <lh...@us...> - 2009-07-23 16:41:29
|
Revision: 330
http://tinytim.svn.sourceforge.net/tinytim/?rev=330&view=rev
Author: lheuer
Date: 2009-07-23 16:41:16 +0000 (Thu, 23 Jul 2009)
Log Message:
-----------
Added CXTM tests, a bit hackish, though
Added Paths:
-----------
tinytim-mio/trunk/src/test/java/org/tinytim/mio/
tinytim-mio/trunk/src/test/java/org/tinytim/mio/AbstractCXTMTestCase.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/AllTests.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/CXTMTestUtils.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestCTMTopicMapReader.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestJTMTopicMapReader.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestJTMTopicMapWriter.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestLTMTopicMapReader.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestN3TopicMapReader.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestSnelloTopicMapReader.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTMXMLTopicMapReader.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTMXMLValidatingTopicMapReader.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10TopicMapReader.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10TopicMapWriter.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10ValidatingTopicMapReader.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM20TopicMapReader.java
tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM20ValidatingTopicMapReader.java
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/AbstractCXTMTestCase.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/AbstractCXTMTestCase.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/AbstractCXTMTestCase.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Arrays;
+
+import org.tinytim.core.TinyTimTestCase;
+import org.tmapi.core.TopicMap;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public abstract class AbstractCXTMTestCase extends TinyTimTestCase {
+
+ protected URL _url;
+ private String _subdir;
+
+ protected AbstractCXTMTestCase(URL url, String subdir) {
+ super(url.getFile().substring(url.getFile().lastIndexOf('/')+1));
+ _url = url;
+ _subdir = subdir;
+ }
+
+ protected abstract TopicMapReader makeReader(TopicMap tm, URL url) throws Exception;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#runTest()
+ */
+ @Override
+ protected void runTest() throws Throwable {
+ TopicMapReader reader;
+ try {
+ reader = makeReader(_tm, _url);
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ throw ex;
+ }
+ reader.read();
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
+ CXTMTopicMapWriter writer = new CXTMTopicMapWriter(result, _url.toExternalForm());
+ writer.write(_tm);
+ ByteArrayOutputStream expected = new ByteArrayOutputStream();
+ InputStream tmp = new FileInputStream(CXTMTestUtils.getCXTMFile(_url, _subdir));
+ int b;
+ while ((b = tmp.read()) != -1) {
+ expected.write(b);
+ }
+ byte[] res = result.toByteArray();
+ byte[] ref = expected.toByteArray();
+ if (!Arrays.equals(res, ref)) {
+ System.out.println(result.toString("utf-8"));
+ fail("Expected: " + expected.toString("utf-8") + "\n, got: " + result.toString("utf-8"));
+ }
+ }
+
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/AllTests.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/AllTests.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/AllTests.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class AllTests extends TestSuite {
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static TestSuite suite() {
+ TestSuite suite = new TestSuite();
+ suite.addTest(TestJTMTopicMapReader.suite());
+ suite.addTest(TestN3TopicMapReader.suite());
+ suite.addTest(TestLTMTopicMapReader.suite());
+ suite.addTest(TestTMXMLTopicMapReader.suite());
+ suite.addTest(TestTMXMLValidatingTopicMapReader.suite());
+ suite.addTest(TestSnelloTopicMapReader.suite());
+ suite.addTest(TestXTM10TopicMapReader.suite());
+ suite.addTest(TestXTM10ValidatingTopicMapReader.suite());
+ suite.addTest(TestXTM20TopicMapReader.suite());
+ suite.addTest(TestXTM20ValidatingTopicMapReader.suite());
+ return suite;
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/CXTMTestUtils.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/CXTMTestUtils.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/CXTMTestUtils.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class CXTMTestUtils {
+
+ public static final String DOC_IRI = "http://tinytim.sourceforge.net/map";
+
+ private static final String _TEST_DIR = System.getProperty("org.tinytim.cxtm-test-dir");
+
+ public static List<URL> filterValidFiles(String subdir, String ext) {
+ File dir = null;
+ if (_TEST_DIR == null) {
+ dir = new File(CXTMTestUtils.class.getResource("../../../" + subdir + "/in").getFile());
+ }
+ else {
+ dir = new File(_TEST_DIR + subdir + "/in");
+ }
+ List<URL> urls = new ArrayList<URL>();
+ for (File file : dir.listFiles()) {
+ if (!file.getName().endsWith(ext)) {
+ continue;
+ }
+ try {
+ urls.add(file.toURI().toURL());
+ }
+ catch (MalformedURLException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ return urls;
+ }
+
+ public static String getCXTMFile(URL url, String subdir) {
+ String fileName = url.getFile().replace("/in/", "/baseline/");
+ return fileName + ".cxtm";
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestCTMTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestCTMTopicMapReader.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestCTMTopicMapReader.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.net.URL;
+
+import org.tmapi.core.TopicMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestCTMTopicMapReader extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ for (URL url: CXTMTestUtils.filterValidFiles("ctm", "ctm")) {
+ suite.addTest(new TestCTMTopicMapReaderCase(url, "ctm"));
+ }
+ return suite;
+ }
+
+ private static class TestCTMTopicMapReaderCase extends AbstractCXTMTestCase {
+
+ protected TestCTMTopicMapReaderCase(URL url, String subdir) {
+ super(url, subdir);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.mio.AbstractCXTMTestCase#makeReader(org.tmapi.core.TopicMap, java.net.URL)
+ */
+ @Override
+ protected TopicMapReader makeReader(TopicMap tm, URL file) throws Exception {
+ return new CTMTopicMapReader(tm, file.openStream(), file.toExternalForm());
+ }
+
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestJTMTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestJTMTopicMapReader.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestJTMTopicMapReader.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.net.URL;
+
+import org.tmapi.core.TopicMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestJTMTopicMapReader extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ for (URL url: CXTMTestUtils.filterValidFiles("jtm", "jtm")) {
+ suite.addTest(new TestN3TopicMapReaderCase(url, "jtm"));
+ }
+ return suite;
+ }
+
+ private static class TestN3TopicMapReaderCase extends AbstractCXTMTestCase {
+
+ protected TestN3TopicMapReaderCase(URL url, String subdir) {
+ super(url, subdir);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.mio.AbstractCXTMTestCase#makeReader(org.tmapi.core.TopicMap, java.net.URL)
+ */
+ @Override
+ protected TopicMapReader makeReader(TopicMap tm, URL file) throws Exception {
+ JTMTopicMapReader reader = new JTMTopicMapReader(tm, file.openStream(), file.toExternalForm());
+ return reader;
+ }
+
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestJTMTopicMapWriter.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestJTMTopicMapWriter.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestJTMTopicMapWriter.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.io.ByteArrayOutputStream;
+
+import org.tinytim.core.TinyTimTestCase;
+import org.tmapi.core.Topic;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestJTMTopicMapWriter extends TinyTimTestCase {
+
+ public void testWriting() throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ String base = "http://www.semagia.com/";
+ TopicMapWriter writer = new JTMTopicMapWriter(out, base);
+ _tm.createTopicByItemIdentifier(createLocator(base + "#iid"));
+ Topic topic = createTopic();
+ topic.addItemIdentifier(createLocator("http://www.sesssmsm.de/"));
+ _tm.setReifier(topic);
+ createAssociation();
+ createRole();
+ createRole();
+ createRole();
+ createRole();
+ createVariant();
+ createVariant();
+ createName();
+ writer.write(_tm);
+ System.out.println(out.toString("utf-8"));
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestLTMTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestLTMTopicMapReader.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestLTMTopicMapReader.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.net.URL;
+
+import org.tmapi.core.TopicMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestLTMTopicMapReader extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ for (URL url: CXTMTestUtils.filterValidFiles("ltm", "ltm")) {
+ suite.addTest(new TestLTMTopicMapReaderCase(url, "ltm"));
+ }
+ return suite;
+ }
+
+ private static class TestLTMTopicMapReaderCase extends AbstractCXTMTestCase {
+
+ protected TestLTMTopicMapReaderCase(URL url, String subdir) {
+ super(url, subdir);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.mio.AbstractCXTMTestCase#makeReader(org.tmapi.core.TopicMap, java.net.URL)
+ */
+ @Override
+ protected TopicMapReader makeReader(TopicMap tm, URL file) throws Exception {
+ LTMTopicMapReader reader = new LTMTopicMapReader(tm, file.openStream(), file.toExternalForm());
+ reader.setLegacyReifierHandling(true);
+ return reader;
+ }
+
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestN3TopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestN3TopicMapReader.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestN3TopicMapReader.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.net.URL;
+
+import org.tmapi.core.TopicMap;
+
+import com.semagia.mio.Source;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestN3TopicMapReader extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ for (URL url: CXTMTestUtils.filterValidFiles("rdf", "n3")) {
+ suite.addTest(new TestN3TopicMapReaderCase(url, "rdf"));
+ }
+ return suite;
+ }
+
+ private static class TestN3TopicMapReaderCase extends AbstractCXTMTestCase {
+
+ protected TestN3TopicMapReaderCase(URL url, String subdir) {
+ super(url, subdir);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.mio.AbstractCXTMTestCase#makeReader(org.tmapi.core.TopicMap, java.net.URL)
+ */
+ @Override
+ protected TopicMapReader makeReader(TopicMap tm, URL file) throws Exception {
+ N3TopicMapReader reader = new N3TopicMapReader(tm, new Source(file.toURI().toString()));
+ return reader;
+ }
+
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestSnelloTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestSnelloTopicMapReader.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestSnelloTopicMapReader.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.net.URL;
+
+import org.tmapi.core.TopicMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestSnelloTopicMapReader extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ for (URL url: CXTMTestUtils.filterValidFiles("snello", "stm")) {
+ suite.addTest(new TestSnelloTopicMapReaderCase(url, "stm"));
+ }
+ return suite;
+ }
+
+ private static class TestSnelloTopicMapReaderCase extends AbstractCXTMTestCase {
+
+ protected TestSnelloTopicMapReaderCase(URL url, String subdir) {
+ super(url, subdir);
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.mio.AbstractCXTMTestCase#makeReader(org.tmapi.core.TopicMap, java.net.URL)
+ */
+ @Override
+ protected TopicMapReader makeReader(TopicMap tm, URL file) throws Exception {
+ return new SnelloTopicMapReader(tm, file.openStream(), file.toExternalForm());
+ }
+
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTMXMLTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTMXMLTopicMapReader.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTMXMLTopicMapReader.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.net.URL;
+
+import org.tmapi.core.TopicMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestTMXMLTopicMapReader extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ for (URL url: CXTMTestUtils.filterValidFiles("tmxml", "xml")) {
+ suite.addTest(new TestTMXMLTopicMapReaderCase(url, "tmxml", false));
+ }
+ return suite;
+ }
+
+ private static class TestTMXMLTopicMapReaderCase extends AbstractCXTMTestCase {
+
+ private boolean _validate;
+
+ protected TestTMXMLTopicMapReaderCase(URL url, String subdir, boolean validate) {
+ super(url, subdir);
+ _validate = validate;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.mio.AbstractCXTMTestCase#makeReader(org.tmapi.core.TopicMap, java.net.URL)
+ */
+ @Override
+ protected TopicMapReader makeReader(TopicMap tm, URL file) throws Exception {
+ TMXMLTopicMapReader reader = new TMXMLTopicMapReader(tm, file.openStream(), file.toExternalForm());
+ reader.setValidation(_validate);
+ return reader;
+ }
+
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTMXMLValidatingTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTMXMLValidatingTopicMapReader.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestTMXMLValidatingTopicMapReader.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.net.URL;
+
+import org.tmapi.core.TopicMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestTMXMLValidatingTopicMapReader extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ for (URL url: CXTMTestUtils.filterValidFiles("tmxml", "xml")) {
+ suite.addTest(new TestTMXMLTopicMapReaderCase(url, "tmxml", true));
+ }
+ return suite;
+ }
+
+ private static class TestTMXMLTopicMapReaderCase extends AbstractCXTMTestCase {
+
+ private boolean _validate;
+
+ protected TestTMXMLTopicMapReaderCase(URL url, String subdir, boolean validate) {
+ super(url, subdir);
+ _validate = validate;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.mio.AbstractCXTMTestCase#makeReader(org.tmapi.core.TopicMap, java.net.URL)
+ */
+ @Override
+ protected TopicMapReader makeReader(TopicMap tm, URL file) throws Exception {
+ TMXMLTopicMapReader reader = new TMXMLTopicMapReader(tm, file.openStream(), file.toExternalForm());
+ reader.setValidation(_validate);
+ return reader;
+ }
+
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10TopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10TopicMapReader.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10TopicMapReader.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.net.URL;
+
+import org.tmapi.core.TopicMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestXTM10TopicMapReader extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ for (URL url: CXTMTestUtils.filterValidFiles("xtm1", "xtm")) {
+ suite.addTest(new TestXTM20TopicMapReaderCase(url, "xtm1", false));
+ }
+ return suite;
+ }
+
+ private static class TestXTM20TopicMapReaderCase extends AbstractCXTMTestCase {
+
+ private boolean _validate;
+
+ protected TestXTM20TopicMapReaderCase(URL url, String subdir, boolean validate) {
+ super(url, subdir);
+ _validate = validate;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.mio.AbstractCXTMTestCase#makeReader(org.tmapi.core.TopicMap, java.net.URL)
+ */
+ @Override
+ protected TopicMapReader makeReader(TopicMap tm, URL file) throws Exception {
+ XTM10TopicMapReader reader = new XTM10TopicMapReader(tm, file.openStream(), file.toExternalForm());
+ reader.setValidation(_validate);
+ return reader;
+ }
+
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10TopicMapWriter.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10TopicMapWriter.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10TopicMapWriter.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.io.ByteArrayOutputStream;
+
+import org.tinytim.core.TinyTimTestCase;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestXTM10TopicMapWriter extends TinyTimTestCase {
+
+ public void testWriting() throws Exception {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ String base = "http://www.semagia.com/";
+ TopicMapWriter writer = new XTM10TopicMapWriter(out, base);
+ _tm.createTopicByItemIdentifier(createLocator(base + "#iid"));
+ createAssociation();
+ createRole();
+ createVariant();
+ createName();
+ writer.write(_tm);
+ System.out.println(out.toString("utf-8"));
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10ValidatingTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10ValidatingTopicMapReader.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM10ValidatingTopicMapReader.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.net.URL;
+
+import org.tmapi.core.TopicMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestXTM10ValidatingTopicMapReader extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ for (URL url: CXTMTestUtils.filterValidFiles("xtm1", "xtm")) {
+ suite.addTest(new TestXTM20TopicMapReaderCase(url, "xtm1", true));
+ }
+ return suite;
+ }
+
+ private static class TestXTM20TopicMapReaderCase extends AbstractCXTMTestCase {
+
+ private boolean _validate;
+
+ protected TestXTM20TopicMapReaderCase(URL url, String subdir, boolean validate) {
+ super(url, subdir);
+ _validate = validate;
+ }
+
+ /* (non-Javadoc)
+ * @see org.tinytim.mio.AbstractCXTMTestCase#makeReader(org.tmapi.core.TopicMap, java.net.URL)
+ */
+ @Override
+ protected TopicMapReader makeReader(TopicMap tm, URL file) throws Exception {
+ XTM10TopicMapReader reader = new XTM10TopicMapReader(tm, file.openStream(), file.toExternalForm());
+ reader.setValidation(_validate);
+ return reader;
+ }
+
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM20TopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM20TopicMapReader.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM20TopicMapReader.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.net.URL;
+
+import org.tmapi.core.TopicMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestXTM20TopicMapReader extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ for (URL url: CXTMTestUtils.filterValidFiles("xtm2", "xtm")) {
+ suite.addTest(new TestXTM20TopicMapReaderCase(url, "xtm2"));
+ suite.addTest(new TestXTM20TopicMapReaderCase(url, "xtm2", true));
+ }
+ return suite;
+ }
+
+ private static class TestXTM20TopicMapReaderCase extends AbstractCXTMTestCase {
+
+ private boolean _validate;
+
+ TestXTM20TopicMapReaderCase(URL url, String subdir) {
+ this(url, subdir, false);
+ }
+
+ TestXTM20TopicMapReaderCase(URL url, String subdir, boolean validate) {
+ super(url, subdir);
+ _validate = validate;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.tinytim.mio.AbstractCXTMTestCase#makeReader(org.tmapi.core.TopicMap, java.net.URL)
+ */
+ @Override
+ protected TopicMapReader makeReader(TopicMap tm, URL file) throws Exception {
+ XTM20TopicMapReader reader = new XTM20TopicMapReader(tm, file.openStream(), file.toExternalForm());
+ reader.setValidation(_validate);
+ return reader;
+ }
+
+ }
+}
Added: tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM20ValidatingTopicMapReader.java
===================================================================
--- tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM20ValidatingTopicMapReader.java (rev 0)
+++ tinytim-mio/trunk/src/test/java/org/tinytim/mio/TestXTM20ValidatingTopicMapReader.java 2009-07-23 16:41:16 UTC (rev 330)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * Licensed 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.tinytim.mio;
+
+import java.net.URL;
+
+import org.tmapi.core.TopicMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestXTM20ValidatingTopicMapReader extends TestSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ for (URL url: CXTMTestUtils.filterValidFiles("xtm2", "xtm")) {
+ suite.addTest(new TestXTM20TopicMapReaderCase(url, "xtm2", true));
+ }
+ return suite;
+ }
+
+ private static class TestXTM20TopicMapReaderCase extends AbstractCXTMTestCase {
+
+ private boolean _validate;
+
+ TestXTM20TopicMapReaderCase(URL url, String subdir) {
+ this(url, subdir, false);
+ }
+
+ TestXTM20TopicMapReaderCase(URL url, String subdir, boolean validate) {
+ super(url, subdir);
+ _validate = validate;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.tinytim.mio.AbstractCXTMTestCase#makeReader(org.tmapi.core.TopicMap, java.net.URL)
+ */
+ @Override
+ protected TopicMapReader makeReader(TopicMap tm, URL file) throws Exception {
+ XTM20TopicMapReader reader = new XTM20TopicMapReader(tm, file.openStream(), file.toExternalForm());
+ reader.setValidation(_validate);
+ return reader;
+ }
+
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|