From: <lh...@us...> - 2008-08-20 11:26:21
|
Revision: 66 http://tmapi.svn.sourceforge.net/tmapi/?rev=66&view=rev Author: lheuer Date: 2008-08-20 11:26:30 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Updated test suite Modified Paths: -------------- trunk/src/test/java/org/tmapi/core/AllCoreTests.java trunk/src/test/java/org/tmapi/core/TMAPITestCase.java trunk/src/test/java/org/tmapi/core/TestOccurrence.java trunk/src/test/java/org/tmapi/core/TestTopicMapSystem.java trunk/src/test/java/org/tmapi/core/TestVariant.java trunk/src/test/java/org/tmapi/index/TestScopedIndex.java Added Paths: ----------- trunk/src/test/java/org/tmapi/core/AbstractTestDatatypeAware.java trunk/src/test/java/org/tmapi/core/AbstractTestTopicMergeDetection.java trunk/src/test/java/org/tmapi/core/TestTopicMapSystemFactory.java trunk/src/test/java/org/tmapi/core/TestTopicMergeDetectionAutomergeDisabled.java trunk/src/test/java/org/tmapi/core/TestTopicMergeDetectionAutomergeEnabled.java trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryA.java trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryB.java trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryC.java trunk/src/test/java/org/tmapi/core/TopicMapSystenFactoryTestBase.java trunk/src/test/java/org/tmapi/core/org.tmapi.core.TopicMapSystemFactory Removed Paths: ------------- trunk/src/test/java/org/tmapi/core/TestTopicMergeDetection.java Added: trunk/src/test/java/org/tmapi/core/AbstractTestDatatypeAware.java =================================================================== --- trunk/src/test/java/org/tmapi/core/AbstractTestDatatypeAware.java (rev 0) +++ trunk/src/test/java/org/tmapi/core/AbstractTestDatatypeAware.java 2008-08-20 11:26:30 UTC (rev 66) @@ -0,0 +1,360 @@ +/* + * The Topic Maps API (TMAPI) was created collectively by + * the membership of the tmapi-discuss mailing list + * <http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss>, + * is hereby released into the public domain; and comes with + * NO WARRANTY. + * + * No one owns TMAPI: you may use it freely in both commercial and + * non-commercial applications, bundle it with your software + * distribution, include it on a CD-ROM, list the source code in a + * book, mirror the documentation at your own web site, or use it in + * any other way you see fit. + */ +package org.tmapi.core; + +import java.math.BigDecimal; +import java.math.BigInteger; + +/** + * Abstract test against the {@link DatatypeAware} interface. + * + * @author <a href="http://tmapi.org/">The TMAPI Project</a> + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +public abstract class AbstractTestDatatypeAware extends TMAPITestCase { + + protected static final String _XSD = "http://www.w3.org/2001/XMLSchema#"; + protected static final String _XSD_STRING = _XSD + "string"; + protected static final String _XSD_INTEGER = _XSD + "integer"; + protected static final String _XSD_INT = _XSD + "int"; + protected static final String _XSD_FLOAT = _XSD + "float"; + protected static final String _XSD_DECIMAL = _XSD + "decimal"; + protected static final String _XSD_LONG = _XSD + "long"; + protected static final String _XSD_ANY_URI = _XSD + "anyURI"; + + protected Locator _xsdString; + protected Locator _xsdInteger; + protected Locator _xsdInt; + protected Locator _xsdFloat; + protected Locator _xsdDecimal; + protected Locator _xsdLong; + protected Locator _xsdAnyURI; + + public AbstractTestDatatypeAware(String name) { + super(name); + } + + /** + * Returns a {@link DatatypeAware} instance to run the tests against. + * + * @return A {@link DatatypeAware} instance. + */ + protected abstract DatatypeAware getDatatypeAware(); + + /* (non-Javadoc) + * @see org.tmapi.core.TMAPITestCase#setUp() + */ + @Override + protected void setUp() throws Exception { + super.setUp(); + _xsdString = createLocator(_XSD_STRING); + _xsdInteger = createLocator(_XSD_INTEGER); + _xsdInt = createLocator(_XSD_INT); + _xsdFloat = createLocator(_XSD_FLOAT); + _xsdDecimal = createLocator(_XSD_DECIMAL); + _xsdLong = createLocator(_XSD_LONG); + _xsdAnyURI = createLocator(_XSD_ANY_URI); + } + + public void testString() { + final DatatypeAware dt = getDatatypeAware(); + final String value = "a string"; + dt.setValue(value); + assertEquals(value, dt.getValue()); + assertEquals(_xsdString, dt.getDatatype()); + assertFailInteger(dt); + assertFailInt(dt); + assertFailFloat(dt); + assertFailLong(dt); + assertFailDecimal(dt); + } + + public void testStringExplicit() { + final DatatypeAware dt = getDatatypeAware(); + final String value = "a string"; + dt.setValue(value, _xsdString); + assertEquals(value, dt.getValue()); + assertEquals(_xsdString, dt.getDatatype()); + assertFailInteger(dt); + assertFailInt(dt); + assertFailFloat(dt); + assertFailLong(dt); + assertFailDecimal(dt); + } + + public void testURI() { + final DatatypeAware dt = getDatatypeAware(); + final String iri = "http://www.example.org/"; + final Locator value = createLocator(iri); + dt.setValue(value); + assertEquals(iri, dt.getValue()); + assertEquals(_xsdAnyURI, dt.getDatatype()); + assertEquals(value, dt.locatorValue()); + assertFailInteger(dt); + assertFailInt(dt); + assertFailFloat(dt); + assertFailLong(dt); + assertFailDecimal(dt); + } + + public void testURIExplicit() { + final DatatypeAware dt = getDatatypeAware(); + final String iri = "http://www.example.org/"; + final Locator value = createLocator(iri); + dt.setValue(iri, _xsdAnyURI); + assertEquals(iri, dt.getValue()); + assertEquals(_xsdAnyURI, dt.getDatatype()); + assertEquals(value, dt.locatorValue()); + assertFailInteger(dt); + assertFailInt(dt); + assertFailFloat(dt); + assertFailLong(dt); + assertFailDecimal(dt); + } + + public void testInteger() { + final BigInteger value = BigInteger.TEN; + final DatatypeAware dt = getDatatypeAware(); + dt.setValue(value); + assertEquals(value.toString(), dt.getValue()); + assertEquals(_xsdInteger, dt.getDatatype()); + assertEquals(value, dt.integerValue()); + assertEquals(BigDecimal.TEN, dt.decimalValue()); + assertEquals(10L, dt.longValue()); + assertEquals(10, dt.intValue()); + assertEquals(10.0F, dt.floatValue()); + } + + public void testIntegerExplicit() { + final BigInteger value = BigInteger.TEN; + final DatatypeAware dt = getDatatypeAware(); + dt.setValue(value.toString(), _xsdInteger); + assertEquals(value.toString(), dt.getValue()); + assertEquals(_xsdInteger, dt.getDatatype()); + assertEquals(value, dt.integerValue()); + assertEquals(BigDecimal.TEN, dt.decimalValue()); + assertEquals(10L, dt.longValue()); + assertEquals(10, dt.intValue()); + assertEquals(10.0F, dt.floatValue()); + } + + public void testDecimal() { + final BigDecimal value = BigDecimal.TEN; + final DatatypeAware dt = getDatatypeAware(); + dt.setValue(value); + assertEquals(value.toString(), dt.getValue()); + assertEquals(_xsdDecimal, dt.getDatatype()); + assertEquals(value, dt.decimalValue()); + assertEquals(BigInteger.TEN, dt.integerValue()); + assertEquals(10L, dt.longValue()); + assertEquals(10, dt.intValue()); + assertEquals(10.0F, dt.floatValue()); + } + + public void testDecimalExplicit() { + final BigDecimal value = BigDecimal.TEN; + final DatatypeAware dt = getDatatypeAware(); + dt.setValue(value.toString(), _xsdDecimal); + assertEquals(value.toString(), dt.getValue()); + assertEquals(_xsdDecimal, dt.getDatatype()); + assertEquals(value, dt.decimalValue()); + assertEquals(BigInteger.TEN, dt.integerValue()); + assertEquals(10L, dt.longValue()); + assertEquals(10, dt.intValue()); + assertEquals(10.0F, dt.floatValue()); + } + + public void testInt() { + final int value = 1976; + final String strValue = "1976"; + final DatatypeAware dt = getDatatypeAware(); + dt.setValue(value); + assertEquals(strValue, dt.getValue()); + assertEquals(_xsdInt, dt.getDatatype()); + assertEquals(new BigDecimal(value), dt.decimalValue()); + assertEquals(new BigInteger(strValue), dt.integerValue()); + assertEquals(1976L, dt.longValue()); + assertEquals(1976, dt.intValue()); + assertEquals(1976.0F, dt.floatValue()); + } + + public void testLong() { + final long value = 1976L; + final String strValue = "1976"; + final DatatypeAware dt = getDatatypeAware(); + dt.setValue(value); + assertEquals(strValue, dt.getValue()); + assertEquals(_xsdLong, dt.getDatatype()); + assertEquals(new BigDecimal(value), dt.decimalValue()); + assertEquals(new BigInteger(strValue), dt.integerValue()); + assertEquals(value, dt.longValue()); + assertEquals(1976, dt.intValue()); + assertEquals(1976.0F, dt.floatValue()); + } + + public void testFloat() { + final float value = 1976.0F; + final String strValue = "1976.0"; + final DatatypeAware dt = getDatatypeAware(); + dt.setValue(value); + assertEquals(strValue, dt.getValue()); + assertEquals(_xsdFloat, dt.getDatatype()); + assertEquals(new BigDecimal(strValue), dt.decimalValue()); + assertFailInteger(dt); + assertFailLong(dt); + assertFailInt(dt); + assertEquals(value, dt.floatValue()); + } + + public void testUserDatatype() { + final Locator datatype = createLocator("http://www.example.org/datatype"); + final DatatypeAware dt = getDatatypeAware(); + final String value = "Value"; + dt.setValue(value, datatype); + assertEquals(datatype, dt.getDatatype()); + assertEquals(value, dt.getValue()); + assertFailInteger(dt); + assertFailInt(dt); + assertFailFloat(dt); + assertFailLong(dt); + assertFailDecimal(dt); + } + + public void testIllegalDatatype() { + final DatatypeAware dt = getDatatypeAware(); + try { + dt.setValue("value", null); + fail("datatypeAware.setValue(\"value\", null) is illegal"); + } + catch (ModelConstraintException ex) { + // noop. + } + } + + public void testIllegalStringValue() { + final DatatypeAware dt = getDatatypeAware(); + try { + dt.setValue((String)null); + fail("datatypeAware.setValue((String)null) is illegal"); + } + catch (ModelConstraintException ex) { + // noop. + } + } + + public void testIllegalStringValueExplicit() { + final DatatypeAware dt = getDatatypeAware(); + try { + dt.setValue(null, _xsdString); + fail("datatypeAware.setValue(null, datatype) is illegal"); + } + catch (ModelConstraintException ex) { + // noop. + } + } + + public void testIllegalLocatorValue() { + final DatatypeAware dt = getDatatypeAware(); + try { + dt.setValue((Locator)null); + fail("datatypeAware.setValue((Locator)null) is illegal"); + } + catch (ModelConstraintException ex) { + // noop. + } + } + + public void testIllegalIntegerValue() { + final DatatypeAware dt = getDatatypeAware(); + try { + dt.setValue((BigInteger)null); + fail("datatypeAware.setValue((BigInteger)null) is illegal"); + } + catch (ModelConstraintException ex) { + // noop. + } + } + + public void testIllegalDecimalValue() { + final DatatypeAware dt = getDatatypeAware(); + try { + dt.setValue((BigDecimal)null); + fail("datatypeAware.setValue((BigDecimal)null) is illegal"); + } + catch (ModelConstraintException ex) { + // noop. + } + } + + protected void assertFailInteger(final DatatypeAware dt) { + try { + dt.integerValue(); + fail("Expected a failure for converting the value to 'BigInteger'"); + } + catch (NumberFormatException ex) { + // noop. + } + } + + protected void assertFailInt(final DatatypeAware dt) { + try { + dt.intValue(); + fail("Expected a failure for converting the value to 'int'"); + } + catch (NumberFormatException ex) { + // noop. + } + } + + protected void assertFailFloat(final DatatypeAware dt) { + try { + dt.floatValue(); + fail("Expected a failure for converting the value to 'float'"); + } + catch (NumberFormatException ex) { + // noop. + } + } + + protected void assertFailDecimal(final DatatypeAware dt) { + try { + dt.decimalValue(); + fail("Expected a failure for converting the value to 'BigDecimal'"); + } + catch (NumberFormatException ex) { + // noop. + } + } + + protected void assertFailLong(final DatatypeAware dt) { + try { + dt.longValue(); + fail("Expected a failure for converting the value to 'long'"); + } + catch (NumberFormatException ex) { + // noop. + } + } + + protected void assertFailLocator(final DatatypeAware dt) { + try { + dt.locatorValue(); + fail("Expected a failure for converting the value to 'Locator'"); + } + catch (IllegalArgumentException ex) { + // noop. + } + } +} Property changes on: trunk/src/test/java/org/tmapi/core/AbstractTestDatatypeAware.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: trunk/src/test/java/org/tmapi/core/AbstractTestTopicMergeDetection.java =================================================================== --- trunk/src/test/java/org/tmapi/core/AbstractTestTopicMergeDetection.java (rev 0) +++ trunk/src/test/java/org/tmapi/core/AbstractTestTopicMergeDetection.java 2008-08-20 11:26:30 UTC (rev 66) @@ -0,0 +1,248 @@ +/* + * The Topic Maps API (TMAPI) was created collectively by + * the membership of the tmapi-discuss mailing list + * <http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss>, + * is hereby released into the public domain; and comes with + * NO WARRANTY. + * + * No one owns TMAPI: you may use it freely in both commercial and + * non-commercial applications, bundle it with your software + * distribution, include it on a CD-ROM, list the source code in a + * book, mirror the documentation at your own web site, or use it in + * any other way you see fit. + */ +package org.tmapi.core; + +/** + * Tests if merging situations are detected. + * + * @author <a href="http://tmapi.org/">The TMAPI Project</a> + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev$ - $Date$ + */ +public abstract class AbstractTestTopicMergeDetection extends TMAPITestCase { + + private boolean _automerge; + + public AbstractTestTopicMergeDetection(String name) { + super(name); + } + + protected abstract boolean getAutomergeEnabled(); + + /* (non-Javadoc) + * @see org.tmapi.core.TMAPITestCase#setUp() + */ + @Override + protected void setUp() throws Exception { + TopicMapSystemFactory factory = TopicMapSystemFactory.newInstance(); + //bad hack to copy all System.Properties to factory + for (Object obj: System.getProperties().keySet()) { + String key = (String) obj; + factory.setProperty(key, System.getProperty(key)); + } + try { + factory.setFeature("http://tmapi.org/features/automerge", getAutomergeEnabled()); + _automerge = getAutomergeEnabled(); + } + catch (Exception ex) { + _automerge = !getAutomergeEnabled(); + } + _sys = factory.newTopicMapSystem(); + removeAllMaps(); // Seems to be unnecessary, but who knows + _defaultLocator = _sys.createLocator(_DEFAULT_ADDRESS); + _tm = _sys.createTopicMap(_defaultLocator); + } + + /** + * Tests if adding a duplicate subject identifier is detected. + */ + public void testExistingSubjectIdentifier() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + assertEquals(2, _tm.getTopics().size()); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addSubjectIdentifier(loc); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); + try { + topic2.addSubjectIdentifier(loc); + if (!_automerge) { + fail("The duplicate subject identifier '" + loc + "' is not detected"); + } + else { + assertEquals(1, _tm.getTopics().size()); + } + } + catch (IdentityConstraintException ex) { + if (_automerge) { + fail("Expected that the duplicate subject identifier causes a transparent merge"); + } + assertEquals(2, _tm.getTopics().size()); + assertEquals(2, _tm.getTopics().size()); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertFalse(topic2.getSubjectIdentifiers().contains(loc)); + } + } + + /** + * Tests if adding a duplicate subject identifier on the SAME topic is ignored. + */ + public void testExistingSubjectIdentifierLegal() { + Topic topic1 = _tm.createTopic(); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addSubjectIdentifier(loc); + assertEquals(1, topic1.getSubjectIdentifiers().size()); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); + topic1.addSubjectIdentifier(loc); + assertEquals(1, topic1.getSubjectIdentifiers().size()); + } + + /** + * Tests if adding a duplicate subject locator is detected. + */ + public void testExistingSubjectLocator() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + assertEquals(2, _tm.getTopics().size()); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addSubjectLocator(loc); + assertTrue(topic1.getSubjectLocators().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectLocator(loc)); + try { + topic2.addSubjectLocator(loc); + if (!_automerge) { + fail("The duplicate subject locator '" + loc + "' is not detected"); + } + else { + assertEquals(1, _tm.getTopics().size()); + } + } + catch (IdentityConstraintException ex) { + if (_automerge) { + fail("Expected that the duplicate subject locator causes a transparent merge"); + } + assertEquals(2, _tm.getTopics().size()); + assertEquals(2, _tm.getTopics().size()); + assertTrue(topic1.getSubjectLocators().contains(loc)); + assertFalse(topic2.getSubjectLocators().contains(loc)); + } + } + + /** + * Tests if adding a duplicate subject locator at the SAME topic is ignored. + */ + public void testExistingSubjectLocatorLegal() { + Topic topic1 = _tm.createTopic(); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addSubjectLocator(loc); + assertEquals(1, topic1.getSubjectLocators().size()); + assertTrue(topic1.getSubjectLocators().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectLocator(loc)); + topic1.addSubjectLocator(loc); + assertEquals(1, topic1.getSubjectLocators().size()); + } + + /** + * Tests if adding an item identifier equals to a subject identifier is detected. + */ + public void testExistingSubjectIdentifierAddItemIdentifier() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + assertEquals(2, _tm.getTopics().size()); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addSubjectIdentifier(loc); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); + try { + topic2.addItemIdentifier(loc); + if (!_automerge) { + fail("A topic with a subject identifier equals to the item identifier '" + loc + "' exists."); + } + else { + assertEquals(1, _tm.getTopics().size()); + } + } + catch (IdentityConstraintException ex) { + if (_automerge) { + fail("Expected that the duplicate item identifier causes a transparent merge"); + } + assertEquals(2, _tm.getTopics().size()); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertFalse(topic2.getItemIdentifiers().contains(loc)); + } + } + + /** + * Tests if adding an item identifier equals to a subject identifier + * on the SAME topic is accepted + */ + public void testExistingSubjectIdentifierAddItemIdentifierLegal() { + final Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + final Topic topic1 = _tm.createTopicBySubjectIdentifier(loc); + assertEquals(1, topic1.getSubjectIdentifiers().size()); + assertEquals(0, topic1.getItemIdentifiers().size()); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); + assertNull(_tm.getConstructByItemIdentifier(loc)); + topic1.addItemIdentifier(loc); + assertEquals(1, topic1.getSubjectIdentifiers().size()); + assertEquals(1, topic1.getItemIdentifiers().size()); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertTrue(topic1.getItemIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); + assertEquals(topic1, _tm.getConstructByItemIdentifier(loc)); + } + + /** + * Tests if adding a subject identifier equals to an item identifier is detected. + */ + public void testExistingItemIdentifierAddSubjectIdentifier() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + assertEquals(2, _tm.getTopics().size()); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addItemIdentifier(loc); + assertTrue(topic1.getItemIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getConstructByItemIdentifier(loc)); + try { + topic2.addSubjectIdentifier(loc); + if (!_automerge) { + fail("A topic with an item identifier equals to the subject identifier '" + loc + "' exists."); + } + else { + assertEquals(1, _tm.getTopics().size()); + } + } + catch (IdentityConstraintException ex) { + if (_automerge) { + fail("Expected a transparent merge for a topic with an item identifier equals to the subject identifier '" + loc + "'."); + } + assertEquals(2, _tm.getTopics().size()); + assertTrue(topic1.getItemIdentifiers().contains(loc)); + assertFalse(topic2.getSubjectIdentifiers().contains(loc)); + } + } + + /** + * Tests if adding a subject identifier equals to an item identifier + * on the SAME topic is accepted + */ + public void testExistingItemIdentifierAddSubjectIdentifierLegal() { + final Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + final Topic topic1 = _tm.createTopicByItemIdentifier(loc); + assertEquals(1, topic1.getItemIdentifiers().size()); + assertEquals(0, topic1.getSubjectIdentifiers().size()); + assertTrue(topic1.getItemIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getConstructByItemIdentifier(loc)); + assertNull(_tm.getTopicBySubjectIdentifier(loc)); + topic1.addSubjectIdentifier(loc); + assertEquals(1, topic1.getSubjectIdentifiers().size()); + assertEquals(1, topic1.getItemIdentifiers().size()); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertTrue(topic1.getItemIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); + assertEquals(topic1, _tm.getConstructByItemIdentifier(loc)); + } +} Property changes on: trunk/src/test/java/org/tmapi/core/AbstractTestTopicMergeDetection.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Modified: trunk/src/test/java/org/tmapi/core/AllCoreTests.java =================================================================== --- trunk/src/test/java/org/tmapi/core/AllCoreTests.java 2008-08-19 11:14:19 UTC (rev 65) +++ trunk/src/test/java/org/tmapi/core/AllCoreTests.java 2008-08-20 11:26:30 UTC (rev 66) @@ -37,7 +37,8 @@ suite.addTestSuite(TestLocator.class); suite.addTestSuite(TestTopicMerge.class); suite.addTestSuite(TestTopicMapMerge.class); - suite.addTestSuite(TestTopicMergeDetection.class); + suite.addTestSuite(TestTopicMergeDetectionAutomergeEnabled.class); + suite.addTestSuite(TestTopicMergeDetectionAutomergeDisabled.class); suite.addTestSuite(TestTopicMapSystem.class); suite.addTestSuite(TestConstruct.class); Modified: trunk/src/test/java/org/tmapi/core/TMAPITestCase.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TMAPITestCase.java 2008-08-19 11:14:19 UTC (rev 65) +++ trunk/src/test/java/org/tmapi/core/TMAPITestCase.java 2008-08-20 11:26:30 UTC (rev 66) @@ -58,7 +58,6 @@ */ protected TopicMap _tm; - public TMAPITestCase(String name) { super(name); } Modified: trunk/src/test/java/org/tmapi/core/TestOccurrence.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TestOccurrence.java 2008-08-19 11:14:19 UTC (rev 65) +++ trunk/src/test/java/org/tmapi/core/TestOccurrence.java 2008-08-20 11:26:30 UTC (rev 66) @@ -20,7 +20,7 @@ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -public class TestOccurrence extends TestDatatypeAware { +public class TestOccurrence extends AbstractTestDatatypeAware { public TestOccurrence(String name) { super(name); Modified: trunk/src/test/java/org/tmapi/core/TestTopicMapSystem.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TestTopicMapSystem.java 2008-08-19 11:14:19 UTC (rev 65) +++ trunk/src/test/java/org/tmapi/core/TestTopicMapSystem.java 2008-08-20 11:26:30 UTC (rev 66) @@ -64,6 +64,12 @@ removeTopicMap(tm3); assertEquals("Expected locator set size to decrement for the topic map sytem", tmcount-1, _sys.getLocators().size()); - } + } + public void testLocatorCreation() { + final String ref = "http://www.tmapi.org/"; + final Locator loc = _sys.createLocator(ref); + assertEquals(ref, loc.getReference()); + } + } Added: trunk/src/test/java/org/tmapi/core/TestTopicMapSystemFactory.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TestTopicMapSystemFactory.java (rev 0) +++ trunk/src/test/java/org/tmapi/core/TestTopicMapSystemFactory.java 2008-08-20 11:26:30 UTC (rev 66) @@ -0,0 +1,91 @@ +/* + * The Topic Maps API (TMAPI) was created collectively by + * the membership of the tmapi-discuss mailing list + * <http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss>, + * is hereby released into the public domain; and comes with + * NO WARRANTY. + * + * No one owns TMAPI: you may use it freely in both commercial and + * non-commercial applications, bundle it with your software + * distribution, include it on a CD-ROM, list the source code in a + * book, mirror the documentation at your own web site, or use it in + * any other way you see fit. + */ +package org.tmapi.core; + +import java.io.File; +import java.io.FileWriter; +import java.io.Writer; + +import junit.framework.TestCase; + +import org.tmapi.core.TopicMapSystemFactory; + +/** + * Tests against the {@link TopicMapSystemFactory}. + * + * @author <a href="http://tmapi.org/">The TMAPI Project</a> + * @author Kal Ahmed + * @version $Rev:$ - $Date:$ + */ +public class TestTopicMapSystemFactory extends TestCase { + + /** + * Constructor for TopicMapSystemFactoryTest. + * + * @param arg0 + */ + public TestTopicMapSystemFactory(String arg0) { + super(arg0); + } + + public static void main(String[] args) { + junit.textui.TestRunner.run(TestTopicMapSystemFactory.class); + } + + public void testReadFromSystemProperty() throws Exception { + System.setProperty("org.tmapi.core.TopicMapSystemFactory", + TopicMapSystemFactoryA.class.getName()); + TopicMapSystemFactory factory = TopicMapSystemFactory.newInstance(); + assertNotNull(factory); + assertTrue(factory instanceof TopicMapSystemFactoryA); + } + + public void testReadFromRuntimeProperty() throws Exception { + System.getProperties().remove("org.tmapi.core.TopicMapSystemFactory"); + File javaHome = new File(System.getProperty("java.home")); + File propsFile = new File(javaHome, "lib" + File.separator + + "tmapi.properties"); + File tmpPropsFile = new File(javaHome, "lib" + File.pathSeparator + + "tmapi.properties.tmp"); + boolean restoreProps = false; + if (propsFile.exists()) { + propsFile.renameTo(tmpPropsFile); + restoreProps = true; + } + try { + Writer writer = new FileWriter(propsFile); + writer.write(TopicMapSystemFactory.class.getName() + "=" + + TopicMapSystemFactoryB.class.getName()); + writer.close(); + + TopicMapSystemFactory factory = TopicMapSystemFactory.newInstance(); + boolean deleted = propsFile.delete(); + assertTrue(deleted); + assertNotNull(factory); + assertTrue(factory instanceof TopicMapSystemFactoryB); + } + finally { + if (restoreProps) { + tmpPropsFile.renameTo(propsFile); + } + } + } + + public void testReadFromResource() throws Exception { + TopicMapSystemFactory factory = TopicMapSystemFactory.newInstance(); + assertNotNull(factory); + assertTrue(factory instanceof TopicMapSystemFactoryC); + } + +} Property changes on: trunk/src/test/java/org/tmapi/core/TestTopicMapSystemFactory.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Deleted: trunk/src/test/java/org/tmapi/core/TestTopicMergeDetection.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TestTopicMergeDetection.java 2008-08-19 11:14:19 UTC (rev 65) +++ trunk/src/test/java/org/tmapi/core/TestTopicMergeDetection.java 2008-08-20 11:26:30 UTC (rev 66) @@ -1,176 +0,0 @@ -/* - * The Topic Maps API (TMAPI) was created collectively by - * the membership of the tmapi-discuss mailing list - * <http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss>, - * is hereby released into the public domain; and comes with - * NO WARRANTY. - * - * No one owns TMAPI: you may use it freely in both commercial and - * non-commercial applications, bundle it with your software - * distribution, include it on a CD-ROM, list the source code in a - * book, mirror the documentation at your own web site, or use it in - * any other way you see fit. - */ -package org.tmapi.core; - -/** - * Tests if merging situations are detected. - * - * @author <a href="http://tmapi.org/">The TMAPI Project</a> - * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev$ - $Date$ - */ -public class TestTopicMergeDetection extends TMAPITestCase { - - //TODO: Respect feature "automerge"! - - public TestTopicMergeDetection(String name) { - super(name); - } - - /** - * Tests if adding a duplicate subject identifier is detected. - */ - public void testExistingSubjectIdentifier() { - Topic topic1 = _tm.createTopic(); - Topic topic2 = _tm.createTopic(); - Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); - topic1.addSubjectIdentifier(loc); - assertTrue(topic1.getSubjectIdentifiers().contains(loc)); - assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); - try { - topic2.addSubjectIdentifier(loc); - fail("The duplicate subject identifier '" + loc + "' is not detected"); - } - catch (IdentityConstraintException ex) { - // noop. - } - } - - /** - * Tests if adding a duplicate subject identifier on the SAME topic is ignored. - */ - public void testExistingSubjectIdentifierLegal() { - Topic topic1 = _tm.createTopic(); - Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); - topic1.addSubjectIdentifier(loc); - assertEquals(1, topic1.getSubjectIdentifiers().size()); - assertTrue(topic1.getSubjectIdentifiers().contains(loc)); - assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); - topic1.addSubjectIdentifier(loc); - assertEquals(1, topic1.getSubjectIdentifiers().size()); - } - - /** - * Tests if adding a duplicate subject locator is detected. - */ - public void testExistingSubjectLocator() { - Topic topic1 = _tm.createTopic(); - Topic topic2 = _tm.createTopic(); - Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); - topic1.addSubjectLocator(loc); - assertTrue(topic1.getSubjectLocators().contains(loc)); - assertEquals(topic1, _tm.getTopicBySubjectLocator(loc)); - try { - topic2.addSubjectLocator(loc); - fail("The duplicate subject locator '" + loc + "' is not detected"); - } - catch (IdentityConstraintException ex) { - // noop. - } - } - - /** - * Tests if adding a duplicate subject locator at the SAME topic is ignored. - */ - public void testExistingSubjectLocatorLegal() { - Topic topic1 = _tm.createTopic(); - Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); - topic1.addSubjectLocator(loc); - assertEquals(1, topic1.getSubjectLocators().size()); - assertTrue(topic1.getSubjectLocators().contains(loc)); - assertEquals(topic1, _tm.getTopicBySubjectLocator(loc)); - topic1.addSubjectLocator(loc); - assertEquals(1, topic1.getSubjectLocators().size()); - } - - /** - * Tests if adding an item identifier equals to a subject identifier is detected. - */ - public void testExistingSubjectIdentifierAddItemIdentifier() { - Topic topic1 = _tm.createTopic(); - Topic topic2 = _tm.createTopic(); - Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); - topic1.addSubjectIdentifier(loc); - assertTrue(topic1.getSubjectIdentifiers().contains(loc)); - assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); - try { - topic2.addItemIdentifier(loc); - fail("A topic with a subject identifier equals to the item identifier '" + loc + "' exists."); - } - catch (IdentityConstraintException ex) { - // noop. - } - } - - /** - * Tests if adding an item identifier equals to a subject identifier - * on the SAME topic is accepted - */ - public void testExistingSubjectIdentifierAddItemIdentifierLegal() { - final Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); - final Topic topic1 = _tm.createTopicBySubjectIdentifier(loc); - assertEquals(1, topic1.getSubjectIdentifiers().size()); - assertEquals(0, topic1.getItemIdentifiers().size()); - assertTrue(topic1.getSubjectIdentifiers().contains(loc)); - assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); - assertNull(_tm.getConstructByItemIdentifier(loc)); - topic1.addItemIdentifier(loc); - assertEquals(1, topic1.getSubjectIdentifiers().size()); - assertEquals(1, topic1.getItemIdentifiers().size()); - assertTrue(topic1.getSubjectIdentifiers().contains(loc)); - assertTrue(topic1.getItemIdentifiers().contains(loc)); - assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); - assertEquals(topic1, _tm.getConstructByItemIdentifier(loc)); - } - - /** - * Tests if adding a subject identifier equals to an item identifier is detected. - */ - public void testExistingItemIdentifierAddSubjectIdentifier() { - Topic topic1 = _tm.createTopic(); - Topic topic2 = _tm.createTopic(); - Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); - topic1.addItemIdentifier(loc); - assertTrue(topic1.getItemIdentifiers().contains(loc)); - assertEquals(topic1, _tm.getConstructByItemIdentifier(loc)); - try { - topic2.addSubjectIdentifier(loc); - fail("A topic with an item identifier equals to the subject identifier '" + loc + "' exists."); - } - catch (IdentityConstraintException ex) { - // noop. - } - } - - /** - * Tests if adding a subject identifier equals to an item identifier - * on the SAME topic is accepted - */ - public void testExistingItemIdentifierAddSubjectIdentifierLegal() { - final Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); - final Topic topic1 = _tm.createTopicByItemIdentifier(loc); - assertEquals(1, topic1.getItemIdentifiers().size()); - assertEquals(0, topic1.getSubjectIdentifiers().size()); - assertTrue(topic1.getItemIdentifiers().contains(loc)); - assertEquals(topic1, _tm.getConstructByItemIdentifier(loc)); - assertNull(_tm.getTopicBySubjectIdentifier(loc)); - topic1.addSubjectIdentifier(loc); - assertEquals(1, topic1.getSubjectIdentifiers().size()); - assertEquals(1, topic1.getItemIdentifiers().size()); - assertTrue(topic1.getSubjectIdentifiers().contains(loc)); - assertTrue(topic1.getItemIdentifiers().contains(loc)); - assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); - assertEquals(topic1, _tm.getConstructByItemIdentifier(loc)); - } -} Added: trunk/src/test/java/org/tmapi/core/TestTopicMergeDetectionAutomergeDisabled.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TestTopicMergeDetectionAutomergeDisabled.java (rev 0) +++ trunk/src/test/java/org/tmapi/core/TestTopicMergeDetectionAutomergeDisabled.java 2008-08-20 11:26:30 UTC (rev 66) @@ -0,0 +1,37 @@ +/* + * The Topic Maps API (TMAPI) was created collectively by + * the membership of the tmapi-discuss mailing list + * <http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss>, + * is hereby released into the public domain; and comes with + * NO WARRANTY. + * + * No one owns TMAPI: you may use it freely in both commercial and + * non-commercial applications, bundle it with your software + * distribution, include it on a CD-ROM, list the source code in a + * book, mirror the documentation at your own web site, or use it in + * any other way you see fit. + */ +package org.tmapi.core; + +/** + * Tests merge detection with feature "automerge" disabled. + * + * @author <a href="http://tmapi.org/">The TMAPI Project</a> + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestTopicMergeDetectionAutomergeDisabled extends AbstractTestTopicMergeDetection { + + public TestTopicMergeDetectionAutomergeDisabled(String name) { + super(name); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TestTopicMergeDetection#getAutomergeEnabled() + */ + @Override + protected boolean getAutomergeEnabled() { + return false; + } + +} Property changes on: trunk/src/test/java/org/tmapi/core/TestTopicMergeDetectionAutomergeDisabled.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: trunk/src/test/java/org/tmapi/core/TestTopicMergeDetectionAutomergeEnabled.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TestTopicMergeDetectionAutomergeEnabled.java (rev 0) +++ trunk/src/test/java/org/tmapi/core/TestTopicMergeDetectionAutomergeEnabled.java 2008-08-20 11:26:30 UTC (rev 66) @@ -0,0 +1,37 @@ +/* + * The Topic Maps API (TMAPI) was created collectively by + * the membership of the tmapi-discuss mailing list + * <http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss>, + * is hereby released into the public domain; and comes with + * NO WARRANTY. + * + * No one owns TMAPI: you may use it freely in both commercial and + * non-commercial applications, bundle it with your software + * distribution, include it on a CD-ROM, list the source code in a + * book, mirror the documentation at your own web site, or use it in + * any other way you see fit. + */ +package org.tmapi.core; + +/** + * Tests merge detection with feature "automerge" enabled. + * + * @author <a href="http://tmapi.org/">The TMAPI Project</a> + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestTopicMergeDetectionAutomergeEnabled extends AbstractTestTopicMergeDetection { + + public TestTopicMergeDetectionAutomergeEnabled(String name) { + super(name); + } + + /* (non-Javadoc) + * @see org.tmapi.core.TestTopicMergeDetection#getAutomergeEnabled() + */ + @Override + protected boolean getAutomergeEnabled() { + return true; + } + +} Property changes on: trunk/src/test/java/org/tmapi/core/TestTopicMergeDetectionAutomergeEnabled.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Modified: trunk/src/test/java/org/tmapi/core/TestVariant.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TestVariant.java 2008-08-19 11:14:19 UTC (rev 65) +++ trunk/src/test/java/org/tmapi/core/TestVariant.java 2008-08-20 11:26:30 UTC (rev 66) @@ -20,7 +20,7 @@ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -public class TestVariant extends TestDatatypeAware { +public class TestVariant extends AbstractTestDatatypeAware { public TestVariant(String name) { super(name); Added: trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryA.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryA.java (rev 0) +++ trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryA.java 2008-08-20 11:26:30 UTC (rev 66) @@ -0,0 +1,27 @@ +/* + * The Topic Maps API (TMAPI) was created collectively by + * the membership of the tmapi-discuss mailing list + * <http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss>, + * is hereby released into the public domain; and comes with + * NO WARRANTY. + * + * No one owns TMAPI: you may use it freely in both commercial and + * non-commercial applications, bundle it with your software + * distribution, include it on a CD-ROM, list the source code in a + * book, mirror the documentation at your own web site, or use it in + * any other way you see fit. + */ +package org.tmapi.core; + +/** + * + * + * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a> + * @author Kal Ahmed + * @version $Rev:$ - $Date:$ + */ +public class TopicMapSystemFactoryA extends TopicMapSystenFactoryTestBase { + + public TopicMapSystemFactoryA() { + } +} \ No newline at end of file Property changes on: trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryA.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryB.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryB.java (rev 0) +++ trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryB.java 2008-08-20 11:26:30 UTC (rev 66) @@ -0,0 +1,27 @@ +/* + * The Topic Maps API (TMAPI) was created collectively by + * the membership of the tmapi-discuss mailing list + * <http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss>, + * is hereby released into the public domain; and comes with + * NO WARRANTY. + * + * No one owns TMAPI: you may use it freely in both commercial and + * non-commercial applications, bundle it with your software + * distribution, include it on a CD-ROM, list the source code in a + * book, mirror the documentation at your own web site, or use it in + * any other way you see fit. + */ +package org.tmapi.core; + +/** + * + * + * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a> + * @author Kal Ahmed + * @version $Rev:$ - $Date:$ + */ +public class TopicMapSystemFactoryB extends TopicMapSystenFactoryTestBase { + + public TopicMapSystemFactoryB() { + } +} \ No newline at end of file Property changes on: trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryB.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryC.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryC.java (rev 0) +++ trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryC.java 2008-08-20 11:26:30 UTC (rev 66) @@ -0,0 +1,29 @@ +/* + * The Topic Maps API (TMAPI) was created collectively by + * the membership of the tmapi-discuss mailing list + * <http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss>, + * is hereby released into the public domain; and comes with + * NO WARRANTY. + * + * No one owns TMAPI: you may use it freely in both commercial and + * non-commercial applications, bundle it with your software + * distribution, include it on a CD-ROM, list the source code in a + * book, mirror the documentation at your own web site, or use it in + * any other way you see fit. + */ +package org.tmapi.core; + +/** + * + * + * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a> + * @author Kal Ahmed + * @version $Rev:$ - $Date:$ + */ +public class TopicMapSystemFactoryC extends TopicMapSystenFactoryTestBase { + /** + * @param TopicMapSystemFactoryTest + */ + public TopicMapSystemFactoryC() { + } +} \ No newline at end of file Property changes on: trunk/src/test/java/org/tmapi/core/TopicMapSystemFactoryC.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: trunk/src/test/java/org/tmapi/core/TopicMapSystenFactoryTestBase.java =================================================================== --- trunk/src/test/java/org/tmapi/core/TopicMapSystenFactoryTestBase.java (rev 0) +++ trunk/src/test/java/org/tmapi/core/TopicMapSystenFactoryTestBase.java 2008-08-20 11:26:30 UTC (rev 66) @@ -0,0 +1,71 @@ +/* + * The Topic Maps API (TMAPI) was created collectively by + * the membership of the tmapi-discuss mailing list + * <http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss>, + * is hereby released into the public domain; and comes with + * NO WARRANTY. + * + * No one owns TMAPI: you may use it freely in both commercial and + * non-commercial applications, bundle it with your software + * distribution, include it on a CD-ROM, list the source code in a + * book, mirror the documentation at your own web site, or use it in + * any other way you see fit. + */ +package org.tmapi.core; + +import org.tmapi.core.TMAPIException; +import org.tmapi.core.TopicMapSystem; +import org.tmapi.core.TopicMapSystemFactory; + +/** + * Base class for all test factories. + * + * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a> + * @author Kal Ahmed + * @version $Rev:$ - $Date:$ + */ +public class TopicMapSystenFactoryTestBase extends TopicMapSystemFactory { + + TopicMapSystenFactoryTestBase() { + // TODO Auto-generated constructor stub + } + + @Override + public boolean getFeature(String featureName) + throws FeatureNotRecognizedException { + // TODO Auto-generated method stub + return false; + } + + @Override + public Object getProperty(String propertyName) { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean hasFeature(String featureName) { + // TODO Auto-generated method stub + return false; + } + + @Override + public TopicMapSystem newTopicMapSystem() throws TMAPIException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setFeature(String featureName, boolean enable) + throws FeatureNotSupportedException, FeatureNotRecognizedException { + // TODO Auto-generated method stub + + } + + @Override + public void setProperty(String propertyName, Object value) { + // TODO Auto-generated method stub + + } + +} \ No newline at end of file Property changes on: trunk/src/test/java/org/tmapi/core/TopicMapSystenFactoryTestBase.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + native Added: trunk/src/test/java/org/tmapi/core/org.tmapi.core.TopicMapSystemFactory =================================================================== --- trunk/src/test/java/org/tmapi/core/org.tmapi.core.TopicMapSystemFactory (rev 0) +++ trunk/src/test/java/org/tmapi/core/org.tmapi.core.TopicMapSystemFactory 2008-08-20 11:26:30 UTC (rev 66) @@ -0,0 +1 @@ +org.tmapi.core.TopicMapSystemFactoryC \ No newline at end of file Modified: trunk/src/test/java/org/tmapi/index/TestScopedIndex.java =================================================================== --- trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-19 11:14:19 UTC (rev 65) +++ trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-20 11:26:30 UTC (rev 66) @@ -90,6 +90,50 @@ assertFalse(_scopedIdx.getAssociationThemes().contains(theme)); } + public void testAssociationMatchAll() { + final Topic theme = createTopic(); + final Topic theme2 = createTopic(); + final Topic unusedTheme = createTopic(); + _updateIndex(); + assertTrue(_scopedIdx.getAssociations(null).isEmpty()); + assertTrue(_scopedIdx.getAssociations(theme).isEmpty()); + assertTrue(_scopedIdx.getAssociationThemes().isEmpty()); + Association scoped = createAssociation(); + assertEquals(0, scoped.getScope().size()); + _updateIndex(); + assertEquals(1, _scopedIdx.getAssociations(null).size()); + assertTrue(_scopedIdx.getAssociations(null).contains(scoped)); + assertFalse(_scopedIdx.getAssociationThemes().contains(theme)); + scoped.addTheme(theme); + _updateIndex(); + assertEquals(1, _scopedIdx.getAssociationThemes().size()); + assertTrue(_scopedIdx.getAssociations(new Topic[]{theme}, true).contains(scoped)); + assertTrue(_scopedIdx.getAssociations(new Topic[]{theme}, false).contains(scoped)); + scoped.addTheme(theme2); + _updateIndex(); + assertEquals(2, _scopedIdx.getAssociationThemes().size()); + assertTrue(_scopedIdx.getAssociations(new Topic[]{theme}, true).contains(scoped)); + assertTrue(_scopedIdx.getAssociations(new Topic[]{theme}, false).contains(scoped)); + assertTrue(_scopedIdx.getAssociations(new Topic[]{theme2}, true).contains(scoped)); + assertTrue(_scopedIdx.getAssociations(new Topic[]{theme2}, false).contains(scoped)); + assertTrue(_scopedIdx.getAssociations(new Topic[]{theme, theme2}, false).contains(scoped)); + assertTrue(_scopedIdx.getAssociations(new Topic[]{theme, theme2}, true).contains(scoped)); + assertTrue(_scopedIdx.getAssociations(new Topic[]{theme, unusedTheme}, false).contains(scoped)); + assertTrue(_scopedIdx.getAssociations(new Topic[]{theme2, unusedTheme}, false).contains(scoped)); + assertFalse(_scopedIdx.getAssociations(new Topic[]{theme, unusedTheme}, true).contains(scoped)); + assertFalse(_scopedIdx.getAssociations(new Topic[]{theme2, unusedTheme}, true).contains(scoped)); + } + + public void testAssociationMatchAllIllegal() { + try { + _scopedIdx.getAssociations(null, true); + fail("getAssociations(null, boolean) is illegal"); + } + catch (IllegalArgumentException ex) { + // noop. + } + } + public void testOccurrence() { Topic theme = createTopic(); _updateIndex(); @@ -117,6 +161,50 @@ assertFalse(_scopedIdx.getOccurrenceThemes().contains(theme)); } + public void testOccurrenceMatchAll() { + final Topic theme = createTopic(); + final Topic theme2 = createTopic(); + final Topic unusedTheme = createTopic(); + _updateIndex(); + assertTrue(_scopedIdx.getOccurrences(null).isEmpty()); + assertTrue(_scopedIdx.getOccurrences(theme).isEmpty()); + assertTrue(_scopedIdx.getOccurrenceThemes().isEmpty()); + final Occurrence scoped = createOccurrence(); + assertEquals(0, scoped.getScope().size()); + _updateIndex(); + assertEquals(1, _scopedIdx.getOccurrences(null).size()); + assertTrue(_scopedIdx.getOccurrences(null).contains(scoped)); + assertFalse(_scopedIdx.getOccurrenceThemes().contains(theme)); + scoped.addTheme(theme); + _updateIndex(); + assertEquals(1, _scopedIdx.getOccurrenceThemes().size()); + assertTrue(_scopedIdx.getOccurrences(new Topic[]{theme}, true).contains(scoped)); + assertTrue(_scopedIdx.getOccurrences(new Topic[]{theme}, false).contains(scoped)); + scoped.addTheme(theme2); + _updateIndex(); + assertEquals(2, _scopedIdx.getOccurrenceThemes().size()); + assertTrue(_scopedIdx.getOccurrences(new Topic[]{theme}, true).contains(scoped)); + assertTrue(_scopedIdx.getOccurrences(new Topic[]{theme}, false).contains(scoped)); + assertTrue(_scopedIdx.getOccurrences(new Topic[]{theme2}, true).contains(scoped)); + assertTrue(_scopedIdx.getOccurrences(new Topic[]{theme2}, false).contains(scoped)); + assertTrue(_scopedIdx.getOccurrences(new Topic[]{theme, theme2}, false).contains(scoped)); + assertTrue(_scopedIdx.getOccurrences(new Topic[]{theme, theme2}, true).contains(scoped)); + assertTrue(_scopedIdx.getOccurrences(new Topic[]{theme, unusedTheme}, false).contains(scoped)); + assertTrue(_scopedIdx.getOccurrences(new Topic[]{theme2, unusedTheme}, false).contains(scoped)); + assertFalse(_scopedIdx.getOccurrences(new Topic[]{theme, unusedTheme}, true).contains(scoped)); + assertFalse(_scopedIdx.getOccurrences(new Topic[]{theme2, unusedTheme}, true).contains(scoped)); + } + + public void testOccurrenceMatchAllIllegal() { + try { + _scopedIdx.getOccurrences(null, true); + fail("getOccurrences(null, boolean) is illegal"); + } + catch (IllegalArgumentException ex) { + // noop. + } + } + public void testName() { Topic theme = createTopic(); _updateIndex(); @@ -167,6 +255,70 @@ assertFalse(_scopedIdx.getNameThemes().contains(theme)); } + public void testNameMatchAll() { + final Topic theme = createTopic(); + final Topic theme2 = createTopic(); + final Topic unusedTheme = createTopic(); + _updateIndex(); + assertTrue(_scopedIdx.getNames(null).isEmpty()); + assertTrue(_scopedIdx.getNames(theme).isEmpty()); + assertTrue(_scopedIdx.getNameThemes().isEmpty()); + final Name scoped = createName(); + assertEquals(0, scoped.getScope().size()); + _updateIndex(); + assertEquals(1, _scopedIdx.getNames(null).size()); + assertTrue(_scopedIdx.getNames(null).contains(scoped)); + assertFalse(_scopedIdx.getNameThemes().contains(theme)); + scoped.addTheme(theme); + _updateIndex(); + assertEquals(1, _scopedIdx.getNameThemes().size()); + assertTrue(_scopedIdx.getNames(new Topic[]{theme}, true).contains(scoped)); + assertTrue(_scopedIdx.getNames(new Topic[]{theme}, false).contains(scoped)); + scoped.addTheme(theme2); + _updateIndex(); + assertEquals(2, _scopedIdx.getNameThemes().size()); + assertTrue(_scopedIdx.getNames(new Topic[]{theme}, true).contains(scoped)); + assertTrue(_scopedIdx.getNames(new Topic[]{theme}, false).contains(scoped)); + assertTrue(_scopedIdx.getNames(new Topic[]{theme2}, true).contains(scoped)); + assertTrue(_scopedIdx.getNames(new Topic[]{theme2}, false).contains(scoped)); + assertTrue(_scopedIdx.getNames(new Topic[]{theme, theme2}, false).contains(scoped)); + assertTrue(_scopedIdx.getNames(new Topic[]{theme, theme2}, true).contains(scoped)); + assertTrue(_scopedIdx.getNames(new Topic[]{theme, unusedTheme}, false).contains(scoped)); + assertTrue(_scopedIdx.getNames(new Topic[]{theme2, unusedTheme}, false).contains(scoped)); + assertFalse(_scopedIdx.getNames(new Topic[]{theme, unusedTheme}, true).contains(scoped)); + assertFalse(_scopedIdx.getNames(new Topic[]{theme2, unusedTheme}, true).contains(scoped)); + } + + public void testNameMatchAllIllegal() { + try { + _scopedIdx.getNames(null, true); + fail("getNames(null, boolean) is illegal"); + } + catch (IllegalArgumentException ex) { + // noop. + } + } + + public void testVariantIllegal() { + try { + _scopedIdx.getVariants(null); + fail("getVariants(null) is illegal"); + } + catch (IllegalArgumentException ex) { + // noop. + } + } + + public void testVariantMatchAllIllegal() { + try { + _scopedIdx.g... [truncated message content] |