From: <lh...@us...> - 2008-08-07 15:06:51
|
Revision: 106 http://tinytim.svn.sourceforge.net/tinytim/?rev=106&view=rev Author: lheuer Date: 2008-08-07 15:06:58 +0000 (Thu, 07 Aug 2008) Log Message: ----------- Removed old test suite Removed Paths: ------------- tinytim/trunk/src/test/java/org/tinytim/AbstractTMAPITestSuite.java tinytim/trunk/src/test/java/org/tinytim/AllTests.java tinytim/trunk/src/test/java/org/tinytim/TestConstruct.java tinytim/trunk/src/test/java/org/tinytim/TestDuplicateRemovalUtils.java tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java tinytim/trunk/src/test/java/org/tinytim/TestScoped.java tinytim/trunk/src/test/java/org/tinytim/TestSignatureGenerator.java tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java tinytim/trunk/src/test/java/org/tinytim/TestTopic.java tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java tinytim/trunk/src/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java tinytim/trunk/src/test/java/org/tinytim/TestTopicMergeDetection.java tinytim/trunk/src/test/java/org/tinytim/TestTopicUtils.java tinytim/trunk/src/test/java/org/tinytim/TestTyped.java tinytim/trunk/src/test/java/org/tinytim/TinyTimTestCase.java tinytim/trunk/src/test/java/org/tinytim/index/ Deleted: tinytim/trunk/src/test/java/org/tinytim/AbstractTMAPITestSuite.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/AbstractTMAPITestSuite.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/AbstractTMAPITestSuite.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,36 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import junit.framework.TestSuite; - -/** - * Base class for all TMAPI-related test cases. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public abstract class AbstractTMAPITestSuite extends TestSuite { - - static { - System.setProperty("org.tmapi.core.TopicMapSystemFactory", "org.tinytim.TopicMapSystemFactoryImpl"); - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/AllTests.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/AllTests.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/AllTests.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,62 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import org.tinytim.index.TestScopedIndex; -import org.tinytim.index.TestTypeInstanceIndex; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Runs all tests. - * - * @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 Test suite() { - TestSuite suite = new TestSuite(); - suite.addTestSuite(TestConstruct.class); - suite.addTestSuite(TestDuplicateRemovalUtils.class); - suite.addTestSuite(TestItemIdentifierConstraint.class); - suite.addTestSuite(TestReifiable.class); - suite.addTestSuite(TestScoped.class); - suite.addTestSuite(TestTopic.class); - suite.addTestSuite(TestSignatureGenerator.class); - suite.addTest(TestTMAPICore.suite()); - suite.addTest(TestTMAPIIndex.suite()); - suite.addTestSuite(TestTopicMapMerge.class); - suite.addTestSuite(TestTopicMapSystemFactoryImpl.class); - suite.addTestSuite(TestTopicMerge.class); - suite.addTestSuite(TestTopicMergeDetection.class); - suite.addTestSuite(TestTopicUtils.class); - suite.addTestSuite(TestTyped.class); - suite.addTestSuite(TestScopedIndex.class); - suite.addTestSuite(TestTypeInstanceIndex.class); - return suite; - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestConstruct.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestConstruct.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestConstruct.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,117 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import org.tmapi.core.Association; -import org.tmapi.core.AssociationRole; -import org.tmapi.core.Locator; -import org.tmapi.core.Occurrence; -import org.tmapi.core.Topic; -import org.tmapi.core.TopicName; -import org.tmapi.core.Variant; - -/** - * Tests against {@link IConstruct}. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public class TestConstruct extends TinyTimTestCase { - - /** - * Tests against the topic map. - */ - public void testTopicMap() { - _testConstruct((IConstruct) _tm); - } - - /** - * Tests against the topic. - */ - public void testTopic() { - _testConstruct((IConstruct) _tm.createTopic()); - } - - /** - * Tests against the association. - */ - public void testAssociation() { - _testConstruct((IConstruct) _tm.createAssociation()); - } - - /** - * Tests against the role. - */ - public void testRole() { - Association assoc = _tm.createAssociation(); - AssociationRole role = assoc.createAssociationRole(null, null); - _testConstruct((IConstruct) role); - } - - /** - * Tests against an occurrence. - */ - public void testOccurrence() { - Topic topic = _tm.createTopic(); - Occurrence occ = topic.createOccurrence("tinyTiM", null, null); - _testConstruct((IConstruct) occ); - } - - /** - * Tests against a name. - */ - public void testName() { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName("tinyTiM", null, null); - _testConstruct((IConstruct) name); - } - - /** - * Tests against a variant. - */ - public void testVariant() { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName("tinyTiM", null, null); - Variant variant = name.createVariant("tinyTiM", null); - _testConstruct((IConstruct) variant); - } - - /** - * Tests adding / removing item identifiers, retrieval by item identifier. - * - * @param construct The Topic Maps construct to test. - */ - private void _testConstruct(IConstruct construct) { - assertEquals(0, construct.getItemIdentifiers().size()); - Locator iid = _tm.createLocator("http://sf.net/projects/tinytim/#test"); - construct.addItemIdentifier(iid); - assertEquals(1, construct.getItemIdentifiers().size()); - assertTrue(construct.getItemIdentifiers().contains(iid)); - assertEquals(construct, _tm.getObjectByItemIdentifier(iid)); - construct.removeItemIdentifier(iid); - assertEquals(0, construct.getItemIdentifiers().size()); - assertFalse(construct.getItemIdentifiers().contains(iid)); - assertNull(_tm.getObjectByItemIdentifier(iid)); - - String id = construct.getObjectId(); - assertEquals(construct, _tm.getObjectById(id)); - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestDuplicateRemovalUtils.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestDuplicateRemovalUtils.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestDuplicateRemovalUtils.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,107 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import java.util.Arrays; -import java.util.Collection; - -import org.tmapi.core.Association; -import org.tmapi.core.Locator; -import org.tmapi.core.Topic; -import org.tmapi.core.TopicName; - -/** - * Tests against the {@link DuplicateRemovalUtils}. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ - */ -public class TestDuplicateRemovalUtils extends TinyTimTestCase { - - public void testTopicRemoveNames() { - Topic topic = _tm.createTopic(); - TopicName name1 = topic.createTopicName("tinyTiM", null); - TopicName name2 = topic.createTopicName("tinyTiM", null); - assertNull(name1.getType()); - assertTrue(name1.getScope().isEmpty()); - assertNull(name2.getType()); - assertTrue(name2.getScope().isEmpty()); - assertEquals(2, topic.getTopicNames().size()); - DuplicateRemovalUtils.removeDuplicates(topic); - assertEquals(1, topic.getTopicNames().size()); - TopicName name = (TopicName) topic.getTopicNames().iterator().next(); - assertEquals("tinyTiM", name.getValue()); - assertNull(name.getType()); - assertTrue(name.getScope().isEmpty()); - } - - public void testTopicRemoveNames2() { - Topic topic = _tm.createTopic(); - TopicName name1 = topic.createTopicName("tinyTiM", null); - TopicName name2 = topic.createTopicName("tinyTiM", null); - Locator iid1 = _tm.createLocator("http://example.org/iid-1"); - Locator iid2 = _tm.createLocator("http://example.org/iid-2"); - name1.addSourceLocator(iid1); - name2.addSourceLocator(iid2); - assertEquals(2, topic.getTopicNames().size()); - DuplicateRemovalUtils.removeDuplicates(topic); - assertEquals(1, topic.getTopicNames().size()); - TopicName name = (TopicName) topic.getTopicNames().iterator().next(); - assertEquals("tinyTiM", name.getValue()); - assertNull(name.getType()); - assertTrue(name.getScope().isEmpty()); - assertEquals(2, name.getSourceLocators().size()); - assertTrue(name.getSourceLocators().contains(iid1)); - assertTrue(name.getSourceLocators().contains(iid2)); - } - - public void testTopicRemoveNames3() { - Topic topic = _tm.createTopic(); - Topic theme1 = _tm.createTopic(); - Topic theme2 = _tm.createTopic(); - Collection<Topic> scope1 = Arrays.asList(new Topic[] {theme1, theme2}); - Collection<Topic> scope2 = Arrays.asList(new Topic[] {theme2, theme1}); - TopicName name1 = topic.createTopicName("tinyTiM", scope1); - TopicName name2 = topic.createTopicName("tinyTiM", scope2); - assertEquals(2, name1.getScope().size()); - assertEquals(2, name2.getScope().size()); - assertEquals(2, topic.getTopicNames().size()); - DuplicateRemovalUtils.removeDuplicates(topic); - assertEquals(1, topic.getTopicNames().size()); - TopicName name = (TopicName) topic.getTopicNames().iterator().next(); - assertEquals("tinyTiM", name.getValue()); - assertNull(name.getType()); - assertEquals(2, name.getScope().size()); - } - - public void testRemoveRoles() { - Association assoc = _tm.createAssociation(); - Topic type = _tm.createTopic(); - Topic player = _tm.createTopic(); - assoc.createAssociationRole(player, type); - assoc.createAssociationRole(player, type); - assertEquals(2, player.getRolesPlayed().size()); - assertEquals(2, assoc.getAssociationRoles().size()); - DuplicateRemovalUtils.removeDuplicates(assoc); - assertEquals(1, player.getRolesPlayed().size()); - assertEquals(1, assoc.getAssociationRoles().size()); - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestItemIdentifierConstraint.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,155 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import org.tmapi.core.Association; -import org.tmapi.core.AssociationRole; -import org.tmapi.core.DuplicateSourceLocatorException; -import org.tmapi.core.Locator; -import org.tmapi.core.Occurrence; -import org.tmapi.core.Topic; -import org.tmapi.core.TopicMap; -import org.tmapi.core.TopicMapObject; -import org.tmapi.core.TopicName; -import org.tmapi.core.TopicsMustMergeException; -import org.tmapi.core.Variant; - -/** - * Tests if the TMDM item identifier constraint is respected. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public class TestItemIdentifierConstraint extends TinyTimTestCase { - - /** - * Tests against a topic map. - */ - public void testTopicMap() throws Exception { - _testConstraint(_tm); - } - - /** - * Tests againts a topic. - */ - public void testTopic() throws Exception { - Topic topic = _tm.createTopic(); - Locator iid = _tm.createLocator("http://sf.net/projects/tinytim"); - topic.addSourceLocator(iid); - assertTrue(topic.getSourceLocators().contains(iid)); - Topic topic2 = _tm.createTopic(); - try { - topic2.addSourceLocator(iid); - } - catch (TopicsMustMergeException ex) { - // noop. - } - topic.removeSourceLocator(iid); - assertFalse(topic.getSourceLocators().contains(iid)); - topic2.addSourceLocator(iid); - assertTrue(topic2.getSourceLocators().contains(iid)); - topic2.removeSourceLocator(iid); - topic.addSourceLocator(iid); - assertTrue(topic.getSourceLocators().contains(iid)); - assertFalse(topic2.getSourceLocators().contains(iid)); - topic.remove(); - topic2.addSourceLocator(iid); - assertTrue(topic2.getSourceLocators().contains(iid)); - } - - /** - * Tests against an association. - */ - public void testAssociation() throws Exception { - _testConstraint(_tm.createAssociation()); - } - - /** - * Tests against a role. - */ - public void testRole() throws Exception { - Association assoc = _tm.createAssociation(); - AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic()); - _testConstraint(role); - } - - /** - * Tests against an occurrence. - */ - public void testOccurrence() throws Exception { - Topic topic = _tm.createTopic(); - Occurrence occ = topic.createOccurrence("tinyTiM", null, null); - _testConstraint(occ); - } - - /** - * Tests against a name. - */ - public void testName() throws Exception { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName("tinyTiM", null, null); - _testConstraint(name); - } - - /** - * Tests against a variant. - */ - public void testVariant() throws Exception { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName("tinyTiM", null, null); - Variant variant = name.createVariant("tinyTiM", null); - _testConstraint(variant); - } - - /** - * The item identifier constraint test. - * - * @param tmo The Topic Maps construct to test. - */ - private void _testConstraint(TopicMapObject tmo) throws Exception { - assertTrue(tmo.getSourceLocators().isEmpty()); - Locator iid = _tm.createLocator("http://sf.net/projects/tinytim"); - tmo.addSourceLocator(iid); - assertTrue(tmo.getSourceLocators().contains(iid)); - Association assoc = _tm.createAssociation(); - try { - assoc.addSourceLocator(iid); - fail("Topic Maps constructs with the same item identifier are not allowed"); - } - catch (DuplicateSourceLocatorException ex) { - // noop - } - tmo.removeSourceLocator(iid); - assertFalse(tmo.getSourceLocators().contains(iid)); - assoc.addSourceLocator(iid); - assertTrue(assoc.getSourceLocators().contains(iid)); - assoc.removeSourceLocator(iid); - assertFalse(assoc.getSourceLocators().contains(iid)); - tmo.addSourceLocator(iid); - assertTrue(tmo.getSourceLocators().contains(iid)); - if (!(tmo instanceof TopicMap)) { - // Removal should 'free' the item identifier - tmo.remove(); - assoc.addSourceLocator(iid); - assertTrue(assoc.getSourceLocators().contains(iid)); - } - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,163 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import java.util.Properties; - -import org.tmapi.core.Association; -import org.tmapi.core.AssociationRole; -import org.tmapi.core.ModelConstraintException; -import org.tmapi.core.Occurrence; -import org.tmapi.core.Topic; -import org.tmapi.core.TopicMap; -import org.tmapi.core.TopicName; -import org.tmapi.core.Variant; - -/** - * Tests against the {@link org.tinytim.IReifiable} interface. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public class TestReifiable extends TinyTimTestCase { - - /* (non-Javadoc) - * @see org.tinytim.TinyTimTestCase#getAdditionalProperties() - */ - @Override - protected Properties getAdditionalProperties() { - Properties props = new Properties(); - props.setProperty(Property.XTM10_REIFICATION, "false"); - return props; - } - - /** - * Tests if a Topic Maps construct is an instance of IReifiable. - */ - public void testInstanceOf() { - assertTrue(((TopicMap)_tm) instanceof IReifiable); - Topic topic = _tm.createTopic(); - assertFalse(topic instanceof IReifiable); - Association assoc = _tm.createAssociation(); - assertTrue(assoc instanceof IReifiable); - AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic()); - assertTrue(role instanceof IReifiable); - Occurrence occ = topic.createOccurrence("tinyTiM", null, null); - assertTrue(occ instanceof IReifiable); - TopicName name = topic.createTopicName("tinyTiM", null); - assertTrue(name instanceof IReifiable); - Variant variant = name.createVariant("tinyTiM", null); - assertTrue(variant instanceof IReifiable); - } - - /** - * Tests setting and getting the reifier of a topic map. - */ - public void testTopicMap() { - _testSetGet((IReifiable)_tm); - } - - /** - * Tests setting and getting the reifier of an association. - */ - public void testAssociation() { - _testSetGet((IReifiable)_tm.createAssociation()); - } - - /** - * Tests setting and getting the reifier of a role. - */ - public void testRole() { - Association assoc = _tm.createAssociation(); - AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic()); - _testSetGet((IReifiable)role); - } - - /** - * Tests setting and getting the reifier of an occurrence. - */ - public void testOccurrence() { - Topic topic = _tm.createTopic(); - Occurrence occ = topic.createOccurrence("tinyTiM", null, null); - _testSetGet((IReifiable)occ); - } - - /** - * Tests setting and getting the reifier of a name. - */ - public void testName() { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName("tinyTiM", null, null); - _testSetGet((IReifiable)name); - } - - /** - * Tests setting and getting the reifier of a variant. - */ - public void testVariant() { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName("tinyTiM", null, null); - Variant variant = name.createVariant("tinyTiM", null); - _testSetGet((IReifiable)variant); - } - - /** - * Tests setting and getting the reifier of a reifiable Topic Maps construct. - * - * @param reifiable The Topic Maps construct to test. - */ - private void _testSetGet(IReifiable reifiable) { - assertNull(reifiable.getReifier()); - TopicImpl reifier = (TopicImpl) _tm.createTopic(); - assertEquals(0, reifier.getReified().size()); - reifiable.setReifier(reifier); - assertEquals(reifier, reifiable.getReifier()); - assertEquals(reifiable, reifier.getReifiedConstruct()); - assertEquals(1, reifier.getReified().size()); - assertTrue(reifier.getReified().contains(reifiable)); - reifiable.setReifier(null); - assertNull(reifiable.getReifier()); - assertNull(reifier.getReifiedConstruct()); - assertEquals(0, reifier.getReified().size()); - - TopicImpl reifier2 = (TopicImpl) _tm.createTopic(); - IReifiable assoc = (IReifiable) _tm.createAssociation(); - assoc.setReifier(reifier2); - assertEquals(reifier2, assoc.getReifier()); - assertEquals(assoc, reifier2.getReifiedConstruct()); - try { - reifiable.setReifier(reifier2); - fail("Expected an exception. The reifier reifies another Topic Maps construct"); - } - catch (ModelConstraintException ex) { - // noop. - } - assoc.setReifier(null); - assertNull(assoc.getReifier()); - assertNull(reifier2.getReifiedConstruct()); - reifiable.setReifier(reifier); - assertEquals(reifier, reifiable.getReifier()); - assertEquals(reifiable, reifier.getReifiedConstruct()); - reifiable.setReifier(reifier2); - assertEquals(reifier2, reifiable.getReifier()); - assertEquals(reifiable, reifier2.getReifiedConstruct()); - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestReificationUtils.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,138 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import org.tmapi.core.Association; -import org.tmapi.core.AssociationRole; -import org.tmapi.core.Locator; -import org.tmapi.core.Occurrence; -import org.tmapi.core.Topic; -import org.tmapi.core.TopicMap; -import org.tmapi.core.TopicMapObject; -import org.tmapi.core.TopicName; -import org.tmapi.core.Variant; - -/** - * Tests against the {@link ReificationUtils}. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public class TestReificationUtils extends TinyTimTestCase { - - /** - * Tests reification of a topic map - */ - public void testTopicMap() throws Exception { - _testReification(_tm); - } - - /** - * Tests reification of a topic (which is not possible) - */ - public void testTopic() { - try { - ReificationUtils.getReifier(_tm.createTopic()); - fail("Topic cannot be reified"); - } - catch (IllegalArgumentException ex) { - // noop. - } - } - - /** - * Tests reification of an association. - */ - public void testAssociation() throws Exception { - _testReification(_tm.createAssociation()); - } - - /** - * Tests reification of a role. - */ - public void testRole() throws Exception { - Association assoc = _tm.createAssociation(); - AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic()); - _testReification(role); - } - - /** - * Tests reification of an occurrence. - */ - public void testOccurrence() throws Exception { - Topic topic = _tm.createTopic(); - Occurrence occ = topic.createOccurrence("tinyTiM", null, null); - _testReification(occ); - } - - /** - * Tests reification of a name. - */ - public void testName() throws Exception { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName("tinyTiM", null, null); - _testReification(name); - } - - /** - * Tests reification of a variant. - */ - public void testVariant() throws Exception { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName("tinyTiM", null, null); - Variant variant = name.createVariant("tinyTiM", null); - _testReification(variant); - } - - /** - * The reification test. - * - * @param tmo The Topic Maps construct to test. - * @throws Exception - */ - private void _testReification(TopicMapObject tmo) throws Exception { - assertTrue(tmo.getSourceLocators().isEmpty()); - assertNull(ReificationUtils.getReifier(tmo)); - Locator loc = _tm.createLocator("http://sf.net/projects/tinytim/#example"); - Topic reifier = _tm.createTopic(); - assertTrue(reifier.getSubjectIdentifiers().isEmpty()); - assertEquals(0, ReificationUtils.getReified(reifier).size()); - reifier.addSubjectIdentifier(loc); - assertEquals(1, reifier.getSubjectIdentifiers().size()); - assertEquals(0, ReificationUtils.getReified(reifier).size()); - tmo.addSourceLocator(loc); - assertEquals(1, ReificationUtils.getReified(reifier).size()); - assertTrue(ReificationUtils.getReified(reifier).contains(tmo)); - assertEquals(reifier, ReificationUtils.getReifier(tmo)); - tmo.removeSourceLocator(loc); - assertEquals(0, ReificationUtils.getReified(reifier).size()); - assertFalse(ReificationUtils.getReified(reifier).contains(tmo)); - assertNull(ReificationUtils.getReifier(tmo)); - if (!(tmo instanceof TopicMap)) { - tmo.addSourceLocator(loc); - assertEquals(1, ReificationUtils.getReified(reifier).size()); - assertTrue(ReificationUtils.getReified(reifier).contains(tmo)); - assertEquals(reifier, ReificationUtils.getReifier(tmo)); - tmo.remove(); - assertEquals(0, ReificationUtils.getReified(reifier).size()); - } - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestScoped.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestScoped.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestScoped.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,119 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import org.tmapi.core.Association; -import org.tmapi.core.AssociationRole; -import org.tmapi.core.Occurrence; -import org.tmapi.core.Topic; -import org.tmapi.core.TopicMap; -import org.tmapi.core.TopicName; -import org.tmapi.core.Variant; - -/** - * Tests against the {@link org.tinytim.IScoped} interface. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public class TestScoped extends TinyTimTestCase { - - /** - * Tests if a Topic Maps construct is an instance of IScoped. - */ - public void testInstanceOf() { - assertFalse(((TopicMap)_tm) instanceof IScoped); - Topic topic = _tm.createTopic(); - assertFalse(topic instanceof IScoped); - Association assoc = _tm.createAssociation(); - assertTrue(assoc instanceof IScoped); - AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic()); - assertFalse(role instanceof IScoped); - Occurrence occ = topic.createOccurrence("tinyTiM", null, null); - assertTrue(occ instanceof IScoped); - TopicName name = topic.createTopicName("tinyTiM", null); - assertTrue(name instanceof IScoped); - Variant variant = name.createVariant("tinyTiM", null); - assertTrue(variant instanceof IScoped); - } - - /** - * Tests against an association. - */ - public void testAssociation() { - Association assoc = _tm.createAssociation(); - _testScoped((IScoped) assoc); - } - - /** - * Tests against an occurrence. - */ - public void testOccurrence() { - Topic topic = _tm.createTopic(); - Occurrence occ = topic.createOccurrence("tinyTiM", null, null); - _testScoped((IScoped) occ); - } - - /** - * Tests against a name. - */ - public void testName() { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName("tinyTiM", null, null); - _testScoped((IScoped) name); - } - - /** - * Tests against a variant. - */ - public void testVariant() { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName("tinyTiM", null, null); - Variant variant = name.createVariant("tinyTiM", null); - _testScoped((IScoped) variant); - } - - /** - * Tests adding / removing themes. - * - * @param scoped The scoped Topic Maps construct to test. - */ - private void _testScoped(IScoped scoped) { - //TODO: This may fail in the future for variants - assertEquals(0, scoped.getScope().size()); - Topic theme1 = _tm.createTopic(); - scoped.addTheme(theme1); - assertEquals(1, scoped.getScope().size()); - assertTrue(scoped.getScope().contains(theme1)); - Topic theme2 = _tm.createTopic(); - assertFalse(scoped.getScope().contains(theme2)); - scoped.addTheme(theme2); - assertEquals(2, scoped.getScope().size()); - assertTrue(scoped.getScope().contains(theme1)); - assertTrue(scoped.getScope().contains(theme2)); - scoped.removeTheme(theme2); - assertEquals(1, scoped.getScope().size()); - assertTrue(scoped.getScope().contains(theme1)); - assertFalse(scoped.getScope().contains(theme2)); - scoped.removeTheme(theme1); - assertEquals(0, scoped.getScope().size()); - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestSignatureGenerator.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestSignatureGenerator.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestSignatureGenerator.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,129 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import org.tinytim.SignatureGenerator; -import org.tmapi.core.Association; -import org.tmapi.core.AssociationRole; -import org.tmapi.core.Occurrence; -import org.tmapi.core.Topic; -import org.tmapi.core.TopicName; -import org.tmapi.core.Variant; - -/** - * Tests against the {@link org.tinytim.SignatureGenerator}. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public class TestSignatureGenerator extends TinyTimTestCase { - - /** - * Tests if an association with no initialized properties returns the same - * signature. - */ - public void testAssociationBasic() { - Association assoc = _tm.createAssociation(); - Association assoc2 = _tm.createAssociation(); - assertFalse(assoc.getObjectId().equals(assoc2.getObjectId())); - String sig = SignatureGenerator.generateSignature(assoc); - assertEquals(sig, SignatureGenerator.generateSignature(assoc2)); - } - - /** - * Tests if a role with no initialized properties returns the same - * signature. - */ - public void testRoleBasic() { - Association assoc = _tm.createAssociation(); - AssociationRole role = assoc.createAssociationRole(null, null); - AssociationRole role2 = assoc.createAssociationRole(null, null); - assertFalse(role.getObjectId().equals(role2.getObjectId())); - String sig = SignatureGenerator.generateSignature(role); - assertEquals(sig, SignatureGenerator.generateSignature(role2)); - } - - /** - * Tests if an occurrence with no initialized properties returns the same - * signature. - */ - public void testOccurrenceBasic() { - Topic topic = _tm.createTopic(); - Occurrence occ = topic.createOccurrence((String) null, null, null); - Occurrence occ2 = topic.createOccurrence((String) null, null, null); - assertFalse(occ.getObjectId().equals(occ2.getObjectId())); - String sig = SignatureGenerator.generateSignature(occ); - assertEquals(sig, SignatureGenerator.generateSignature(occ2)); - } - - /** - * Tests if a name with no initialized properties returns the same - * signature. - */ - public void testNameBasic() { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName(null, null); - TopicName name2 = topic.createTopicName(null, null); - assertFalse(name.getObjectId().equals(name2.getObjectId())); - String sig = SignatureGenerator.generateSignature(name); - assertEquals(sig, SignatureGenerator.generateSignature(name2)); - } - - /** - * Tests if a variant with no initialized properties returns the same - * signature. - */ - public void testVariantBasic() { - Topic topic = _tm.createTopic(); - TopicName name = topic.createTopicName("tinyTiM", null); - Variant variant = name.createVariant("tiny Topic Maps", null); - String sig = SignatureGenerator.generateSignature(variant); - assertEquals(sig, SignatureGenerator.generateSignature(variant)); - } - - /** - * Tests if associations with the same type return the same signature. - */ - public void testAssociationTyped() { - Association assoc = _tm.createAssociation(); - String sigBefore = SignatureGenerator.generateSignature(assoc); - Topic type = _tm.createTopic(); - assoc.setType(type); - String sigAfter = SignatureGenerator.generateSignature(assoc); - assertFalse(sigBefore.equals(sigAfter)); - Association assoc2 = _tm.createAssociation(); - assertEquals(sigBefore, SignatureGenerator.generateSignature(assoc2)); - assoc2.setType(type); - assertEquals(sigAfter, SignatureGenerator.generateSignature(assoc2)); - } - - public void testRoles() { - Association assoc = _tm.createAssociation(); - Topic type = _tm.createTopic(); - Topic player = _tm.createTopic(); - AssociationRole role1 = assoc.createAssociationRole(player, type); - AssociationRole role2 = assoc.createAssociationRole(player, type); - assertEquals(2, player.getRolesPlayed().size()); - assertEquals(2, assoc.getAssociationRoles().size()); - String sig = SignatureGenerator.generateSignature(role1); - assertEquals(sig, SignatureGenerator.generateSignature(role2)); - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,42 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import org.tmapi.core.test.AllTMAPITests; - -import junit.framework.Test; - -/** - * Runs the TMAPI core test suite against tinyTiM. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public class TestTMAPICore extends AbstractTMAPITestSuite { - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - - public static Test suite() { - return AllTMAPITests.suite(); - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,42 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import org.tmapi.index.core.test.AllTMAPIIndexTests; - -import junit.framework.Test; - -/** - * Runs the TMAPI index test suite against tinyTiM. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public class TestTMAPIIndex extends AbstractTMAPITestSuite { - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - - public static Test suite() { - return AllTMAPIIndexTests.suite(); - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestTopic.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestTopic.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestTopic.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,44 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import org.tmapi.core.Locator; -import org.tmapi.core.Topic; - -/** - * Tests against the {@link org.tmapi.core.Topic}. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ - */ -public class TestTopic extends TinyTimTestCase { - - public void testSubjectLocators() { - final Topic topic = _tm.createTopic(); - assertEquals(0, topic.getSubjectLocators().size()); - final Locator loc = _tm.createLocator("http://www.example.org/"); - topic.addSubjectLocator(loc); - assertEquals(1, topic.getSubjectLocators().size()); - assertTrue(topic.getSubjectLocators().contains(loc)); - topic.removeSubjectLocator(loc); - assertEquals(0, topic.getSubjectLocators().size()); - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMapMerge.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,157 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import org.tmapi.core.Locator; -import org.tmapi.core.Topic; -import org.tmapi.core.TopicMap; - -/** - * Tests merging of topic maps. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public class TestTopicMapMerge extends TinyTimTestCase { - - private static final String _TM2_BASE = "http://www.sf.net/projects/tinytim/tm-2"; - - private TopicMap _tm2; - - /* (non-Javadoc) - * @see org.tinytim.TinyTimTestCase#setUp() - */ - @Override - protected void setUp() throws Exception { - super.setUp(); - _tm2 = _sys.createTopicMap(_TM2_BASE); - } - - /* (non-Javadoc) - * @see org.tinytim.TinyTimTestCase#tearDown() - */ - @Override - protected void tearDown() throws Exception { - super.tearDown(); - _tm2 = null; - } - - /** - * Tests merging of topics by equal item identifiers. - */ - public void testMergeSimple1() { - final String ref = "http://sf.net/projects/tinytim/loc"; - Topic topicA = _tm.createTopic(); - Locator iidA = _tm.createLocator(ref); - topicA.addSourceLocator(iidA); - Topic topicB = _tm2.createTopic(); - Locator iidB = _tm2.createLocator(ref); - topicB.addSourceLocator(iidB); - assertEquals(1, _tm.getTopics().size()); - assertEquals(1, _tm2.getTopics().size()); - - _tm.mergeIn(_tm2); - assertEquals(1, _tm.getTopics().size()); - assertEquals(topicA, _tm.getObjectByItemIdentifier(iidA)); - } - - /** - * Tests merging of topics by equal subject identifiers. - */ - public void testMergeSimple2() { - final String ref = "http://sf.net/projects/tinytim/loc"; - Topic topicA = _tm.createTopic(); - Locator sidA = _tm.createLocator(ref); - topicA.addSubjectIdentifier(sidA); - Topic topicB = _tm2.createTopic(); - Locator sidB = _tm2.createLocator(ref); - topicB.addSubjectIdentifier(sidB); - assertEquals(1, _tm.getTopics().size()); - assertEquals(1, _tm2.getTopics().size()); - - _tm.mergeIn(_tm2); - assertEquals(1, _tm.getTopics().size()); - assertEquals(topicA, _tm.getTopicBySubjectIdentifier(sidA)); - } - - /** - * Tests merging of topics by equal subject locators. - */ - public void testMergeSimple3() { - final String ref = "http://sf.net/projects/tinytim/loc"; - Topic topicA = _tm.createTopic(); - Locator sloA = _tm.createLocator(ref); - topicA.addSubjectLocator(sloA); - Topic topicB = _tm2.createTopic(); - Locator sloB = _tm2.createLocator(ref); - topicB.addSubjectLocator(sloB); - assertEquals(1, _tm.getTopics().size()); - assertEquals(1, _tm2.getTopics().size()); - - _tm.mergeIn(_tm2); - assertEquals(1, _tm.getTopics().size()); - assertEquals(topicA, _tm.getTopicBySubjectLocator(sloA)); - } - - /** - * Tests merging of topics by existing topic with item identifier equals - * to a topic's subject identifier from the other map. - */ - public void testMergeSimple4() { - final String ref = "http://sf.net/projects/tinytim/loc"; - Topic topicA = _tm.createTopic(); - Locator loc = _tm.createLocator(ref); - topicA.addSourceLocator(loc); - Topic topicB = _tm2.createTopic(); - Locator locB = _tm2.createLocator(ref); - topicB.addSubjectIdentifier(locB); - assertEquals(1, _tm.getTopics().size()); - assertEquals(1, _tm2.getTopics().size()); - assertEquals(topicA, _tm.getObjectByItemIdentifier(loc)); - assertNull(_tm.getTopicBySubjectIdentifier(loc)); - _tm.mergeIn(_tm2); - assertEquals(1, _tm.getTopics().size()); - assertEquals(topicA, _tm.getObjectByItemIdentifier(loc)); - assertEquals(topicA, _tm.getTopicBySubjectIdentifier(loc)); - } - - /** - * Tests merging of topics by existing topic with subject identifier equals - * to a topic's item identifier from the other map. - */ - public void testMergeSimple5() { - final String ref = "http://sf.net/projects/tinytim/loc"; - Topic topicA = _tm.createTopic(); - Locator loc = _tm.createLocator(ref); - topicA.addSubjectIdentifier(loc); - Topic topicB = _tm2.createTopic(); - Locator locB = _tm2.createLocator(ref); - topicB.addSourceLocator(locB); - assertEquals(1, _tm.getTopics().size()); - assertEquals(1, _tm2.getTopics().size()); - assertNull(_tm.getObjectByItemIdentifier(loc)); - assertEquals(topicA, _tm.getTopicBySubjectIdentifier(loc)); - _tm.mergeIn(_tm2); - assertEquals(1, _tm.getTopics().size()); - assertEquals(topicA, _tm.getObjectByItemIdentifier(loc)); - assertEquals(topicA, _tm.getTopicBySubjectIdentifier(loc)); - } -} Deleted: tinytim/trunk/src/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java 2008-08-07 14:42:58 UTC (rev 105) +++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java 2008-08-07 15:06:58 UTC (rev 106) @@ -1,179 +0,0 @@ -/* - * This is tinyTiM, a tiny Topic Maps engine. - * - * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -package org.tinytim; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import org.tinytim.ICollectionFactory; -import org.tinytim.JavaCollectionFactory; -import org.tinytim.Property; -import org.tinytim.TMAPIFeature; -import org.tinytim.TopicMapSystemImpl; -import org.tmapi.core.FeatureNotRecognizedException; -import org.tmapi.core.FeatureNotSupportedException; - -/** - * Tests against the {@link org.tinytim.TopicMapSystemFactoryImpl}. - * - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public class TestTopicMapSystemFactoryImpl extends TinyTimTestCase { - - /** - * Tests the default feature values. - * - * @throws Exception - */ - public void testDefaultFeatureValues() throws Exception { - assertTrue(_sysFactory.getFeature(TMAPIFeature.NOTATION_URI)); - assertTrue(_sysFactory.getFeature(TMAPIFeature.XTM_1_1)); - assertFalse(_sysFactory.getFeature(TMAPIFeature.XTM_1_0)); - assertFalse(_sysFactory.getFeature(TMAPIFeature.READ_ONLY)); - assertFalse(_sysFactory.getFeature(TMAPIFeature.AUTOMERGE)); - assertFalse(_sysFactory.getFeature(TMAPIFeature.TNC)); - } - - - private void _setFeatureToAcceptedValue(String featureName, boolean value) throws Exception { - try { - _sysFactory.setFeature(featureName, value); - } - catch (FeatureNotSupportedException ex) { - fail("Unexpected exception while setting '" + featureName + "' to '" + value + "'"); - } - } - - private void _setFeatureToUnacceptedValue(String featureName, boolean value) throws Exception { - try { - _sysFactory.setFeature(featureName, value); - fail("Expected exception while setting '" + featureName + "' to '" + value + "'"); - } - catch (FeatureNotSupportedException ex) { - // noop. - } - } - - /** - * Tests if enabling / disabling of various features delivers the expected - * results. - * - * @throws Exception - */ - public void testSetFeatureValues() throws Exception { - _setFeatureToAcceptedValue(TMAPIFeature.NOTATION_URI, true); - _setFeatureToUnacceptedValue(TMAPIFeature.NOTATION_URI, false); - _setFeatureToAcceptedValue(TMAPIFeature.XTM_1_0, false); - _setFeatureToUnacceptedValue(TMAPIFeature.XTM_1_0, true); - _setFeatureToAcceptedValue(TMAPIFeature.XTM_1_1, true); - _setFeatureToUnacceptedValue(TMAPIFeature.XTM_1_1, false); - _setFeatureToAcceptedValue(TMAPIFeature.READ_ONLY, false); - _setFeatureToUnacceptedValue(TMAPIFeature.READ_ONLY, true); - _setFeatureToAcceptedValue(TMAPIFeature.AUTOMERGE, false); - _setFeatureToUnacceptedValue(TMAPIFeature.AUTOMERGE, true); - _setFeatureToAcceptedValue(TMAPIFeature.TNC, false); - _setFeatureToUnacceptedValue(TMAPIFeature.TNC, true); - } - - /** - * Tests if an unknown feature throws the expected exception. - * - * @throws Exception - */ - public void testUnrecognizedFeature() throws Exception { - try { - String unknownFeatureName = "http://www.semagia.com/tinyTiM/unknownTMAPIFeature"; - _sysFactory.setFeature(unknownFeatureName, true); - fail("Expected an exception while setting a unknown feature"); - } - catch (FeatureNotRecognizedException ex) { - // noop. - } - } - - /** - * Tests if the collection factory property is set. - * - * @throws Exception - */ - public void testCollectionFactoryProperty() throws Exception { - boolean troveAvailable = false; - try { - Class.forName("gnu.trove.THashSet"); - troveAvailable = true; - } - catch (Exception ex) { - // noop. - } - if (troveAvailable) { - assertEquals("org.tinytim.TroveCollectionFactory", _sysFactory.getProperty(Property.COLLECTION_FACTORY)); - } - else { - assertEquals("org.tinytim.JavaCollectionFactory", _sysFactory.getProperty(Property.COLLECTION_FACTORY)); - assertTrue(((TopicMapSystemImpl) _sysFactory.newTopicMapSystem()).getCollectionFactory() instanceof JavaCollectionFactory); - } - } - - /** - * Tests if the TopicMapSystemFactory creates automatically a default - * CollectionFactory iff the class name in the property is invaild / - * not resolvable. - * ... [truncated message content] |