You can subscribe to this list here.
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(29) |
Sep
(4) |
Oct
|
Nov
(12) |
Dec
(1) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2009 |
Jan
(1) |
Feb
(4) |
Mar
(4) |
Apr
|
May
(2) |
Jun
(4) |
Jul
(9) |
Aug
(2) |
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2010 |
Jan
(12) |
Feb
(20) |
Mar
(17) |
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(1) |
Sep
(7) |
Oct
|
Nov
|
Dec
|
|
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] |
|
From: <lh...@us...> - 2008-08-19 11:14:10
|
Revision: 65
http://tmapi.svn.sourceforge.net/tmapi/?rev=65&view=rev
Author: lheuer
Date: 2008-08-19 11:14:19 +0000 (Tue, 19 Aug 2008)
Log Message:
-----------
- Added IllegalArgumentException to the index docs
- More variant tests
- More ScopedIndex tests
Modified Paths:
--------------
trunk/src/main/java/org/tmapi/index/LiteralIndex.java
trunk/src/main/java/org/tmapi/index/ScopedIndex.java
trunk/src/test/java/org/tmapi/core/TestReified.java
trunk/src/test/java/org/tmapi/core/TestVariant.java
trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java
trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
Modified: trunk/src/main/java/org/tmapi/index/LiteralIndex.java
===================================================================
--- trunk/src/main/java/org/tmapi/index/LiteralIndex.java 2008-08-14 11:46:44 UTC (rev 64)
+++ trunk/src/main/java/org/tmapi/index/LiteralIndex.java 2008-08-19 11:14:19 UTC (rev 65)
@@ -37,6 +37,7 @@
*
* @param value The value of the {@link Occurrence}s to be returned.
* @return An unmodifiable collection of {@link Occurrence}s.
+ * @throws IllegalArgumentException If the value is <tt>null</tt>.
*/
public Collection<Occurrence> getOccurrences(String value);
@@ -53,6 +54,7 @@
*
* @param value The value of the {@link Occurrence}s to be returned.
* @return An unmodifiable collection of {@link Occurrence}s.
+ * @throws IllegalArgumentException If the value is <tt>null</tt>.
*/
public Collection<Occurrence> getOccurrences(Locator value);
@@ -65,6 +67,7 @@
* @param value The value of the {@link Occurrence}s to be returned.
* @param datatype The datatype of the {@link Occurrence}s to be returned.
* @return An unmodifiable collection of {@link Occurrence}s.
+ * @throws IllegalArgumentException If the value or datatype is <tt>null</tt>.
*/
public Collection<Occurrence> getOccurrences(String value, Locator datatype);
@@ -77,6 +80,7 @@
*
* @param value The value of the {@link Variant}s to be returned.
* @return An unmodifiable collection of {@link Variant}s.
+ * @throws IllegalArgumentException If the value is <tt>null</tt>.
*/
public Collection<Variant> getVariants(String value);
@@ -93,6 +97,7 @@
*
* @param value The value of the {@link Variant}s to be returned.
* @return An unmodifiable collection of {@link Variant}s.
+ * @throws IllegalArgumentException If the value is <tt>null</tt>.
*/
public Collection<Variant> getVariants(Locator value);
@@ -105,6 +110,7 @@
* @param value The value of the {@link Variant}s to be returned.
* @param datatype The datatype of the {@link Variant}s to be returned.
* @return An unmodifiable collection of {@link Variant}s.
+ * @throws IllegalArgumentException If the value or datatype is <tt>null</tt>.
*/
public Collection<Variant> getVariants(String value, Locator datatype);
@@ -116,6 +122,7 @@
*
* @param value The value of the {@link Name}s to be returned.
* @return An unmodifiable collection of {@link Name}s.
+ * @throws IllegalArgumentException If the value is <tt>null</tt>.
*/
public Collection<Name> getNames(String value);
Modified: trunk/src/main/java/org/tmapi/index/ScopedIndex.java
===================================================================
--- trunk/src/main/java/org/tmapi/index/ScopedIndex.java 2008-08-14 11:46:44 UTC (rev 64)
+++ trunk/src/main/java/org/tmapi/index/ScopedIndex.java 2008-08-19 11:14:19 UTC (rev 65)
@@ -57,6 +57,7 @@
* must match all <tt>themes</tt>, if <tt>false</tt> one
* theme must be matched at least.
* @return An unmodifiable collection of {@link Association}s.
+ * @throws IllegalArgumentException If <tt>themes</tt> is <tt>null</tt>.
*/
public Collection<Association> getAssociations(Topic[] themes,
boolean matchAll);
@@ -95,6 +96,7 @@
* must match all <tt>themes</tt>, if <tt>false</tt> one
* theme must be matched at least.
* @return An unmodifiable collection of {@link Occurrence}s.
+ * @throws IllegalArgumentException If <tt>themes</tt> is <tt>null</tt>.
*/
public Collection<Occurrence> getOccurrences(Topic[] themes,
boolean matchAll);
@@ -133,6 +135,7 @@
* must match all <tt>themes</tt>, if <tt>false</tt> one
* theme must be matched at least.
* @return An unmodifiable collection of {@link Name}s.
+ * @throws IllegalArgumentException If <tt>themes</tt> is <tt>null</tt>.
*/
public Collection<Name> getNames(Topic[] themes, boolean matchAll);
@@ -155,6 +158,7 @@
* @param theme The {@link Topic} which must be part of the scope. This
* must not be <tt>null</tt>.
* @return An unmodifiable collection of {@link Variant}s.
+ * @throws IllegalArgumentException If <tt>theme</tt> is <tt>null</tt>.
*/
public Collection<Variant> getVariants(Topic theme);
@@ -169,6 +173,7 @@
* must match all <tt>themes</tt>, if <tt>false</tt> one
* theme must be matched at least.
* @return An unmodifiable collection of {@link Variant}s.
+ * @throws IllegalArgumentException If <tt>themes</tt> is <tt>null</tt>.
*/
public Collection<Variant> getVariants(Topic[] themes, boolean matchAll);
Modified: trunk/src/test/java/org/tmapi/core/TestReified.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestReified.java 2008-08-14 11:46:44 UTC (rev 64)
+++ trunk/src/test/java/org/tmapi/core/TestReified.java 2008-08-19 11:14:19 UTC (rev 65)
@@ -45,6 +45,8 @@
assertEquals("Unexpected reifier property", reifier, reifiable.getReifier());
assertEquals("Unexpected reified property", reifiable, reifier.getReified());
try {
+ // Assigning the *same* reifier is allowed, the TM processor MUST NOT
+ // raise an exception
reifiable.setReifier(reifier);
}
catch (ModelConstraintException ex) {
Modified: trunk/src/test/java/org/tmapi/core/TestVariant.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestVariant.java 2008-08-14 11:46:44 UTC (rev 64)
+++ trunk/src/test/java/org/tmapi/core/TestVariant.java 2008-08-19 11:14:19 UTC (rev 65)
@@ -62,7 +62,8 @@
final Topic varTheme = createTopic();
final Variant variant = name.createVariant("Variant", varTheme);
assertNotNull(variant);
- assertEquals(1, variant.getScope().size());
+ assertEquals("Unexpected variant's scope",
+ 1, variant.getScope().size());
assertTrue(variant.getScope().contains(varTheme));
final Topic nameTheme = createTopic();
name.addTheme(nameTheme);
@@ -73,7 +74,62 @@
assertTrue(variant.getScope().contains(varTheme));
name.removeTheme(nameTheme);
assertTrue(name.getScope().isEmpty());
- assertEquals(1, variant.getScope().size());
+ assertEquals("Name's theme wasn't remove from the variant",
+ 1, variant.getScope().size());
assertTrue(variant.getScope().contains(varTheme));
}
+
+ /**
+ * Tests if a variant's theme equals to a name's theme stays
+ * even if the name's theme is removed.
+ */
+ public void testScopeProperty2() {
+ final Topic theme = createTopic();
+ final Topic varTheme = createTopic();
+ final Name name = createTopic().createName("Name", theme);
+ assertEquals(1, name.getScope().size());
+ assertTrue(name.getScope().contains(theme));
+ final Variant variant = name.createVariant("Variant", theme, varTheme);
+ assertNotNull(variant);
+ assertEquals("Unexpected variant's scope",
+ 2, variant.getScope().size());
+ assertTrue(variant.getScope().contains(theme));
+ assertTrue(variant.getScope().contains(varTheme));
+ name.removeTheme(theme);
+ assertEquals(0, name.getScope().size());
+ assertEquals("Unexpected variant's scope after removal of 'theme' from name",
+ 2, variant.getScope().size());
+ assertTrue(variant.getScope().contains(theme));
+ assertTrue(variant.getScope().contains(varTheme));
+ }
+
+ /**
+ * Tests if a variant's theme equals to a name's theme stays
+ * even if the variant's theme is removed.
+ */
+ public void testScopeProperty3() {
+ final Topic theme = createTopic();
+ final Topic varTheme = createTopic();
+ final Name name = createTopic().createName("Name", theme);
+ assertEquals(1, name.getScope().size());
+ assertTrue(name.getScope().contains(theme));
+ final Variant variant = name.createVariant("Variant", theme, varTheme);
+ assertNotNull(variant);
+ assertEquals("Unexpected variant's scope",
+ 2, variant.getScope().size());
+ assertTrue(variant.getScope().contains(theme));
+ assertTrue(variant.getScope().contains(varTheme));
+ variant.removeTheme(theme);
+ assertEquals("The parent still contains 'theme'",
+ 2, variant.getScope().size());
+ assertTrue(variant.getScope().contains(theme));
+ assertTrue(variant.getScope().contains(varTheme));
+ name.removeTheme(theme);
+ assertEquals(0, name.getScope().size());
+ assertEquals("'theme' was removed from the name",
+ 1, variant.getScope().size());
+ assertFalse(variant.getScope().contains(theme));
+ assertTrue(variant.getScope().contains(varTheme));
+ }
+
}
Modified: trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java
===================================================================
--- trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java 2008-08-14 11:46:44 UTC (rev 64)
+++ trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java 2008-08-19 11:14:19 UTC (rev 65)
@@ -91,7 +91,7 @@
_litIdx.getNames(null);
fail("getNames(null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -185,7 +185,7 @@
_litIdx.getOccurrences((String)null);
fail("getOccurrences((String)null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -195,7 +195,7 @@
_litIdx.getOccurrences((Locator)null);
fail("getOccurrences((Locator)null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -205,7 +205,7 @@
_litIdx.getOccurrences("value", null);
fail("getOccurrences(\"value\", null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -299,7 +299,7 @@
_litIdx.getVariants((String)null);
fail("getVariants((String)null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -309,7 +309,7 @@
_litIdx.getVariants((Locator)null);
fail("getVariants((Locator)null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -319,7 +319,7 @@
_litIdx.getVariants("value", null);
fail("getVariants(\"value\", null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
===================================================================
--- trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-14 11:46:44 UTC (rev 64)
+++ trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-19 11:14:19 UTC (rev 65)
@@ -176,10 +176,11 @@
final Name name = createName();
assertEquals(0, name.getScope().size());
final Variant scoped = name.createVariant("Variant", theme);
- assertEquals(1, scoped.getScope().size());
+ assertEquals("Unexpected variant's scope size", 1, scoped.getScope().size());
_updateIndex();
assertFalse(_scopedIdx.getVariantThemes().isEmpty());
- assertEquals(1, _scopedIdx.getVariantThemes().size());
+ assertEquals("Unexpected number of variant themes",
+ 1, _scopedIdx.getVariantThemes().size());
assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
assertTrue(_scopedIdx.getVariantThemes().contains(theme));
// Add theme to name
@@ -198,13 +199,14 @@
name.removeTheme(theme2);
_updateIndex();
assertFalse(_scopedIdx.getVariantThemes().isEmpty());
- assertEquals(1, _scopedIdx.getVariantThemes().size());
+ assertEquals("The scope change in the name is not reflected in variant",
+ 1, _scopedIdx.getVariantThemes().size());
assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
assertTrue(_scopedIdx.getVariantThemes().contains(theme));
scoped.addTheme(theme2);
_updateIndex();
assertEquals("Change of the variant's scope is not reflected in the index",
- 2, _scopedIdx.getVariantThemes().size());
+ 2, _scopedIdx.getVariantThemes().size());
assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
assertTrue(_scopedIdx.getVariantThemes().contains(theme));
assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
@@ -212,7 +214,8 @@
// Add theme to name
name.addTheme(theme2);
_updateIndex();
- assertEquals(2, _scopedIdx.getVariantThemes().size());
+ assertEquals("Adding a theme to the variant's parent is not reflected",
+ 2, _scopedIdx.getVariantThemes().size());
assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
assertTrue(_scopedIdx.getVariantThemes().contains(theme));
assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
@@ -220,7 +223,8 @@
// Remove theme from name
name.removeTheme(theme2);
_updateIndex();
- assertEquals(2, _scopedIdx.getVariantThemes().size());
+ assertEquals("Removing the name's theme MUST NOT be reflected in the variant's scope",
+ 2, _scopedIdx.getVariantThemes().size());
assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
assertTrue(_scopedIdx.getVariantThemes().contains(theme));
assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-08-14 11:46:38
|
Revision: 64
http://tmapi.svn.sourceforge.net/tmapi/?rev=64&view=rev
Author: lheuer
Date: 2008-08-14 11:46:44 +0000 (Thu, 14 Aug 2008)
Log Message:
-----------
- ModelConstraintException for all factory methods
- Explicit tests for IllegalArgumentException and ModelConstraintException
Modified Paths:
--------------
trunk/src/main/java/org/tmapi/core/Association.java
trunk/src/main/java/org/tmapi/core/DatatypeAware.java
trunk/src/main/java/org/tmapi/core/Name.java
trunk/src/main/java/org/tmapi/core/Role.java
trunk/src/main/java/org/tmapi/core/Scoped.java
trunk/src/main/java/org/tmapi/core/Topic.java
trunk/src/main/java/org/tmapi/core/TopicMap.java
trunk/src/main/java/org/tmapi/core/Typed.java
trunk/src/main/java/org/tmapi/core/Variant.java
trunk/src/test/java/org/tmapi/core/TestAssociation.java
trunk/src/test/java/org/tmapi/core/TestConstruct.java
trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
trunk/src/test/java/org/tmapi/core/TestName.java
trunk/src/test/java/org/tmapi/core/TestRole.java
trunk/src/test/java/org/tmapi/core/TestScoped.java
trunk/src/test/java/org/tmapi/core/TestTopic.java
trunk/src/test/java/org/tmapi/core/TestTopicMap.java
trunk/src/test/java/org/tmapi/core/TestTyped.java
trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
Modified: trunk/src/main/java/org/tmapi/core/Association.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Association.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Association.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -78,6 +78,7 @@
* must not be <tt>null</tt>.
* @return An unmodifiable (maybe empty) set of roles with the specified
* <tt>type</tt> property.
+ * @throws IllegalArgumentException In case the <tt>type</tt> is <tt>null</tt>.
*/
public Set<Role> getRoles(Topic type);
@@ -87,6 +88,8 @@
* @param type The role type; MUST NOT be <tt>null</tt>.
* @param player The role player; MUST NOT be <tt>null</tt>.
* @return A newly created association role.
+ * @throws ModelConstraintException In case the role <tt>type</tt> or
+ * <tt>player</tt> is <tt>null</tt>.
*/
public Role createRole(Topic type, Topic player);
Modified: trunk/src/main/java/org/tmapi/core/DatatypeAware.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/DatatypeAware.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/DatatypeAware.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -68,6 +68,7 @@
* </p>
*
* @param value The IRI value.
+ * @throws ModelConstraintException In case the <tt>value</tt> is <tt>null</tt>.
*/
public void setValue(Locator value);
@@ -76,6 +77,8 @@
*
* @param value The string value.
* @param datatype The value's datatype.
+ * @throws ModelConstraintException In case the <tt>value</tt> or <tt>datatype</tt>
+ * is <tt>null</tt>.
*/
public void setValue(String value, Locator datatype);
@@ -87,6 +90,7 @@
* </p>
*
* @param value The decimal value.
+ * @throws ModelConstraintException In case the <tt>value</tt> is <tt>null</tt>.
*/
public void setValue(BigDecimal value);
@@ -98,6 +102,7 @@
* </p>
*
* @param value The integer value.
+ * @throws ModelConstraintException In case the <tt>value</tt> is <tt>null</tt>.
*/
public void setValue(BigInteger value);
Modified: trunk/src/main/java/org/tmapi/core/Name.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Name.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Name.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -47,6 +47,7 @@
* The previous value is overridden.
*
* @param value The name string to be assigned to the name.
+ * @throws ModelConstraintException If the the <tt>value</tt> is <tt>null</tt>.
*/
public void setValue(String value);
@@ -70,8 +71,9 @@
* @param value The string value.
* @param scope An array (length >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> is <tt>null</tt>,
+ * or the scope of the variant would not be a true superset of the
+ * name's scope.
*/
public Variant createVariant(String value, Topic... scope);
@@ -86,8 +88,9 @@
* @param value The string value.
* @param scope A collection (size >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> is <tt>null</tt>,
+ * or the scope of the variant would not be a true superset of the
+ * name's scope.
*/
public Variant createVariant(String value, Collection<Topic> scope);
@@ -102,8 +105,9 @@
* @param value A locator which represents an IRI.
* @param scope An array (length >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> is <tt>null</tt>,
+ * or the scope of the variant would not be a true superset of the
+ * name's scope.
*/
public Variant createVariant(Locator value, Topic... scope);
@@ -118,8 +122,9 @@
* @param value A locator which represents an IRI.
* @param scope A collection (size >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> is <tt>null</tt>,
+ * or the scope of the variant would not be a true superset of the
+ * name's scope.
*/
public Variant createVariant(Locator value, Collection<Topic> scope);
@@ -135,8 +140,9 @@
* @param datatype A locator indicating the datatype of the <tt>value</tt>.
* @param scope An array (length >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> or <tt>datatype</tt>
+ * is <tt>null</tt>, or the scope of the variant would not be a
+ * true superset of the name's scope.
*/
public Variant createVariant(String value, Locator datatype, Topic... scope);
@@ -152,8 +158,9 @@
* @param datatype A locator indicating the datatype of the <tt>value</tt>.
* @param scope A collection (size >= 1) of themes.
* @return The newly created {@link Variant}
- * @throws ModelConstraintException If the scope of the variant would
- * not be a true superset of the name's scope.
+ * @throws ModelConstraintException If the <tt>value</tt> or <tt>datatype</tt>
+ * is <tt>null</tt>, or the scope of the variant would not be a
+ * true superset of the name's scope.
*/
public Variant createVariant(String value, Locator datatype,
Collection<Topic> scope);
Modified: trunk/src/main/java/org/tmapi/core/Role.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Role.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Role.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -44,6 +44,7 @@
* Any previous role player will be overriden by <tt>player</tt>.
*
* @param player The topic which should play this role.
+ * @throws ModelConstraintException If the <tt>player</tt> is <tt>null</tt>.
*/
public void setPlayer(Topic player);
}
Modified: trunk/src/main/java/org/tmapi/core/Scoped.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Scoped.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Scoped.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -41,6 +41,7 @@
* Adds a topic to the scope.
*
* @param theme The topic which should be added to the scope.
+ * @throws ModelConstraintException If the <tt>theme</tt> is <tt>null</tt>.
*/
public void addTheme(Topic theme);
Modified: trunk/src/main/java/org/tmapi/core/Topic.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Topic.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Topic.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -142,6 +142,7 @@
* must not be <tt>null</tt>.
* @return An unmodifiable set of {@link Name}s with the specified
* <tt>type</tt>.
+ * @throws IllegalArgumentException If the <tt>type</tt> is <tt>null</tt>.
*/
public Set<Name> getNames(Topic type);
@@ -155,6 +156,8 @@
* the array's length is <tt>0</tt>, the name will be
* in the unconstrained scope.
* @return The newly created {@link Name}
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Name createName(Topic type, String value, Topic... scope);
@@ -167,6 +170,8 @@
* @param scope A collection of themes or <tt>null</tt> if the name should
* be in the unconstrained scope.
* @return The newly created {@link Name}
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Name createName(Topic type, String value, Collection<Topic> scope);
@@ -184,6 +189,8 @@
* the array's length is <tt>0</tt>, the name will be
* in the unconstrained scope.
* @return The newly created {@link Name}
+ * @throws ModelConstraintException If either the <tt>value</tt>, or
+ * <tt>scope</tt> is <tt>null</tt>.
*/
public Name createName(String value, Topic... scope);
@@ -200,6 +207,8 @@
* @param scope A collection of themes or <tt>null</tt> if the name should
* be in the unconstrained scope.
* @return The newly created {@link Name}
+ * @throws ModelConstraintException If either the <tt>value</tt>, or
+ * <tt>scope</tt> is <tt>null</tt>.
*/
public Name createName(String value, Collection<Topic> scope);
@@ -232,6 +241,7 @@
* must not be <tt>null</tt>.
* @return An unmodifiable set of {@link Occurrence}s with the
* specified <tt>type</tt>.
+ * @throws IllegalArgumentException If the <tt>type</tt> is <tt>null</tt>.
*/
public Set<Occurrence> getOccurrences(Topic type);
@@ -249,6 +259,8 @@
* the array's length is <tt>0</tt>, the occurrence will be
* in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, String value, Topic... scope);
@@ -265,6 +277,8 @@
* @param scope A collection of themes or <tt>null</tt> if the occurrence
* should be in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, String value,
Collection<Topic> scope);
@@ -283,6 +297,8 @@
* the array's length is <tt>0</tt>, the occurrence will be
* in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, Locator value,
Topic... scope);
@@ -300,6 +316,8 @@
* @param scope A collection of themes or <tt>null</tt> if the occurrence
* should be in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, or <tt>scope</tt> is <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, Locator value,
Collection<Topic> scope);
@@ -319,6 +337,9 @@
* the array's length is <tt>0</tt>, the occurrence will be
* in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, the <tt>datatype</tt> or <tt>scope</tt> is
+ * <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, String value,
Locator datatype, Topic... scope);
@@ -337,6 +358,9 @@
* @param scope A collection of themes or <tt>null</tt> if the occurrence
* should be in the unconstrained scope.
* @return The newly created {@link Occurrence}.
+ * @throws ModelConstraintException If either the <tt>type</tt>, the
+ * <tt>value</tt>, the <tt>datatype</tt> or <tt>scope</tt> is
+ * <tt>null</tt>.
*/
public Occurrence createOccurrence(Topic type, String value,
Locator datatype, Collection<Topic> scope);
@@ -370,6 +394,7 @@
* @param type The type of the {@link Role}s to be returned; must not
* be <tt>null</tt>.
* @return An unmodifiable set of {@link Role}s with the specified <tt>type</tt>.
+ * @throws IllegalArgumentException If the <tt>type</tt> is <tt>null</tt>.
*/
public Set<Role> getRolesPlayed(Topic type);
@@ -396,6 +421,8 @@
* @return An unmodifiable set of {@link Role}s with the specified <tt>type</tt>
* which are part of {@link Association}s with the specified
* <tt>assocType</tt>.
+ * @throws IllegalArgumentException If the <tt>type</tt> or <tt>assocType</tt>
+ * is <tt>null</tt>.
*/
public Set<Role> getRolesPlayed(Topic type, Topic assocType);
@@ -423,6 +450,7 @@
*
* @param type The type of which this topic should become an instance of;
* must not be <tt>null</tt>.
+ * @throws ModelConstraintException If the <tt>type</tt> is <tt>null</tt>.
*/
public void addType(Topic type);
Modified: trunk/src/main/java/org/tmapi/core/TopicMap.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicMap.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/TopicMap.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -125,6 +125,7 @@
*
* @param sid The subject identifier the topic should contain.
* @return A {@link Topic} instance with the specified subject identifier.
+ * @throws ModelConstraintException If the subject identifier <tt>sid</tt> is <tt>null</tt>.
*/
public Topic createTopicBySubjectIdentifier(Locator sid);
@@ -137,6 +138,7 @@
*
* @param slo The subject locator the topic should contain.
* @return A {@link Topic} instance with the specified subject locator.
+ * @throws ModelConstraintException If the subject locator <tt>slo</tt> is <tt>null</tt>.
*/
public Topic createTopicBySubjectLocator(Locator slo);
@@ -158,6 +160,9 @@
*
* @param iid The item identifier the topic should contain.
* @return A {@link Topic} instance with the specified item identifier.
+ * @throws ModelConstraintException If the item identifier <tt>iid</tt> is <tt>null</tt>.
+ * @throws IdentityConstraintException If an other {@link Construct} with the
+ * specified item identifier exists which is not a {@link Topic}.
*/
public Topic createTopicByItemIdentifier(Locator iid);
@@ -184,6 +189,8 @@
* the array's length is <tt>0</tt>, the association will be
* in the unconstrained scope.
* @return The newly created {@link Association}
+ * @throws ModelConstraintException If either the <tt>type</tt> or
+ * <tt>scope</tt> is <tt>null</tt>.
*/
public Association createAssociation(Topic type, Topic... scope);
@@ -195,6 +202,8 @@
* @param scope A collection of themes or <tt>null</tt> if the association
* should be in the unconstrained scope.
* @return The newly created {@link Association}
+ * @throws ModelConstraintException If either the <tt>type</tt> or
+ * <tt>scope</tt> is <tt>null</tt>.
*/
public Association createAssociation(Topic type, Collection<Topic> scope);
Modified: trunk/src/main/java/org/tmapi/core/Typed.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Typed.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Typed.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -38,6 +38,7 @@
*
* @param type The topic that should define the nature of this construct;
* MUST NOT be <tt>null</tt>.
+ * @throws ModelConstraintException If the <tt>type</tt> is <tt>null</tt>.
*/
public void setType(Topic type);
Modified: trunk/src/main/java/org/tmapi/core/Variant.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Variant.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/main/java/org/tmapi/core/Variant.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -38,8 +38,7 @@
*
* The returned scope is a true superset of the parent's scope.
*
- * @return An unmodifiable set of {@link Topic}s which define
- * the scope.
+ * @return An unmodifiable set of {@link Topic}s which define the scope.
*/
public Set<Topic> getScope();
Modified: trunk/src/test/java/org/tmapi/core/TestAssociation.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestAssociation.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestAssociation.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -134,7 +134,7 @@
assoc.getRoles(null);
fail("getRoles(null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -147,7 +147,7 @@
assoc.createRole(createTopic(), null);
fail("Role creation where player is null shouldn't be allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -160,7 +160,7 @@
assoc.createRole(null, createTopic());
fail("Role creation where type is null shouldn't be allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestConstruct.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestConstruct.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestConstruct.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -51,7 +51,7 @@
construct.addItemIdentifier(null);
fail("addItemIdentifier(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
if (construct instanceof TopicMap) {
Modified: trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -238,7 +238,7 @@
dt.setValue("value", null);
fail("datatypeAware.setValue(\"value\", null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -249,7 +249,7 @@
dt.setValue((String)null);
fail("datatypeAware.setValue((String)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -260,7 +260,7 @@
dt.setValue(null, _xsdString);
fail("datatypeAware.setValue(null, datatype) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -271,7 +271,7 @@
dt.setValue((Locator)null);
fail("datatypeAware.setValue((Locator)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -282,7 +282,7 @@
dt.setValue((BigInteger)null);
fail("datatypeAware.setValue((BigInteger)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -293,44 +293,11 @@
dt.setValue((BigDecimal)null);
fail("datatypeAware.setValue((BigDecimal)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
- public void testIllegalFloatValue() {
- final DatatypeAware dt = getDatatypeAware();
- try {
- dt.setValue((Float)null);
- fail("datatypeAware.setValue((Float)null) is illegal");
- }
- catch (Exception ex) {
- // noop.
- }
- }
-
- public void testIllegalLongValue() {
- final DatatypeAware dt = getDatatypeAware();
- try {
- dt.setValue((Long)null);
- fail("datatypeAware.setValue((Long)null) is illegal");
- }
- catch (Exception ex) {
- // noop.
- }
- }
-
- public void testIllegalIntValue() {
- final DatatypeAware dt = getDatatypeAware();
- try {
- dt.setValue((Integer)null);
- fail("datatypeAware.setValue((Integer)null) is illegal");
- }
- catch (Exception ex) {
- // noop.
- }
- }
-
protected void assertFailInteger(final DatatypeAware dt) {
try {
dt.integerValue();
Modified: trunk/src/test/java/org/tmapi/core/TestName.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestName.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestName.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -59,7 +59,7 @@
name.setValue(null);
fail("setValue(null) is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
// Old value kept.
@@ -108,7 +108,7 @@
name.createVariant((String)null, theme);
fail("Creation of a variant with (String) null value is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -120,7 +120,7 @@
name.createVariant((Locator)null, theme);
fail("Creation of a variant with (Locator) null value is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -132,7 +132,7 @@
name.createVariant("Variant", (Locator)null, theme);
fail("Creation of a variant with datatype == null is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -158,7 +158,7 @@
name.createVariant("Variant", Collections.<Topic>emptySet());
fail("Creation of a variant with an empty scope is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -169,7 +169,7 @@
name.createVariant("Variant", (Topic[])null);
fail("Creation of a variant with a null scope is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestRole.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestRole.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestRole.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -67,11 +67,15 @@
role.setPlayer(player);
assertEquals("Unexpected role player after setting to 'player'",
player, role.getPlayer());
+ }
+
+ public void testIllegalPlayer() {
+ Role role = createRole();
try {
role.setPlayer(null);
fail("Setting the role player to null is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestScoped.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestScoped.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestScoped.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -58,7 +58,7 @@
scoped.addTheme(null);
fail("addTheme(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestTopic.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopic.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestTopic.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -56,7 +56,7 @@
topic.addSubjectIdentifier(null);
fail("addSubjectIdentifier(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -67,7 +67,7 @@
topic.addSubjectLocator(null);
fail("addSubjectLocator(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -124,7 +124,7 @@
topic.addType(null);
fail("addType(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -161,7 +161,7 @@
player.getRolesPlayed(null);
fail("topic.getRolesPlayed(null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -217,7 +217,7 @@
player.getRolesPlayed(role.getType(), null);
fail("topic.getRolesPlayed(type, null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -229,7 +229,7 @@
player.getRolesPlayed(null, role.getParent().getType());
fail("topic.getRolesPlayed(null, type) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -265,7 +265,7 @@
parent.getOccurrences(null);
fail("topic.getOccurrences(null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -301,7 +301,7 @@
parent.getNames(null);
fail("topic.getNames(null) is illegal");
}
- catch (Exception ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
@@ -505,7 +505,7 @@
topic.createOccurrence(createTopic(), "Occurrence", (Locator)null);
fail("createOccurrence(topic, \"Occurrence\", (Locator)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -516,7 +516,7 @@
topic.createOccurrence(null, "Occurrence");
fail("createOccurrence(null, \"Occurrence\" is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -527,7 +527,7 @@
topic.createOccurrence(createTopic(), "Occurrence", (Topic[])null);
fail("createOccurrence(topic, \"Occurrence\", (Topic[])null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -538,7 +538,7 @@
topic.createOccurrence(createTopic(), "Occurrence", (Collection<Topic>)null);
fail("createOccurrence(topic, \"Occurrence\", (Collection<Topic>)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -651,7 +651,7 @@
topic.createName(createTopic(), (String)null);
fail("createName(topic, null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -662,7 +662,7 @@
topic.createName(createTopic(), "Name", (Topic[])null);
fail("createName(topic, \"Name\", (Topic[])null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -673,7 +673,7 @@
topic.createName(createTopic(), "Name", (Collection<Topic>)null);
fail("createName(topic, \"Name\", (Collection<Topic>)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -684,7 +684,7 @@
topic.createName((String)null);
fail("createName(null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -695,7 +695,7 @@
topic.createName("Name", (Topic[])null);
fail("createName(\"Name\", (Topic[])null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -706,7 +706,7 @@
topic.createName("Name", (Collection<Topic>)null);
fail("createName(\"Name\", (Collection<Topic>)null) is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestTopicMap.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicMap.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestTopicMap.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -13,6 +13,7 @@
*/
package org.tmapi.core;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -56,7 +57,7 @@
_tm.createTopicBySubjectIdentifier(null);
fail("Subject identifier == null is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -79,7 +80,7 @@
_tm.createTopicBySubjectLocator(null);
fail("Subject locator == null is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -102,7 +103,7 @@
_tm.createTopicByItemIdentifier(null);
fail("item identifier == null is illegal");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
@@ -182,29 +183,42 @@
assertTrue(assoc.getScope().contains(theme2));
}
- public void testAssociationCreationIllegalType() {
+ public void testAssociationCreationIllegalTypeScopeArray() {
try {
_tm.createAssociation(null);
fail("Creating an association with type == null is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
- public void testAssociationCreationIllegalNullScope() {
+ public void testAssociationCreationIllegalTypeScopeCollection() {
try {
+ _tm.createAssociation(null, Arrays.asList(createTopic()));
+ fail("Creating an association with type == null is not allowed");
+ }
+ catch (ModelConstraintException ex) {
+ // noop.
+ }
+ }
+
+ public void testAssociationCreationIllegalNullCollectionScope() {
+ try {
_tm.createAssociation(createTopic(), (Topic[])null);
fail("Creating an association with scope == null is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
+ }
+
+ public void testAssociationCreationIllegalNullArrayScope() {
try {
_tm.createAssociation(createTopic(), (Collection<Topic>)null);
fail("Creating an association with scope == (Collection) null is not allowed");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestTyped.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTyped.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/core/TestTyped.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -38,7 +38,7 @@
typed.setType(null);
fail("Setting the type to null should be disallowed.");
}
- catch (Exception ex) {
+ catch (ModelConstraintException ex) {
// noop.
}
}
Modified: trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
===================================================================
--- trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-09 16:08:12 UTC (rev 63)
+++ trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-14 11:46:44 UTC (rev 64)
@@ -20,6 +20,7 @@
import org.tmapi.core.Occurrence;
import org.tmapi.core.TMAPITestCase;
import org.tmapi.core.Topic;
+import org.tmapi.core.Variant;
/**
* Tests against the {@link ScopedIndex} interface.
@@ -63,7 +64,7 @@
}
public void testAssociation() {
- Topic theme = _tm.createTopic();
+ Topic theme = createTopic();
_updateIndex();
assertTrue(_scopedIdx.getAssociations(null).isEmpty());
assertTrue(_scopedIdx.getAssociations(theme).isEmpty());
@@ -89,8 +90,8 @@
assertFalse(_scopedIdx.getAssociationThemes().contains(theme));
}
- public void testOccurrence() throws Exception {
- Topic theme = _tm.createTopic();
+ public void testOccurrence() {
+ Topic theme = createTopic();
_updateIndex();
assertTrue(_scopedIdx.getOccurrences(null).isEmpty());
assertTrue(_scopedIdx.getOccurrences(theme).isEmpty());
@@ -116,8 +117,8 @@
assertFalse(_scopedIdx.getOccurrenceThemes().contains(theme));
}
- public void testName() throws Exception {
- Topic theme = _tm.createTopic();
+ public void testName() {
+ Topic theme = createTopic();
_updateIndex();
assertTrue(_scopedIdx.getNames(null).isEmpty());
assertTrue(_scopedIdx.getNames(theme).isEmpty());
@@ -143,8 +144,8 @@
assertFalse(_scopedIdx.getNameThemes().contains(theme));
}
- public void testName2() throws Exception {
- Topic theme = _tm.createTopic();
+ public void testName2() {
+ Topic theme = createTopic();
_updateIndex();
assertTrue(_scopedIdx.getNames(null).isEmpty());
assertTrue(_scopedIdx.getNames(theme).isEmpty());
@@ -166,4 +167,93 @@
assertFalse(_scopedIdx.getNameThemes().contains(theme));
}
+ public void testVariant() {
+ final Topic theme = createTopic();
+ final Topic theme2 = createTopic();
+ _updateIndex();
+ assertTrue(_scopedIdx.getVariants(theme).isEmpty());
+ assertTrue(_scopedIdx.getVariantThemes().isEmpty());
+ final Name name = createName();
+ assertEquals(0, name.getScope().size());
+ final Variant scoped = name.createVariant("Variant", theme);
+ assertEquals(1, scoped.getScope().size());
+ _updateIndex();
+ assertFalse(_scopedIdx.getVariantThemes().isEmpty());
+ assertEquals(1, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ // Add theme to name
+ name.addTheme(theme2);
+ assertEquals(1, name.getScope().size());
+ assertEquals("The scope change of the parent is not reflected in the variant's scope",
+ 2, scoped.getScope().size());
+ _updateIndex();
+ assertEquals("Change of the parent's scope is not reflected in the index",
+ 2, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme2));
+ // Remove theme from name
+ name.removeTheme(theme2);
+ _updateIndex();
+ assertFalse(_scopedIdx.getVariantThemes().isEmpty());
+ assertEquals(1, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ scoped.addTheme(theme2);
+ _updateIndex();
+ assertEquals("Change of the variant's scope is not reflected in the index",
+ 2, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme2));
+ // Add theme to name
+ name.addTheme(theme2);
+ _updateIndex();
+ assertEquals(2, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme2));
+ // Remove theme from name
+ name.removeTheme(theme2);
+ _updateIndex();
+ assertEquals(2, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme2));
+ scoped.removeTheme(theme2);
+ assertFalse(_scopedIdx.getVariantThemes().isEmpty());
+ assertEquals(1, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ }
+
+ public void testVariant2() {
+ final Topic theme = createTopic();
+ final Topic theme2 = createTopic();
+ _updateIndex();
+ assertTrue(_scopedIdx.getVariants(theme).isEmpty());
+ assertTrue(_scopedIdx.getVariants(theme2).isEmpty());
+ assertTrue(_scopedIdx.getVariantThemes().isEmpty());
+ final Name name = createTopic().createName("Name", theme2);
+ assertEquals(1, name.getScope().size());
+ final Variant scoped = name.createVariant("Variant", theme);
+ assertEquals(2, scoped.getScope().size());
+ _updateIndex();
+ assertEquals(2, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ assertTrue(_scopedIdx.getVariants(theme2).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme2));
+ name.removeTheme(theme2);
+ assertEquals(0, name.getScope().size());
+ _updateIndex();
+ assertEquals(1, _scopedIdx.getVariantThemes().size());
+ assertTrue(_scopedIdx.getVariants(theme).contains(scoped));
+ assertTrue(_scopedIdx.getVariantThemes().contains(theme));
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-08-09 16:08:04
|
Revision: 63
http://tmapi.svn.sourceforge.net/tmapi/?rev=63&view=rev
Author: lheuer
Date: 2008-08-09 16:08:12 +0000 (Sat, 09 Aug 2008)
Log Message:
-----------
TopicMap.getIndex() uses Generics to avoid casting
Modified Paths:
--------------
trunk/src/main/java/org/tmapi/core/TopicMap.java
trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java
trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
trunk/src/test/java/org/tmapi/index/TestTypeInstanceIndex.java
Modified: trunk/src/main/java/org/tmapi/core/TopicMap.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicMap.java 2008-08-08 12:00:50 UTC (rev 62)
+++ trunk/src/main/java/org/tmapi/core/TopicMap.java 2008-08-09 16:08:12 UTC (rev 63)
@@ -237,6 +237,6 @@
* @throws UnsupportedOperationException If the implementation does not
* support indices or if the specified index is unsupported.
*/
- public Index getIndex(Class<? extends Index> indexInterface);
+ public <I extends Index> I getIndex(Class<I> indexInterface);
}
Modified: trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java
===================================================================
--- trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java 2008-08-08 12:00:50 UTC (rev 62)
+++ trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java 2008-08-09 16:08:12 UTC (rev 63)
@@ -43,7 +43,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- _litIdx = (LiteralIndex) _tm.getIndex(LiteralIndex.class);
+ _litIdx = _tm.getIndex(LiteralIndex.class);
_litIdx.open();
final String XSD_BASE = "http://www.w3.org/2001/XMLSchema#";
_xsdString = createLocator(XSD_BASE + "string");
Modified: trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
===================================================================
--- trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-08 12:00:50 UTC (rev 62)
+++ trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-09 16:08:12 UTC (rev 63)
@@ -42,7 +42,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- _scopedIdx = (ScopedIndex) _tm.getIndex(ScopedIndex.class);
+ _scopedIdx = _tm.getIndex(ScopedIndex.class);
_scopedIdx.open();
}
Modified: trunk/src/test/java/org/tmapi/index/TestTypeInstanceIndex.java
===================================================================
--- trunk/src/test/java/org/tmapi/index/TestTypeInstanceIndex.java 2008-08-08 12:00:50 UTC (rev 62)
+++ trunk/src/test/java/org/tmapi/index/TestTypeInstanceIndex.java 2008-08-09 16:08:12 UTC (rev 63)
@@ -41,7 +41,7 @@
@Override
protected void setUp() throws Exception {
super.setUp();
- _typeInstanceIdx = (TypeInstanceIndex) _tm.getIndex(TypeInstanceIndex.class);
+ _typeInstanceIdx = _tm.getIndex(TypeInstanceIndex.class);
_typeInstanceIdx.open();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-08-08 12:00:46
|
Revision: 62
http://tmapi.svn.sourceforge.net/tmapi/?rev=62&view=rev
Author: lheuer
Date: 2008-08-08 12:00:50 +0000 (Fri, 08 Aug 2008)
Log Message:
-----------
- Docs for the exceptions
- Minor doc tweaks (<p/>'s etc)
Modified Paths:
--------------
trunk/src/main/java/org/tmapi/core/Association.java
trunk/src/main/java/org/tmapi/core/Construct.java
trunk/src/main/java/org/tmapi/core/DatatypeAware.java
trunk/src/main/java/org/tmapi/core/FactoryConfigurationException.java
trunk/src/main/java/org/tmapi/core/FeatureNotRecognizedException.java
trunk/src/main/java/org/tmapi/core/FeatureNotSupportedException.java
trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java
trunk/src/main/java/org/tmapi/core/Locator.java
trunk/src/main/java/org/tmapi/core/ModelConstraintException.java
trunk/src/main/java/org/tmapi/core/Name.java
trunk/src/main/java/org/tmapi/core/Occurrence.java
trunk/src/main/java/org/tmapi/core/Reifiable.java
trunk/src/main/java/org/tmapi/core/Role.java
trunk/src/main/java/org/tmapi/core/Scoped.java
trunk/src/main/java/org/tmapi/core/TMAPIException.java
trunk/src/main/java/org/tmapi/core/TMAPIRuntimeException.java
trunk/src/main/java/org/tmapi/core/Topic.java
trunk/src/main/java/org/tmapi/core/TopicInUseException.java
trunk/src/main/java/org/tmapi/core/TopicMap.java
trunk/src/main/java/org/tmapi/core/TopicMapExistsException.java
trunk/src/main/java/org/tmapi/core/TopicMapSystem.java
trunk/src/main/java/org/tmapi/core/TopicMapSystemFactory.java
trunk/src/main/java/org/tmapi/core/Typed.java
trunk/src/main/java/org/tmapi/core/Variant.java
trunk/src/main/java/org/tmapi/index/Index.java
trunk/src/main/java/org/tmapi/index/LiteralIndex.java
trunk/src/main/java/org/tmapi/index/ScopedIndex.java
trunk/src/main/java/org/tmapi/index/TypeInstanceIndex.java
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/TestAssociation.java
trunk/src/test/java/org/tmapi/core/TestConstruct.java
trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
trunk/src/test/java/org/tmapi/core/TestLocator.java
trunk/src/test/java/org/tmapi/core/TestName.java
trunk/src/test/java/org/tmapi/core/TestOccurrence.java
trunk/src/test/java/org/tmapi/core/TestReified.java
trunk/src/test/java/org/tmapi/core/TestRole.java
trunk/src/test/java/org/tmapi/core/TestScoped.java
trunk/src/test/java/org/tmapi/core/TestTopic.java
trunk/src/test/java/org/tmapi/core/TestTopicMap.java
trunk/src/test/java/org/tmapi/core/TestTopicMapMerge.java
trunk/src/test/java/org/tmapi/core/TestTopicMapSystem.java
trunk/src/test/java/org/tmapi/core/TestTopicMerge.java
trunk/src/test/java/org/tmapi/core/TestTopicMergeDetection.java
trunk/src/test/java/org/tmapi/core/TestTyped.java
trunk/src/test/java/org/tmapi/core/TestVariant.java
trunk/src/test/java/org/tmapi/index/AllIndexTests.java
trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java
trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
trunk/src/test/java/org/tmapi/index/TestTypeInstanceIndex.java
Modified: trunk/src/main/java/org/tmapi/core/Association.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Association.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/Association.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -19,7 +19,7 @@
* Represents an
* <a href="http://www.isotopicmaps.org/sam/sam-model/#sect-association">association item</a>.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Association extends Reifiable, Typed, Scoped {
@@ -44,7 +44,7 @@
/**
* Returns the role types participating in this association.
- *
+ * <p>
* This method returns the same result as the following code:
* <pre>
* Set<Topic> types = new HashSet<Topic>();
@@ -52,7 +52,7 @@
* types.add(role.getType());
* }
* </pre>
- *
+ * </p>
* The return value may be empty but must never be <tt>null</tt>.
*
* @return An unmodifiable set of role types.
@@ -61,7 +61,7 @@
/**
* Returns all roles with the specified <tt>type</tt>.
- *
+ * <p>
* This method returns the same result as the following code:
* <pre>
* Set<Role> roles = new HashSet<Role>();
@@ -71,7 +71,7 @@
* }
* }
* </pre>
- *
+ * </p>
* The return value may be empty but must never be <tt>null</tt>.
*
* @param type The type of the {@link Role} instances to be returned,
Modified: trunk/src/main/java/org/tmapi/core/Construct.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Construct.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/Construct.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -18,7 +18,7 @@
/**
* Base interface for all Topic Maps constructs.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Construct {
Modified: trunk/src/main/java/org/tmapi/core/DatatypeAware.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/DatatypeAware.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/DatatypeAware.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -18,12 +18,13 @@
/**
* Common base interface for {@link Occurrence}s and {@link Variant}s.
- *
+ * <p>
* Some convenience methods for a subset of
* <a href="http://www.w3.org/TR/xmlschema-2/">XML Schema Part 2: Datatypes</a>
* are supported.
+ * </p>
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface DatatypeAware extends Reifiable, Scoped {
@@ -38,12 +39,13 @@
/**
* Returns the lexical representation of the value.
- *
+ * <p>
* For the datatype <a href="http://www.w3.org/TR/xmlschema-2/#string">xsd:string</a>
* the string itself is returned. For the datatype
* <a href="http://www.w3.org/TR/xmlschema-2/#anyURI">xsd:anyURI</a>
* the {@link Locator#getReference()} is returned.
- *
+ * </p>
+ *
* @return The lexical representation of the value (never <tt>null</tt>).
*/
public String getValue();
@@ -60,10 +62,11 @@
/**
* Sets the IRI value.
- *
+ * <p>
* This method sets the datatype implicitly to
* <a href="http://www.w3.org/TR/xmlschema-2/#anyURI">xsd:anyURI</a>.
- *
+ * </p>
+ *
* @param value The IRI value.
*/
public void setValue(Locator value);
@@ -78,50 +81,55 @@
/**
* Sets the decimal value.
- *
+ * <p>
* This method sets the datatype implicitly to
* <a href="http://www.w3.org/TR/xmlschema-2/#decimal">xsd:decimal</a>.
- *
+ * </p>
+ *
* @param value The decimal value.
*/
public void setValue(BigDecimal value);
/**
* Sets the integer value.
- *
+ * <p>
* This method sets the datatype implicitly to
* <a href="http://www.w3.org/TR/xmlschema-2/#integer">xsd:integer</a>.
- *
+ * </p>
+ *
* @param value The integer value.
*/
public void setValue(BigInteger value);
/**
* Sets the long value.
- *
+ * <p>
* This method sets the datatype implicitly to
* <a href="http://www.w3.org/TR/xmlschema-2/#long">xsd:long</a>.
- *
+ * </p>
+ *
* @param value The integer value.
*/
public void setValue(long value);
/**
* Sets the float value.
- *
+ * <p>
* This method sets the datatype implicitly to
* <a href="http://www.w3.org/TR/xmlschema-2/#float">xsd:float</a>.
- *
+ * </p>
+ *
* @param value The float value.
*/
public void setValue(float value);
/**
* Sets the int value.
- *
+ * <p>
* This method sets the datatype implicitly to
* <a href="http://www.w3.org/TR/xmlschema-2/#int">xsd:int</a>.
- *
+ * </p>
+ *
* @param value The int value.
*/
public void setValue(int value);
Modified: trunk/src/main/java/org/tmapi/core/FactoryConfigurationException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/FactoryConfigurationException.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/FactoryConfigurationException.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -18,42 +18,45 @@
* cannot be instantiated through the method
* {@link TopicMapSystemFactory#newInstance()}.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public class FactoryConfigurationException extends TMAPIException {
- /**
- *
- */
private static final long serialVersionUID = -6197383571197389854L;
/**
- *
+ * Constructs a new throwable with the specified detail message.
*
- * @param msg
+ * @param message The detail message. This message is saved for later
+ * retrieval by the {@link #getMessage()} method.
*/
- public FactoryConfigurationException(String msg) {
- super(msg);
+ public FactoryConfigurationException(String message) {
+ super(message);
}
/**
- *
+ * Constructs a new exception that wraps another exception.
*
- * @param cause
+ * @param cause The throwable which caused this exception to be thrown.
+ * This value is saved for later retrieval by the
+ * {@link #getCause()} method.
*/
public FactoryConfigurationException(Throwable cause) {
super(cause);
}
/**
- *
+ * Constructs a new throwable with the specified detail message.
*
- * @param msg
- * @param cause
+ * @param message The detail message. This message is saved for later
+ * retrieval by the {@link #getMessage()} method.
+ * @param cause The throwable which caused this exception to be thrown.
+ * This value is saved for later retrieval by the
+ * {@link #getCause()} method.
*/
- public FactoryConfigurationException(String msg, Throwable cause) {
- super(msg, cause);
+ public FactoryConfigurationException(String message, Throwable cause) {
+ super(message, cause);
}
}
Modified: trunk/src/main/java/org/tmapi/core/FeatureNotRecognizedException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/FeatureNotRecognizedException.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/FeatureNotRecognizedException.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -13,47 +13,49 @@
*/
package org.tmapi.core;
-
/**
* Exception thrown when the TopicMapSystemFactory does not recognize
* the name of a feature that the application is trying to enable or disable.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public class FeatureNotRecognizedException extends FactoryConfigurationException {
- /**
- *
- */
private static final long serialVersionUID = 6231608065963599726L;
/**
- *
+ * Constructs a new throwable with the specified detail message.
*
- * @param msg
+ * @param message The detail message. This message is saved for later
+ * retrieval by the {@link #getMessage()} method.
*/
- public FeatureNotRecognizedException(String msg) {
- super(msg);
+ public FeatureNotRecognizedException(String message) {
+ super(message);
}
/**
- *
+ * Constructs a new exception that wraps another exception.
*
- * @param cause
+ * @param cause The throwable which caused this exception to be thrown.
+ * This value is saved for later retrieval by the
+ * {@link #getCause()} method.
*/
public FeatureNotRecognizedException(Throwable cause) {
super(cause);
}
/**
- *
+ * Constructs a new throwable with the specified detail message.
*
- * @param msg
- * @param cause
+ * @param message The detail message. This message is saved for later
+ * retrieval by the {@link #getMessage()} method.
+ * @param cause The throwable which caused this exception to be thrown.
+ * This value is saved for later retrieval by the
+ * {@link #getCause()} method.
*/
- public FeatureNotRecognizedException(String msg, Throwable cause) {
- super(msg, cause);
+ public FeatureNotRecognizedException(String message, Throwable cause) {
+ super(message, cause);
}
}
Modified: trunk/src/main/java/org/tmapi/core/FeatureNotSupportedException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/FeatureNotSupportedException.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/FeatureNotSupportedException.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -19,26 +19,45 @@
* implementations <strong>MUST</strong> throw a FeatureNotRecognizedException
* rather than a FeatureNotSupportedException.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public class FeatureNotSupportedException extends FactoryConfigurationException {
+ private static final long serialVersionUID = -6901109695537829395L;
+
/**
- *
+ * Constructs a new throwable with the specified detail message.
+ *
+ * @param message The detail message. This message is saved for later
+ * retrieval by the {@link #getMessage()} method.
*/
- private static final long serialVersionUID = -6901109695537829395L;
-
- public FeatureNotSupportedException(String msg) {
- super(msg);
+ public FeatureNotSupportedException(String message) {
+ super(message);
}
+ /**
+ * Constructs a new exception that wraps another exception.
+ *
+ * @param cause The throwable which caused this exception to be thrown.
+ * This value is saved for later retrieval by the
+ * {@link #getCause()} method.
+ */
public FeatureNotSupportedException(Throwable cause) {
super(cause);
}
- public FeatureNotSupportedException(String msg, Throwable cause) {
- super(msg, cause);
+ /**
+ * Constructs a new throwable with the specified detail message.
+ *
+ * @param message The detail message. This message is saved for later
+ * retrieval by the {@link #getMessage()} method.
+ * @param cause The throwable which caused this exception to be thrown.
+ * This value is saved for later retrieval by the
+ * {@link #getCause()} method.
+ */
+ public FeatureNotSupportedException(String message, Throwable cause) {
+ super(message, cause);
}
}
Modified: trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -20,12 +20,11 @@
* to different objects causes an <tt>IdentityConstraintException</tt> to be
* thrown.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev: 33 $ - $Date: 2008-08-02 16:42:29 +0200 (Sa, 02 Aug 2008) $
*/
public class IdentityConstraintException extends ModelConstraintException {
-
private static final long serialVersionUID = -8239221052536586370L;
private final Construct _existing;
Modified: trunk/src/main/java/org/tmapi/core/Locator.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Locator.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/Locator.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -16,7 +16,7 @@
/**
* Immutable representation of an IRI.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Locator {
Modified: trunk/src/main/java/org/tmapi/core/ModelConstraintException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/ModelConstraintException.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/ModelConstraintException.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -18,7 +18,7 @@
* <a href="http://www.isotopicmaps.org/sam/sam-model/">Topic Maps \x97 Data Model</a>
* constraint violations.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev: 33 $ - $Date: 2008-08-02 16:42:29 +0200 (Sa, 02 Aug 2008) $
*/
public class ModelConstraintException extends TMAPIRuntimeException {
@@ -43,7 +43,7 @@
* Returns the {@link Construct} which has thrown the exception.
*
* @return The construct which has thrown the exception or <tt>null</tt>
- * if no approbiate construct is available (i.e. in the factory
+ * if no appropiate construct is available (i.e. in the factory
* methods).
*/
public Construct getSender() {
Modified: trunk/src/main/java/org/tmapi/core/Name.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Name.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/Name.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -20,7 +20,7 @@
* Represents a
* <a href="http://www.isotopicmaps.org/sam/sam-model/#sect-topic-name">topic name item</a>.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Name extends Typed, Scoped, Reifiable {
@@ -62,10 +62,11 @@
/**
* Creates a {@link Variant} of this topic name with the specified string
* <tt>value</tt> and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Variant} will have the datatype
* <a href="http://www.w3.org/TR/xmlschema-2/#string">xsd:string</a>.
- *
+ * </p>
+ *
* @param value The string value.
* @param scope An array (length >= 1) of themes.
* @return The newly created {@link Variant}
@@ -77,10 +78,11 @@
/**
* Creates a {@link Variant} of this topic name with the specified string
* <tt>value</tt> and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Variant} will have the datatype
* <a href="http://www.w3.org/TR/xmlschema-2/#string">xsd:string</a>.
- *
+ * </p>
+ *
* @param value The string value.
* @param scope A collection (size >= 1) of themes.
* @return The newly created {@link Variant}
@@ -92,10 +94,11 @@
/**
* Creates a {@link Variant} of this topic name with the specified IRI
* <tt>value</tt> and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Variant} will have the datatype
* <a href="http://www.w3.org/TR/xmlschema-2/#anyURI">xsd:anyURI</a>.
- *
+ * </p>
+ *
* @param value A locator which represents an IRI.
* @param scope An array (length >= 1) of themes.
* @return The newly created {@link Variant}
@@ -107,10 +110,11 @@
/**
* Creates a {@link Variant} of this topic name with the specified IRI
* <tt>value</tt> and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Variant} will have the datatype
* <a href="http://www.w3.org/TR/xmlschema-2/#anyURI">xsd:anyURI</a>.
- *
+ * </p>
+ *
* @param value A locator which represents an IRI.
* @param scope A collection (size >= 1) of themes.
* @return The newly created {@link Variant}
@@ -122,10 +126,11 @@
/**
* Creates a {@link Variant} of this topic name with the specified IRI
* <tt>value</tt>, <tt>datatype</tt>, and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Variant} will have the datatype specified by
* <tt>datatype</tt>.
- *
+ * </p>
+ *
* @param value A lexical string representation of the value.
* @param datatype A locator indicating the datatype of the <tt>value</tt>.
* @param scope An array (length >= 1) of themes.
@@ -138,10 +143,11 @@
/**
* Creates a {@link Variant} of this topic name with the specified IRI
* <tt>value</tt>, <tt>datatype</tt>, and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Variant} will have the datatype specified by
* <tt>datatype</tt>.
- *
+ * </p>
+ *
* @param value A lexical string representation of the value.
* @param datatype A locator indicating the datatype of the <tt>value</tt>.
* @param scope A collection (size >= 1) of themes.
Modified: trunk/src/main/java/org/tmapi/core/Occurrence.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Occurrence.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/Occurrence.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -17,7 +17,7 @@
* Represents an
* <a href="http://www.isotopicmaps.org/sam/sam-model/#sect-occurrence">occurrence item</a>.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Occurrence extends Typed, DatatypeAware {
Modified: trunk/src/main/java/org/tmapi/core/Reifiable.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Reifiable.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/Reifiable.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -18,7 +18,7 @@
*
* Every Topic Maps construct that is not a {@link Topic} is reifiable.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Reifiable extends Construct {
Modified: trunk/src/main/java/org/tmapi/core/Role.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Role.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/Role.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -17,7 +17,7 @@
* Represents an
* <a href="http://www.isotopicmaps.org/sam/sam-model/#sect-assoc-role">association role item</a>.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Role extends Reifiable, Typed {
Modified: trunk/src/main/java/org/tmapi/core/Scoped.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Scoped.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/Scoped.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -21,7 +21,7 @@
* {@link Association}s, {@link Occurrence}s, {@link Name}s, and
* {@link Variant}s are scoped.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Scoped extends Construct {
Modified: trunk/src/main/java/org/tmapi/core/TMAPIException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TMAPIException.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/TMAPIException.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -17,47 +17,42 @@
* The base class for all standard (non run-time) exceptions thrown by a
* TMAPI system.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public class TMAPIException extends Exception {
- /**
- *
- */
private static final long serialVersionUID = -804738055960757078L;
/**
- *
+ * Constructs a new throwable with the specified detail message.
*
+ * @param message The detail message. This message is saved for later
+ * retrieval by the {@link #getMessage()} method.
+ * @param cause The throwable which caused this exception to be thrown.
+ * This value is saved for later retrieval by the
+ * {@link #getCause()} method.
*/
- public TMAPIException() {
- super();
- }
-
- /**
- *
- *
- * @param message
- * @param cause
- */
public TMAPIException(String message, Throwable cause) {
super(message, cause);
}
/**
- *
+ * Constructs a new throwable with the specified detail message.
*
- * @param message
+ * @param message The detail message. This message is saved for later
+ * retrieval by the {@link #getMessage()} method.
*/
public TMAPIException(String message) {
super(message);
}
/**
- *
+ * Constructs a new exception that wraps another exception.
*
- * @param cause
+ * @param cause The throwable which caused this exception to be thrown.
+ * This value is saved for later retrieval by the
+ * {@link #getCause()} method.
*/
public TMAPIException(Throwable cause) {
super(cause);
Modified: trunk/src/main/java/org/tmapi/core/TMAPIRuntimeException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TMAPIRuntimeException.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/TMAPIRuntimeException.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -18,39 +18,42 @@
* is an error in the underlying topic map processing system or when integrity
* constraints are violated.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev:$ - $Date:$
*/
public class TMAPIRuntimeException extends RuntimeException {
- /**
- *
- */
private static final long serialVersionUID = -5272967154641022529L;
/**
- *
- *
- * @param msg
- * @param cause
+ * Constructs a new throwable with the specified detail message.
+ *
+ * @param message The detail message. This message is saved for later
+ * retrieval by the {@link #getMessage()} method.
+ * @param cause The throwable which caused this exception to be thrown.
+ * This value is saved for later retrieval by the
+ * {@link #getCause()} method.
*/
- public TMAPIRuntimeException(String msg, Throwable cause) {
- super(msg, cause);
+ public TMAPIRuntimeException(String message, Throwable cause) {
+ super(message, cause);
}
/**
- *
- *
- * @param msg
+ * Constructs a new throwable with the specified detail message.
+ *
+ * @param message The detail message. This message is saved for later
+ * retrieval by the {@link #getMessage()} method.
*/
- public TMAPIRuntimeException(String msg) {
- super(msg);
+ public TMAPIRuntimeException(String message) {
+ super(message);
}
/**
- *
- *
- * @param cause
+ * Constructs a new exception that wraps another exception.
+ *
+ * @param cause The throwable which caused this exception to be thrown.
+ * This value is saved for later retrieval by the
+ * {@link #getCause()} method.
*/
public TMAPIRuntimeException(Throwable cause) {
super(cause);
Modified: trunk/src/main/java/org/tmapi/core/Topic.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Topic.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/Topic.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -20,7 +20,7 @@
* Represents a
* <a href="http://www.isotopicmaps.org/sam/sam-model/#d0e739">topic item</a>.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Topic extends Construct {
@@ -36,11 +36,12 @@
/**
* Adds an item identifier to this topic.
- *
+ * <p>
* If adding the specified item identifier would make this topic
* represent the same subject as another topic and the feature
* "automerge" (http://tmapi.org/features/automerge) is disabled,
* an {@link IdentityConstraintException} is thrown.
+ * </p>
*
* @see org.tmapi.core.Construct#addItemIdentifier(org.tmapi.core.Locator)
*/
@@ -58,12 +59,13 @@
/**
* Adds a subject identifier to this topic.
- *
+ * <p>
* If adding the specified subject identifier would make this topic
* represent the same subject as another topic and the feature
* "automerge" (http://tmapi.org/features/automerge/) is disabled,
* an {@link IdentityConstraintException} is thrown.
- *
+ * </p>
+ *
* @param sid The subject identifier to be added; must not be <tt>null</tt>.
* @throws IdentityConstraintException If the feature "automerge" is
* disabled and adding the subject identifier would make this
@@ -90,12 +92,13 @@
/**
* Adds a subject locator to this topic.
- *
+ * <p>
* If adding the specified subject locator would make this topic
* represent the same subject as another topic and the feature
* "automerge" (http://tmapi.org/features/automerge/) is disabled,
* an {@link IdentityConstraintException} is thrown.
- *
+ * </p>
+ *
* @param slo The subject locator to be added; must not be <tt>null</tt>.
* @throws IdentityConstraintException If the feature "automerge" is
* disabled and adding the subject locator would make this
@@ -122,7 +125,7 @@
/**
* Returns the {@link Name}s of this topic where the name type is
* <tt>type</tt>.
- *
+ * <p>
* This method returns the same result as the following code:
* <pre>
* Set<Name> names = new HashSet<Name>();
@@ -132,7 +135,7 @@
* }
* }
* </pre>
- *
+ * </p>
* The return value may be empty but must never be <tt>null</tt>.
*
* @param type The type of the {@link Name}s to be returned;
@@ -170,11 +173,12 @@
/**
* Creates a {@link Name} for this topic with the specified <tt>value</tt>,
* and <tt>scope</tt>.
- *
+ * <p>
* The created {@link Name} will have the default name type
* (a {@link Topic} with the subject identifier
* <a href="http://psi.topicmaps.org/iso13250/model/topic-name">http://psi.topicmaps.org/iso13250/model/topic-name</a>).
- *
+ * </p>
+ *
* @param value The string value of the name; MUST NOT be <tt>null</tt>.
* @param scope An optional array of themes, must not be <tt>null</tt>. If
* the array's length is <tt>0</tt>, the name will be
@@ -186,11 +190,12 @@
/**
* Creates a {@link Name} for this topic with the specified <tt>value</tt>,
* and <tt>scope</tt>.
- *
+ * <p>
* The created {@link Name} will have the default name type
* (a {@link Topic} with the subject identifier
* <a href="http://psi.topicmaps.org/iso13250/model/topic-name">http://psi.topicmaps.org/iso13250/model/topic-name</a>).
- *
+ * </p>
+ *
* @param value The string value of the name; MUST NOT be <tt>null</tt>.
* @param scope A collection of themes or <tt>null</tt> if the name should
* be in the unconstrained scope.
@@ -210,7 +215,7 @@
/**
* Returns the {@link Occurrence}s of this topic where the occurrence type
* is <tt>type</tt>.
- *
+ * <p>
* This method returns the same result as the following code:
* <pre>
* Set<Occurrence> occs = new HashSet<Occurrence>();
@@ -220,7 +225,7 @@
* }
* }
* </pre>
- *
+ * </p>
* The return value may be empty but must never be <tt>null</tt>.
*
* @param type The type of the {@link Occurrence}s to be returned;
@@ -233,10 +238,11 @@
/**
* Creates an {@link Occurrence} for this topic with the specified
* <tt>type</tt>, string <tt>value</tt>, and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Occurrence} will have the datatype
* <a href="http://www.w3.org/TR/xmlschema-2/#string">xsd:string</a>.
- *
+ * </p>
+ *
* @param type The occurrence type; MUST NOT be <tt>null</tt>.
* @param value The string value of the occurrence.
* @param scope An optional array of themes, must not be <tt>null</tt>. If
@@ -249,10 +255,11 @@
/**
* Creates an {@link Occurrence} for this topic with the specified
* <tt>type</tt>, string <tt>value</tt>, and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Occurrence} will have the datatype
* <a href="http://www.w3.org/TR/xmlschema-2/#string">xsd:string</a>.
- *
+ * </p>
+ *
* @param type The occurrence type; MUST NOT be <tt>null</tt>.
* @param value The string value of the occurrence.
* @param scope A collection of themes or <tt>null</tt> if the occurrence
@@ -265,10 +272,11 @@
/**
* Creates an {@link Occurrence} for this topic with the specified
* <tt>type</tt>, IRI <tt>value</tt>, and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Occurrence} will have the datatype
* <a href="http://www.w3.org/TR/xmlschema-2/#anyURI">xsd:anyURI</a>.
- *
+ * </p>
+ *
* @param type The occurrence type; MUST NOT be <tt>null</tt>.
* @param value A locator which represents an IRI.
* @param scope An optional array of themes, must not be <tt>null</tt>. If
@@ -282,10 +290,11 @@
/**
* Creates an {@link Occurrence} for this topic with the specified
* <tt>type</tt>, IRI <tt>value</tt>, and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Occurrence} will have the datatype
* <a href="http://www.w3.org/TR/xmlschema-2/#anyURI">xsd:anyURI</a>.
- *
+ * </p>
+ *
* @param type The occurrence type; MUST NOT be <tt>null</tt>.
* @param value A locator which represents an IRI.
* @param scope A collection of themes or <tt>null</tt> if the occurrence
@@ -298,10 +307,11 @@
/**
* Creates an {@link Occurrence} for this topic with the specified
* <tt>type</tt>, <tt>value</tt>, <tt>datatype</tt>, and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Occurrence} will have the datatype specified
* by <tt>datatype</tt>.
- *
+ * </p>
+ *
* @param type The occurrence type; MUST NOT be <tt>null</tt>.
* @param value A lexical string representation of the value.
* @param datatype A locator indicating the datatype of the <tt>value</tt>.
@@ -316,10 +326,11 @@
/**
* Creates an {@link Occurrence} for this topic with the specified
* <tt>type</tt>, <tt>value</tt>, <tt>datatype</tt>, and <tt>scope</tt>.
- *
+ * <p>
* The newly created {@link Occurrence} will have the datatype specified
* by <tt>datatype</tt>.
- *
+ * </p>
+ *
* @param type The occurrence type; MUST NOT be <tt>null</tt>.
* @param value A lexical string representation of the value.
* @param datatype A locator indicating the datatype of the <tt>value</tt>.
@@ -342,7 +353,7 @@
/**
* Returns the roles played by this topic where the role type is
* <tt>type</tt>.
- *
+ * <p>
* This method returns the same result as the following code:
* <pre>
* Set<Role> roles = new HashSet<Role>();
@@ -352,6 +363,7 @@
* }
* }
* </pre>
+ * </p>
*
* The return value may be empty but must never be <tt>null</tt>.
*
@@ -364,7 +376,7 @@
/**
* Returns the {@link Role}s played by this topic where the role type is
* <tt>type</tt> and the {@link Association} type is <tt>assocType</tt>.
- *
+ * <p>
* This method returns the same result as the following code:
* <pre>
* Set<Role> roles = new HashSet<Role>();
@@ -374,7 +386,7 @@
* }
* }
* </pre>
- *
+ * </p>
* The return value may be empty but must never be <tt>null</tt>.
*
* @param type The type of the {@link Role}s to be returned;
@@ -389,12 +401,12 @@
/**
* Returns the types of which this topic is an instance of.
- *
+ * <p>
* This method may return only those types which where added by
* {@link #addType(Topic)} and may ignore
* <a href="http://www.isotopicmaps.org/sam/sam-model/#sect-types">type-instance</a>
* relationships which are modelled as association.
- *
+ * </p>
* The return value may be empty but must never be <tt>null</tt>.
*
* @return An unmodifiable set of {@link Topic}s.
@@ -403,11 +415,12 @@
/**
* Adds a type to this topic.
- *
+ * <p>
* Implementations may or may not create an association for types added
* by this method. In any case, every type which was added by this method
* must be returned by the {@link #getTypes()} method.
- *
+ * </p>
+ *
* @param type The type of which this topic should become an instance of;
* must not be <tt>null</tt>.
*/
@@ -430,26 +443,30 @@
/**
* Merges another topic into this topic.
- *
+ * <p>
* Merging a topic into this topic causes this topic to gain all
* of the characteristics of the other topic and to replace the other
* topic wherever it is used as type, theme, or reifier.
* After this method completes, <tt>other</tt> will have been removed from
- * the {@link TopicMap}.
+ * the {@link TopicMap}.
+ * </p>
+ * <p>
* NOTE: The other topic MUST belong to the same {@link TopicMap} instance
* as this topic!
- *
+ * </p>
+ *
* @param other The topic to be merged into this topic.
*/
public void mergeIn(Topic other);
/**
* Removes this topic from the containing {@link TopicMap} instance.
- *
+ * <p>
* This method throws a {@link TopicInUseException} if the topic plays
* a {@link Role}, is used as type of a {@link Typed} construct, or if
* it is used as theme for a {@link Scoped} construct, or if it reifies a
* {@link Reifiable}.
+ * </p>
*
* @see org.tmapi.core.Construct#remove()
*
Modified: trunk/src/main/java/org/tmapi/core/TopicInUseException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicInUseException.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/TopicInUseException.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -17,7 +17,7 @@
* Thrown when an attempt is made to remove a {@link Topic} which is being used
* as a type, as a reifier, or as a role player in an association, or in a scope.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public class TopicInUseException extends ModelConstraintException {
@@ -36,7 +36,6 @@
super(sender, msg);
}
-
/* (non-Javadoc)
* @see org.tmapi.core.ModelConstraintException#getSender()
*/
Modified: trunk/src/main/java/org/tmapi/core/TopicMap.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicMap.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/TopicMap.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -22,7 +22,7 @@
* Represents a
* <a href="http://www.isotopicmaps.org/sam/sam-model/#d0e657">topic map item</a>.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface TopicMap extends Reifiable {
@@ -54,10 +54,11 @@
/**
* Returns a topic by its subject identifier.
- *
+ * <p>
* If no topic with the specified subject identifier exists, this method
* returns <tt>null</tt>.
- *
+ * </p>
+ *
* @param sid The subject identifier of the topic to be returned.
* @return A topic with the specified subject identifier or <tt>null</tt>
* if no such topic exists in the topic map.
@@ -66,10 +67,11 @@
/**
* Returns a topic by its subject locator.
- *
+ * <p>
* If no topic with the specified subject locator exists, this method
* returns <tt>null</tt>.
- *
+ * </p>
+ *
* @param slo The subject locator of the topic to be returned.
* @return A topic with the specified subject locator or <tt>null</tt>
* if no such topic exists in the topic map.
@@ -107,10 +109,11 @@
/**
* Returns a {@link Topic} instance with the specified subject identifier.
- *
+ * <p>
* This method returns either an existing {@link Topic} or creates a new
* {@link Topic} instance with the specified subject identifier.
- *
+ * </p>
+ * <p>
* If a topic with the specified subject identifier exists in the topic map,
* that topic is returned. If a topic with an item identifier equals to
* the specified subject identifier exists, the specified subject identifier
@@ -118,7 +121,8 @@
* If neither a topic with the specified subject identifier nor with an
* item identifier equals to the subject identifier exists, a topic with
* the subject identifier is created.
- *
+ * </p>
+ *
* @param sid The subject identifier the topic should contain.
* @return A {@link Topic} instance with the specified subject identifier.
*/
@@ -126,10 +130,11 @@
/**
* Returns a {@link Topic} instance with the specified subject locator.
- *
+ * <p>
* This method returns either an existing {@link Topic} or creates a new
* {@link Topic} instance with the specified subject locator.
- *
+ * </p>
+ *
* @param slo The subject locator the topic should contain.
* @return A {@link Topic} instance with the specified subject locator.
*/
@@ -137,10 +142,11 @@
/**
* Returns a {@link Topic} instance with the specified item identifier.
- *
+ * <p>
* This method returns either an existing {@link Topic} or creates a new
* {@link Topic} instance with the specified item identifier.
- *
+ * </p>
+ * <p>
* If a topic with the specified item identifier exists in the topic map,
* that topic is returned. If a topic with a subject identifier equals to
* the specified item identifier exists, the specified item identifier
@@ -148,6 +154,7 @@
* If neither a topic with the specified item identifier nor with a
* subject identifier equals to the subject identifier exists, a topic with
* the item identifier is created.
+ * </p>
*
* @param iid The item identifier the topic should contain.
* @return A {@link Topic} instance with the specified item identifier.
@@ -157,10 +164,11 @@
/**
* Returns a {@link Topic} instance with an automatically generated item
* identifier.
- *
+ * <p>
* This method returns never an existing {@link Topic} but creates a
* new one with an automatically generated item identifier.
* How that item identifier is generated depends on the implementation.
+ * </p>
*
* @return The newly created {@link Topic} instance with an automatically
* generated item identifier.
@@ -192,26 +200,29 @@
/**
* Closes use of this topic map instance.
- *
+ * <p>
* This method should be invoked by the application once it is finished
* using this topic map instance.
- *
+ * </p>
+ * <p>
* Implementations may release any resources required for the
* <tt>TopicMap</tt> instance or any of the {@link Construct} instances
* contained by this instance.
+ * </p>
*/
public void close();
/**
* Merges the topic map <code>other</code> into this topic map.
- *
+ * <p>
* All {@link Topic}s and {@link Association}s and all of their contents in
* <tt>other</tt> will be added to this topic map.
- *
+ * </p>
+ * <p>
* All information items in <tt>other</tt> will be merged into this
* topic map as defined by the
* <a href="http://www.isotopicmaps.org/sam/sam-model/#d0e1862">Topic Maps - Data Model (TMDM) merging rules</a>.
- *
+ * </p>
* The merge process will not modify <tt>other</tt> in any way.
*
* @param other The topic map to be merged with this topic map instance.
@@ -224,7 +235,7 @@
* @param indexInterface The index to return.
* @return An index.
* @throws UnsupportedOperationException If the implementation does not
- * support indices.
+ * support indices or if the specified index is unsupported.
*/
public Index getIndex(Class<? extends Index> indexInterface);
Modified: trunk/src/main/java/org/tmapi/core/TopicMapExistsException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicMapExistsException.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/TopicMapExistsException.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -18,15 +18,22 @@
* under a storage address (an IRI) that is already assigned to another
* {@link TopicMap} in the same {@link TopicMapSystem}.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public class TopicMapExistsException extends TMAPIException {
private static final long serialVersionUID = -1721148856137546269L;
- public TopicMapExistsException(String msg) {
- super(msg);
+ /**
+ * Constructs a new <tt>TopcMapExistsException</tt> with the specified
+ * detail message.
+ *
+ * @param message The detail message. This message is saved for later
+ * retrieval by the {@link #getMessage()} method.
+ */
+ public TopicMapExistsException(String message) {
+ super(message);
}
}
Modified: trunk/src/main/java/org/tmapi/core/TopicMapSystem.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicMapSystem.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/TopicMapSystem.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -22,7 +22,7 @@
* {@link TopicMap} objects. A TMAPI system may be capable of allowing a client
* to create new {@link TopicMap} instances.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface TopicMapSystem {
@@ -32,13 +32,14 @@
* specified storage address <tt>iri</tt>.
*
* The string is assumed to be in IRI notation.
- *
+ * <p>
* This method should return the same result as the following code:
* <pre>
* TopicMapSystem tmSys = ... // Assumed to be there
* String iri = "http://www.example.org/tm";
* TopicMap tm = tmSys.getTopicMap(tmSys.createLocator(iri));
* </pre>
+ * </p>
*
* @see #getTopicMap(Locator)
*
@@ -102,13 +103,14 @@
* specified <tt>iri</tt>.
*
* The string is assumed to be in IRI notation.
- *
+ * <p>
* This method should return the same result as the following code:
* <pre>
* TopicMapSystem tmSys = ... // Assumed to be there
* String iri = "http://www.example.org/tm";
* TopicMap tm = tmSys.createTopicMap(tmSys.createLocator(iri));
* </pre>
+ * </p>
*
* @see #createTopicMap(Locator)
*
@@ -122,11 +124,12 @@
/**
* Returns the value of the feature specified by <tt>featureName</tt>
* for this TopicMapSystem instance.
- *
+ * <p>
* The features supported by the TopicMapSystem and the value for each
* feature is set when the TopicMapSystem is created by a call to
* {@link TopicMapSystemFactory#newTopicMapSystem()} and cannot be modified
* subsequently.
+ * </p>
*
* @param featureName The name of the feature to check
* @return <tt>true</tt> if the named feature is enabled this TopicMapSystem
@@ -141,16 +144,19 @@
/**
* Returns a property in the underlying implementation of
* {@link TopicMapSystem}.
- *
+ * <p>
* A list of the core properties defined by TMAPI can be found at
* <a href="http://tmapi.org/properties/">http://tmapi.org/properties/</a>.
- *
+ * </p>
+ * <p>
* An implementation is free to support properties other than the core ones.
- *
+ * </p>
+ * <p>
* The properties supported by the TopicMapSystem
* and the value for each property is set when the TopicMapSystem is created
* by a call to {@link TopicMapSystemFactory#newTopicMapSystem()} and cannot
* be modified subsequently.
+ * </p>
*
* @param propertyName The name of the property to retrieve.
* @return The value set for the property or <tt>null</tt> if no value is
@@ -161,10 +167,11 @@
/**
* Applications SHOULD call this method when the TopicMapSystem instance is
* no longer required.
- *
+ * <p>
* Once the TopicMapSystem instance is closed, the TopicMapSystem and any
* object retrieved from or created in this TopicMapSystem MUST NOT be used
* by the application.
+ * </p>
*
* An implementation of the TopicMapSystem interface may use this method to
* clean up any resources used by the implementation.
Modified: trunk/src/main/java/org/tmapi/core/TopicMapSystemFactory.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicMapSystemFactory.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/TopicMapSystemFactory.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -31,7 +31,7 @@
* {@link #setProperty(String, Object)} methods prior to invoking
* {@link #newTopicMapSystem()}.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public abstract class TopicMapSystemFactory {
@@ -52,11 +52,12 @@
/**
* Returns if the particular feature is supported by the
* {@link TopicMapSystem}.
- *
+ * <p>
* Opposite to {@link #getFeature} this method returns if the requested
* feature is generally available / supported by the underlying
* {@link TopicMapSystem} and does not return the state (enabled/disabled)
* of the feature.
+ * </p>
*
* @param featureName The name of the feature to check.
* @return <tt>true</tt> if the requested feature is supported,
@@ -83,9 +84,10 @@
/**
* Sets a particular feature in the underlying implementation of
* {@link TopicMapSystem}.
- *
+ * <p>
* A list of the core features can be found at
* <a href="http://tmapi.org/features/">http://tmapi.org/features/</a>.
+ * </p>
*
* @param featureName The name of the feature to be set.
* @param enable <tt>true</tt> to enable the feature,
@@ -102,9 +104,10 @@
/**
* Gets the value of a property in the underlying implementation of
* {@link TopicMapSystem}.
- *
+ * <p>
* A list of the core properties defined by TMAPI can be found at
* <a href="http://tmapi.org/properties/">http://tmapi.org/properties/</a>.
+ * </p>
*
* An implementation is free to support properties other than the core ones.
*
@@ -117,10 +120,10 @@
/**
* Sets a property in the underlying implementation of
* {@link TopicMapSystem}.
- *
+ * <p>
* A list of the core properties defined by TMAPI can be found at
* <a href="http://tmapi.org/properties/">http://tmapi.org/properties/</a>.
- *
+ * </p>
* An implementation is free to support properties other than the core ones.
*
* @param propertyName The name of the property to be set.
@@ -189,6 +192,7 @@
* @throws FactoryConfigurationException
* If the specified implementation class could not be loaded.
*/
+ @SuppressWarnings("unchecked")
private static Class<? extends TopicMapSystemFactory> getImplementationClass()
throws FactoryConfigurationException {
String implClassName = getClassNameFromProperties();
Modified: trunk/src/main/java/org/tmapi/core/Typed.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Typed.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/Typed.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -19,7 +19,7 @@
* {@link Association}s, {@link Role}s, {@link Occurrence}s, and
* {@link Name}s are typed.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Typed extends Construct {
Modified: trunk/src/main/java/org/tmapi/core/Variant.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Variant.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/core/Variant.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -19,7 +19,7 @@
* Represents a
* <a href="http://www.isotopicmaps.org/sam/sam-model/#sect-variant">variant item</a>.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Variant extends DatatypeAware {
Modified: trunk/src/main/java/org/tmapi/index/Index.java
===================================================================
--- trunk/src/main/java/org/tmapi/index/Index.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/index/Index.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -16,7 +16,7 @@
/**
* Base interface for all indices.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface Index {
@@ -43,12 +43,13 @@
/**
* Indicates whether the index is updated automatically.
- *
+ * <p>
* If the value is <tt>true</tt>, then the index is automatically kept
* synchronized with the topic map as values are changed.
* If the value is <tt>false</tt>, then the {@link Index#reindex()}
* method must be called to resynchronize the index with the topic map
* after values are changed.
+ * </p>
*
* @return <tt>true</tt> if index is updated automatically, <tt>false</tt> otherwise.
*/
Modified: trunk/src/main/java/org/tmapi/index/LiteralIndex.java
===================================================================
--- trunk/src/main/java/org/tmapi/index/LiteralIndex.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/index/LiteralIndex.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -23,7 +23,7 @@
/**
* Index for literal values stored in a topic map.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface LiteralIndex extends Index {
@@ -43,12 +43,12 @@
/**
* Returns the {@link Occurrence}s in the topic map whose value property
* matches the IRI represented by <tt>value</tt>.
- *
+ * <p>
* Those {@link Occurrence}s which have a datatype equal to
* <a href="http://www.w3.org/TR/xmlschema-2/#anyURI">xsd:anyURI</a>
* and their value property is equal to {@link Locator#getReference()}
* are returned.
- *
+ * </p>
* The return value may be empty but must never be <tt>null</tt>.
*
* @param value The value of the {@link Occurrence}s to be returned.
@@ -83,12 +83,12 @@
/**
* Returns the {@link Variant}s in the topic map whose value property
* matches the IRI represented by <tt>value</tt>.
- *
+ * <p>
* Those {@link Variant}s which have a datatype equal to
* <a href="http://www.w3.org/TR/xmlschema-2/#anyURI">xsd:anyURI</a>
* and their value property is equal to {@link Locator#getReference()}
* are returned.
- *
+ * </p>
* The return value may be empty but must never be <tt>null</tt>.
*
* @param value The value of the {@link Variant}s to be returned.
Modified: trunk/src/main/java/org/tmapi/index/ScopedIndex.java
===================================================================
--- trunk/src/main/java/org/tmapi/index/ScopedIndex.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/index/ScopedIndex.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -28,7 +28,7 @@
* {@link Name}s, and {@link Variant}s by their scope property and to
* {@link Topic}s which are used as theme in a scope.
*
- * @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
+ * @author <a href="http://tmapi.org/">The TMAPI Project</a>
* @version $Rev$ - $Date$
*/
public interface ScopedIndex extends Index {
Modified: trunk/src/main/java/org/tmapi/index/TypeInstanceIndex.java
===================================================================
--- trunk/src/main/java/org/tmapi/index/TypeInstanceIndex.java 2008-08-07 11:25:25 UTC (rev 61)
+++ trunk/src/main/java/org/tmapi/index/TypeInstanceIndex.java 2008-08-08 12:00:50 UTC (rev 62)
@@ -24,29 +24,30 @@
/**
* Index for type-instance relationships between {@link Topic}s
* and for {@link org.tmapi.core.Typed} Topic Maps constructs.
- *
+ * <p>
* This index provides access to {@link Topic}s used in
* <a href="http://www.isotopicmaps.org/sam/sam-model/#sect-types">type-instan...
[truncated message content] |
|
From: <lh...@us...> - 2008-08-07 11:25:18
|
Revision: 61
http://tmapi.svn.sourceforge.net/tmapi/?rev=61&view=rev
Author: lheuer
Date: 2008-08-07 11:25:25 +0000 (Thu, 07 Aug 2008)
Log Message:
-----------
- More tests
- Initial TestLiteralIndex
Modified Paths:
--------------
trunk/src/test/java/org/tmapi/core/TestAssociation.java
trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
trunk/src/test/java/org/tmapi/core/TestName.java
trunk/src/test/java/org/tmapi/core/TestTopicMap.java
trunk/src/test/java/org/tmapi/index/AllIndexTests.java
trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java
trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
trunk/src/test/java/org/tmapi/index/TestTypeInstanceIndex.java
Modified: trunk/src/test/java/org/tmapi/core/TestAssociation.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestAssociation.java 2008-08-06 15:33:10 UTC (rev 60)
+++ trunk/src/test/java/org/tmapi/core/TestAssociation.java 2008-08-07 11:25:25 UTC (rev 61)
@@ -45,6 +45,9 @@
parent.getAssociations().isEmpty());
}
+ /**
+ * Test the creation of roles.
+ */
public void testRoleCreation() {
final Association assoc = createAssociation();
assertTrue("Expected no roles in a newly created association",
@@ -59,6 +62,9 @@
assertTrue(player.getRolesPlayed().contains(role));
}
+ /**
+ * Tests {@link Association#getRoleTypes()}
+ */
public void testRoleTypes() {
final Association assoc = createAssociation();
final Topic type1 = createTopic();
@@ -87,6 +93,9 @@
assertEquals(0, assoc.getRoleTypes().size());
}
+ /**
+ * Tests {@link Association#getRoles(Topic)}
+ */
public void testRoleFilter() {
final Association assoc = createAssociation();
final Topic type1 = createTopic();
Modified: trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-06 15:33:10 UTC (rev 60)
+++ trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-07 11:25:25 UTC (rev 61)
@@ -175,6 +175,161 @@
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 (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testIllegalStringValue() {
+ final DatatypeAware dt = getDatatypeAware();
+ try {
+ dt.setValue((String)null);
+ fail("datatypeAware.setValue((String)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testIllegalStringValueExplicit() {
+ final DatatypeAware dt = getDatatypeAware();
+ try {
+ dt.setValue(null, _xsdString);
+ fail("datatypeAware.setValue(null, datatype) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testIllegalLocatorValue() {
+ final DatatypeAware dt = getDatatypeAware();
+ try {
+ dt.setValue((Locator)null);
+ fail("datatypeAware.setValue((Locator)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testIllegalIntegerValue() {
+ final DatatypeAware dt = getDatatypeAware();
+ try {
+ dt.setValue((BigInteger)null);
+ fail("datatypeAware.setValue((BigInteger)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testIllegalDecimalValue() {
+ final DatatypeAware dt = getDatatypeAware();
+ try {
+ dt.setValue((BigDecimal)null);
+ fail("datatypeAware.setValue((BigDecimal)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testIllegalFloatValue() {
+ final DatatypeAware dt = getDatatypeAware();
+ try {
+ dt.setValue((Float)null);
+ fail("datatypeAware.setValue((Float)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testIllegalLongValue() {
+ final DatatypeAware dt = getDatatypeAware();
+ try {
+ dt.setValue((Long)null);
+ fail("datatypeAware.setValue((Long)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testIllegalIntValue() {
+ final DatatypeAware dt = getDatatypeAware();
+ try {
+ dt.setValue((Integer)null);
+ fail("datatypeAware.setValue((Integer)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
protected void assertFailInteger(final DatatypeAware dt) {
try {
dt.integerValue();
Modified: trunk/src/test/java/org/tmapi/core/TestName.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestName.java 2008-08-06 15:33:10 UTC (rev 60)
+++ trunk/src/test/java/org/tmapi/core/TestName.java 2008-08-07 11:25:25 UTC (rev 61)
@@ -136,6 +136,21 @@
}
}
+ public void testVariantCreationIllegalScope() {
+ final Name name = createName();
+ final Topic theme = createTopic();
+ name.addTheme(theme);
+ assertEquals(1, name.getScope().size());
+ assertTrue(name.getScope().contains(theme));
+ try {
+ name.createVariant("Variant", theme);
+ fail("The variant would be in the same scope as the parent");
+ }
+ catch (ModelConstraintException ex) {
+ // noop.
+ }
+ }
+
public void testVariantCreationIllegalEmptyScope() {
final Name name = createName();
try {
@@ -143,7 +158,7 @@
fail("Creation of a variant with an empty scope is not allowed");
}
catch (Exception ex) {
-
+ // noop.
}
}
@@ -154,7 +169,7 @@
fail("Creation of a variant with a null scope is not allowed");
}
catch (Exception ex) {
-
+ // noop.
}
}
}
Modified: trunk/src/test/java/org/tmapi/core/TestTopicMap.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicMap.java 2008-08-06 15:33:10 UTC (rev 60)
+++ trunk/src/test/java/org/tmapi/core/TestTopicMap.java 2008-08-07 11:25:25 UTC (rev 61)
@@ -222,26 +222,10 @@
* Test index.
*/
private static class BogusIndex implements Index {
-
- @Override
public void close() {}
-
- @Override
- public boolean isAutoUpdated() {
- return false;
- }
-
- @Override
- public boolean isOpen() {
- return false;
- }
-
- @Override
- public void open() {
- }
-
- @Override
+ public boolean isAutoUpdated() { return false; }
+ public boolean isOpen() { return false; }
+ public void open() { }
public void reindex() {}
-
}
}
Modified: trunk/src/test/java/org/tmapi/index/AllIndexTests.java
===================================================================
--- trunk/src/test/java/org/tmapi/index/AllIndexTests.java 2008-08-06 15:33:10 UTC (rev 60)
+++ trunk/src/test/java/org/tmapi/index/AllIndexTests.java 2008-08-07 11:25:25 UTC (rev 61)
@@ -20,7 +20,7 @@
* Provides a test suite which contains all test cases for the .index package.
*
* @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class AllIndexTests extends TestSuite {
Modified: trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java
===================================================================
--- trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java 2008-08-06 15:33:10 UTC (rev 60)
+++ trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java 2008-08-07 11:25:25 UTC (rev 61)
@@ -13,17 +13,24 @@
*/
package org.tmapi.index;
+import org.tmapi.core.Locator;
+import org.tmapi.core.Name;
+import org.tmapi.core.Occurrence;
import org.tmapi.core.TMAPITestCase;
+import org.tmapi.core.Topic;
+import org.tmapi.core.Variant;
/**
* Tests against the {@link LiteralInstanceIndex} interface.
*
* @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestLiteralIndex extends TMAPITestCase {
private LiteralIndex _litIdx;
+ private Locator _xsdString;
+ private Locator _xsdAnyURI;
public TestLiteralIndex(String name) {
super(name);
@@ -37,6 +44,9 @@
super.setUp();
_litIdx = (LiteralIndex) _tm.getIndex(LiteralIndex.class);
_litIdx.open();
+ final String XSD_BASE = "http://www.w3.org/2001/XMLSchema#";
+ _xsdString = createLocator(XSD_BASE + "string");
+ _xsdAnyURI = createLocator(XSD_BASE + "anyURI");
}
/* (non-Javadoc)
@@ -55,4 +65,262 @@
}
}
+ public void testName() {
+ final String value = "Value";
+ final String value2 = "Value2";
+ _updateIndex();
+ assertEquals(0, _litIdx.getNames(value).size());
+ final Name name = createTopic().createName(value);
+ _updateIndex();
+ assertEquals(1, _litIdx.getNames(value).size());
+ assertTrue(_litIdx.getNames(value).contains(name));
+ name.setValue(value2);
+ _updateIndex();
+ assertEquals(0, _litIdx.getNames(value).size());
+ assertEquals(1, _litIdx.getNames(value2).size());
+ assertTrue(_litIdx.getNames(value2).contains(name));
+ name.remove();
+ _updateIndex();
+ assertEquals(0, _litIdx.getNames(value).size());
+ assertEquals(0, _litIdx.getNames(value2).size());
+ }
+
+ public void testNameIllegalString() {
+ try {
+ _litIdx.getNames(null);
+ fail("getNames(null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testOccurrenceString() {
+ final String value = "Value";
+ final String value2 = "Value2";
+ _updateIndex();
+ assertEquals(0, _litIdx.getOccurrences(value).size());
+ assertEquals(0, _litIdx.getOccurrences(value, _xsdString).size());
+ final Topic type = createTopic();
+ final Occurrence occ = createTopic().createOccurrence(type, value);
+ _updateIndex();
+ assertEquals(1, _litIdx.getOccurrences(value).size());
+ assertTrue(_litIdx.getOccurrences(value).contains(occ));
+ assertEquals(1, _litIdx.getOccurrences(value, _xsdString).size());
+ assertTrue(_litIdx.getOccurrences(value, _xsdString).contains(occ));
+ occ.setValue(value2);
+ _updateIndex();
+ assertEquals(0, _litIdx.getOccurrences(value).size());
+ assertEquals(0, _litIdx.getOccurrences(value, _xsdString).size());
+ assertEquals(1, _litIdx.getOccurrences(value2).size());
+ assertTrue(_litIdx.getOccurrences(value2).contains(occ));
+ assertEquals(1, _litIdx.getOccurrences(value2, _xsdString).size());
+ assertTrue(_litIdx.getOccurrences(value2, _xsdString).contains(occ));
+ occ.remove();
+ _updateIndex();
+ assertEquals(0, _litIdx.getOccurrences(value).size());
+ assertEquals(0, _litIdx.getOccurrences(value, _xsdString).size());
+ assertEquals(0, _litIdx.getOccurrences(value2).size());
+ assertEquals(0, _litIdx.getOccurrences(value2, _xsdString).size());
+ }
+
+ public void testOccurrenceURI() {
+ final Locator value = createLocator("http://www.example.org/1");
+ final Locator value2 = createLocator("http://www.example.org/2");
+ _updateIndex();
+ assertEquals(0, _litIdx.getOccurrences(value).size());
+ assertEquals(0, _litIdx.getOccurrences(value.getReference(), _xsdAnyURI).size());
+ final Topic type = createTopic();
+ final Occurrence occ = createTopic().createOccurrence(type, value);
+ _updateIndex();
+ assertEquals(1, _litIdx.getOccurrences(value).size());
+ assertTrue(_litIdx.getOccurrences(value).contains(occ));
+ assertEquals(1, _litIdx.getOccurrences(value.getReference(), _xsdAnyURI).size());
+ assertTrue(_litIdx.getOccurrences(value.getReference(), _xsdAnyURI).contains(occ));
+ occ.setValue(value2);
+ _updateIndex();
+ assertEquals(0, _litIdx.getOccurrences(value).size());
+ assertEquals(0, _litIdx.getOccurrences(value.getReference(), _xsdAnyURI).size());
+ assertEquals(1, _litIdx.getOccurrences(value2).size());
+ assertTrue(_litIdx.getOccurrences(value2).contains(occ));
+ assertEquals(1, _litIdx.getOccurrences(value2.getReference(), _xsdAnyURI).size());
+ assertTrue(_litIdx.getOccurrences(value2.getReference(), _xsdAnyURI).contains(occ));
+ occ.remove();
+ _updateIndex();
+ assertEquals(0, _litIdx.getOccurrences(value).size());
+ assertEquals(0, _litIdx.getOccurrences(value.getReference(), _xsdAnyURI).size());
+ assertEquals(0, _litIdx.getOccurrences(value2).size());
+ assertEquals(0, _litIdx.getOccurrences(value2.getReference(), _xsdAnyURI).size());
+ }
+
+ public void testOccurrenceExplicitDatatype() {
+ final String value = "http://www.example.org/1";
+ final String value2 = "http://www.example.org/2";
+ final Locator datatype = createLocator("http://www.example.org/datatype");
+ _updateIndex();
+ assertEquals(0, _litIdx.getOccurrences(value).size());
+ assertEquals(0, _litIdx.getOccurrences(value, datatype).size());
+ final Topic type = createTopic();
+ final Occurrence occ = createTopic().createOccurrence(type, value, datatype);
+ _updateIndex();
+ assertEquals(0, _litIdx.getOccurrences(value).size());
+ assertEquals(1, _litIdx.getOccurrences(value, datatype).size());
+ assertTrue(_litIdx.getOccurrences(value, datatype).contains(occ));
+ occ.setValue(value2, datatype);
+ _updateIndex();
+ assertEquals(0, _litIdx.getOccurrences(value).size());
+ assertEquals(0, _litIdx.getOccurrences(value, datatype).size());
+ assertEquals(0, _litIdx.getOccurrences(value2).size());
+ assertEquals(1, _litIdx.getOccurrences(value2, datatype).size());
+ assertTrue(_litIdx.getOccurrences(value2, datatype).contains(occ));
+ occ.remove();
+ _updateIndex();
+ assertEquals(0, _litIdx.getOccurrences(value2).size());
+ assertEquals(0, _litIdx.getOccurrences(value2, datatype).size());
+ }
+
+ public void testOccurrenceIllegalString() {
+ try {
+ _litIdx.getOccurrences((String)null);
+ fail("getOccurrences((String)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testOccurrenceIllegalURI() {
+ try {
+ _litIdx.getOccurrences((Locator)null);
+ fail("getOccurrences((Locator)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testOccurrenceIllegalDatatype() {
+ try {
+ _litIdx.getOccurrences("value", null);
+ fail("getOccurrences(\"value\", null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testVariantString() {
+ final String value = "Value";
+ final String value2 = "Value2";
+ _updateIndex();
+ assertEquals(0, _litIdx.getVariants(value).size());
+ assertEquals(0, _litIdx.getVariants(value, _xsdString).size());
+ final Topic theme = createTopic();
+ final Variant variant = createName().createVariant(value, theme);
+ _updateIndex();
+ assertEquals(1, _litIdx.getVariants(value).size());
+ assertTrue(_litIdx.getVariants(value).contains(variant));
+ assertEquals(1, _litIdx.getVariants(value, _xsdString).size());
+ assertTrue(_litIdx.getVariants(value, _xsdString).contains(variant));
+ variant.setValue(value2);
+ _updateIndex();
+ assertEquals(0, _litIdx.getVariants(value).size());
+ assertEquals(0, _litIdx.getVariants(value, _xsdString).size());
+ assertEquals(1, _litIdx.getVariants(value2).size());
+ assertTrue(_litIdx.getVariants(value2).contains(variant));
+ assertEquals(1, _litIdx.getVariants(value2, _xsdString).size());
+ assertTrue(_litIdx.getVariants(value2, _xsdString).contains(variant));
+ variant.remove();
+ _updateIndex();
+ assertEquals(0, _litIdx.getVariants(value).size());
+ assertEquals(0, _litIdx.getVariants(value, _xsdString).size());
+ assertEquals(0, _litIdx.getVariants(value2).size());
+ assertEquals(0, _litIdx.getVariants(value2, _xsdString).size());
+ }
+
+ public void testVariantURI() {
+ final Locator value = createLocator("http://www.example.org/1");
+ final Locator value2 = createLocator("http://www.example.org/2");
+ _updateIndex();
+ assertEquals(0, _litIdx.getVariants(value).size());
+ assertEquals(0, _litIdx.getVariants(value.getReference(), _xsdAnyURI).size());
+ final Topic theme = createTopic();
+ final Variant variant = createName().createVariant(value, theme);
+ _updateIndex();
+ assertEquals(1, _litIdx.getVariants(value).size());
+ assertTrue(_litIdx.getVariants(value).contains(variant));
+ assertEquals(1, _litIdx.getVariants(value.getReference(), _xsdAnyURI).size());
+ assertTrue(_litIdx.getVariants(value.getReference(), _xsdAnyURI).contains(variant));
+ variant.setValue(value2);
+ _updateIndex();
+ assertEquals(0, _litIdx.getVariants(value).size());
+ assertEquals(0, _litIdx.getVariants(value.getReference(), _xsdAnyURI).size());
+ assertEquals(1, _litIdx.getVariants(value2).size());
+ assertTrue(_litIdx.getVariants(value2).contains(variant));
+ assertEquals(1, _litIdx.getVariants(value2.getReference(), _xsdAnyURI).size());
+ assertTrue(_litIdx.getVariants(value2.getReference(), _xsdAnyURI).contains(variant));
+ variant.remove();
+ _updateIndex();
+ assertEquals(0, _litIdx.getVariants(value).size());
+ assertEquals(0, _litIdx.getVariants(value.getReference(), _xsdAnyURI).size());
+ assertEquals(0, _litIdx.getVariants(value2).size());
+ assertEquals(0, _litIdx.getVariants(value2.getReference(), _xsdAnyURI).size());
+ }
+
+ public void testVariantExplicitDatatype() {
+ final String value = "http://www.example.org/1";
+ final String value2 = "http://www.example.org/2";
+ final Locator datatype = createLocator("http://www.example.org/datatype");
+ _updateIndex();
+ assertEquals(0, _litIdx.getVariants(value).size());
+ assertEquals(0, _litIdx.getVariants(value, datatype).size());
+ final Topic theme = createTopic();
+ final Variant variant = createName().createVariant(value, datatype, theme);
+ _updateIndex();
+ assertEquals(0, _litIdx.getVariants(value).size());
+ assertEquals(1, _litIdx.getVariants(value, datatype).size());
+ assertTrue(_litIdx.getVariants(value, datatype).contains(variant));
+ variant.setValue(value2, datatype);
+ _updateIndex();
+ assertEquals(0, _litIdx.getVariants(value).size());
+ assertEquals(0, _litIdx.getVariants(value, datatype).size());
+ assertEquals(0, _litIdx.getVariants(value2).size());
+ assertEquals(1, _litIdx.getVariants(value2, datatype).size());
+ assertTrue(_litIdx.getVariants(value2, datatype).contains(variant));
+ variant.remove();
+ _updateIndex();
+ assertEquals(0, _litIdx.getVariants(value2).size());
+ assertEquals(0, _litIdx.getVariants(value2, datatype).size());
+ }
+
+ public void testVariantIllegalString() {
+ try {
+ _litIdx.getVariants((String)null);
+ fail("getVariants((String)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testVariantIllegalURI() {
+ try {
+ _litIdx.getVariants((Locator)null);
+ fail("getVariants((Locator)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testVariantIllegalDatatype() {
+ try {
+ _litIdx.getVariants("value", null);
+ fail("getVariants(\"value\", null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
}
Modified: trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
===================================================================
--- trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-06 15:33:10 UTC (rev 60)
+++ trunk/src/test/java/org/tmapi/index/TestScopedIndex.java 2008-08-07 11:25:25 UTC (rev 61)
@@ -25,7 +25,7 @@
* Tests against the {@link ScopedIndex} interface.
*
* @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestScopedIndex extends TMAPITestCase {
Modified: trunk/src/test/java/org/tmapi/index/TestTypeInstanceIndex.java
===================================================================
--- trunk/src/test/java/org/tmapi/index/TestTypeInstanceIndex.java 2008-08-06 15:33:10 UTC (rev 60)
+++ trunk/src/test/java/org/tmapi/index/TestTypeInstanceIndex.java 2008-08-07 11:25:25 UTC (rev 61)
@@ -24,7 +24,7 @@
* Tests against the {@link TypeInstanceIndex} interface.
*
* @author TMAPI <a href="http://www.tmapi.org">tmapi.org</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class TestTypeInstanceIndex extends TMAPITestCase {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-08-06 16:18:29
|
Revision: 60
http://tmapi.svn.sourceforge.net/tmapi/?rev=60&view=rev
Author: lheuer
Date: 2008-08-06 15:33:10 +0000 (Wed, 06 Aug 2008)
Log Message:
-----------
Added test for TopicMap.getIndex
Modified Paths:
--------------
trunk/src/test/java/org/tmapi/core/TestTopicMap.java
Modified: trunk/src/test/java/org/tmapi/core/TestTopicMap.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicMap.java 2008-08-06 15:06:53 UTC (rev 59)
+++ trunk/src/test/java/org/tmapi/core/TestTopicMap.java 2008-08-06 15:33:10 UTC (rev 60)
@@ -16,6 +16,8 @@
import java.util.Collection;
import java.util.Collections;
+import org.tmapi.index.Index;
+
/**
* Tests against the {@link TopicMap} interface.
*
@@ -206,4 +208,40 @@
}
}
+ public void testGetIndex() {
+ try {
+ _tm.getIndex(BogusIndex.class);
+ fail("Exception expected for an unknown index");
+ }
+ catch (UnsupportedOperationException ex) {
+ // noop.
+ }
+ }
+
+ /**
+ * Test index.
+ */
+ private static class BogusIndex implements Index {
+
+ @Override
+ public void close() {}
+
+ @Override
+ public boolean isAutoUpdated() {
+ return false;
+ }
+
+ @Override
+ public boolean isOpen() {
+ return false;
+ }
+
+ @Override
+ public void open() {
+ }
+
+ @Override
+ public void reindex() {}
+
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-08-06 15:06:45
|
Revision: 59
http://tmapi.svn.sourceforge.net/tmapi/?rev=59&view=rev
Author: lheuer
Date: 2008-08-06 15:06:53 +0000 (Wed, 06 Aug 2008)
Log Message:
-----------
More DatatypeAware tests
Modified Paths:
--------------
trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
Modified: trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-06 14:54:56 UTC (rev 58)
+++ trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-06 15:06:53 UTC (rev 59)
@@ -93,6 +93,36 @@
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();
@@ -119,6 +149,32 @@
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());
+ }
+
protected void assertFailInteger(final DatatypeAware dt) {
try {
dt.integerValue();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-08-06 14:54:46
|
Revision: 58
http://tmapi.svn.sourceforge.net/tmapi/?rev=58&view=rev
Author: lheuer
Date: 2008-08-06 14:54:56 +0000 (Wed, 06 Aug 2008)
Log Message:
-----------
Aligned test to Exception change in DatatypeAware
Modified Paths:
--------------
trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
Modified: trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-06 14:04:00 UTC (rev 57)
+++ trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-06 14:54:56 UTC (rev 58)
@@ -13,6 +13,7 @@
*/
package org.tmapi.core;
+import java.math.BigDecimal;
import java.math.BigInteger;
/**
@@ -77,7 +78,6 @@
assertFailFloat(dt);
assertFailLong(dt);
assertFailDecimal(dt);
- assertFailLocator(dt);
}
public void testStringExplicit() {
@@ -91,7 +91,6 @@
assertFailFloat(dt);
assertFailLong(dt);
assertFailDecimal(dt);
- assertFailLocator(dt);
}
public void testInteger() {
@@ -101,24 +100,23 @@
assertEquals(value.toString(), dt.getValue());
assertEquals(_xsdInteger, dt.getDatatype());
assertEquals(value, dt.integerValue());
- assertFailInt(dt);
- assertFailFloat(dt);
- assertFailLong(dt);
- assertFailDecimal(dt);
- assertFailLocator(dt);
+ 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, dt.getValue());
+ assertEquals(value.toString(), dt.getValue());
assertEquals(_xsdInteger, dt.getDatatype());
- assertFailInt(dt);
- assertFailFloat(dt);
- assertFailLong(dt);
- assertFailDecimal(dt);
- assertFailLocator(dt);
+ assertEquals(value, dt.integerValue());
+ assertEquals(BigDecimal.TEN, dt.decimalValue());
+ assertEquals(10L, dt.longValue());
+ assertEquals(10, dt.intValue());
+ assertEquals(10.0F, dt.floatValue());
}
protected void assertFailInteger(final DatatypeAware dt) {
@@ -126,7 +124,7 @@
dt.integerValue();
fail("Expected a failure for converting the value to 'BigInteger'");
}
- catch (IllegalStateException ex) {
+ catch (NumberFormatException ex) {
// noop.
}
}
@@ -136,7 +134,7 @@
dt.intValue();
fail("Expected a failure for converting the value to 'int'");
}
- catch (IllegalStateException ex) {
+ catch (NumberFormatException ex) {
// noop.
}
}
@@ -146,7 +144,7 @@
dt.floatValue();
fail("Expected a failure for converting the value to 'float'");
}
- catch (IllegalStateException ex) {
+ catch (NumberFormatException ex) {
// noop.
}
}
@@ -156,7 +154,7 @@
dt.decimalValue();
fail("Expected a failure for converting the value to 'BigDecimal'");
}
- catch (IllegalStateException ex) {
+ catch (NumberFormatException ex) {
// noop.
}
}
@@ -166,7 +164,7 @@
dt.longValue();
fail("Expected a failure for converting the value to 'long'");
}
- catch (IllegalStateException ex) {
+ catch (NumberFormatException ex) {
// noop.
}
}
@@ -176,7 +174,7 @@
dt.locatorValue();
fail("Expected a failure for converting the value to 'Locator'");
}
- catch (IllegalStateException ex) {
+ catch (IllegalArgumentException ex) {
// noop.
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-08-06 14:03:52
|
Revision: 57
http://tmapi.svn.sourceforge.net/tmapi/?rev=57&view=rev
Author: lheuer
Date: 2008-08-06 14:04:00 +0000 (Wed, 06 Aug 2008)
Log Message:
-----------
"topic map" -> "Topic Maps" where it fits
Modified Paths:
--------------
trunk/README.txt
Modified: trunk/README.txt
===================================================================
--- trunk/README.txt 2008-08-06 13:56:44 UTC (rev 56)
+++ trunk/README.txt 2008-08-06 14:04:00 UTC (rev 57)
@@ -1,36 +1,36 @@
TMAPI 2.0
=========
-1. What is TMAPI ?
-2. How do I run it ?
+1. What is TMAPI?
+2. How do I run it?
3. Reporting Bugs
4. Legal stuff
-1. What is TMAPI ?
-------------------
+1. What is TMAPI?
+-----------------
TMAPI is an open-source effort to define a set of common APIs for programming
-against topic map processing engines. The goal of TMAPI is to allow developers
-to create Java code which is portable between different topic map processors
+against Topic Maps processing engines. The goal of TMAPI is to allow developers
+to create Java code which is portable between different Topic Maps processors
with minimal code changes.
This release of TMAPI defines:
- 1) A collection of interfaces for the topic map data model, exposing topic
+ 1) A collection of interfaces for the Topic Maps - Data Model, exposing topic
maps, topics, occurrences and so on to the programmer.
- 2) A set of interfaces for initialising access to a topic map processing
+ 2) A set of interfaces for initialising access to a Topic Maps processing
system and the topic maps that it manages.
3) A basic interface for indexes of topic map data.
4) A set of core indexes of topic map information covering the most commonly
used indexes.
TMAPI is built for extensibility and will in future be extended to define
-interface packages for topic map parsers; query engines; and other topic map
+interface packages for topic map parsers; query engines; and other Topic Maps
processing tools as needed.
-2. How do I run it ?
---------------------
-TMAPI is NOT a topic map processor! There is really nothing to run except for
+2. How do I run it?
+-------------------
+TMAPI is NOT a Topic Maps processor! There is really nothing to run except for
the conformance tests. To run an application that uses TMAPI you will need a
-conformant topic map processor implementation. There are several TMAPI
+conformant Topic Maps processor implementation. There are several TMAPI
implementations available. Up-to-date details can be found on the TMAPI website
at http://www.tmapi.org/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-08-06 13:56:35
|
Revision: 56
http://tmapi.svn.sourceforge.net/tmapi/?rev=56&view=rev
Author: lheuer
Date: 2008-08-06 13:56:44 +0000 (Wed, 06 Aug 2008)
Log Message:
-----------
- DatatypeAware: Switched from IllegalStateException to NumberFormatException and IllegalArgumentException
- TestTopicMerge: Removed unnecessary Exception declaration
Modified Paths:
--------------
trunk/src/main/java/org/tmapi/core/DatatypeAware.java
trunk/src/test/java/org/tmapi/core/TestTopicMerge.java
Modified: trunk/src/main/java/org/tmapi/core/DatatypeAware.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/DatatypeAware.java 2008-08-06 12:35:05 UTC (rev 55)
+++ trunk/src/main/java/org/tmapi/core/DatatypeAware.java 2008-08-06 13:56:44 UTC (rev 56)
@@ -130,7 +130,7 @@
* Returns the <tt>int</tt> representation of the value.
*
* @return An <tt>int</tt> representation of the value.
- * @throws IllegalStateException If the value cannot be represented as
+ * @throws NumberFormatException If the value cannot be represented as
* a <tt>int</tt>.
*/
public int intValue();
@@ -139,7 +139,7 @@
* Returns the {@link BigInteger} representation of the value.
*
* @return A {@link BigInteger} representation of the value.
- * @throws IllegalStateException If the value cannot be represented as
+ * @throws NumberFormatException If the value cannot be represented as
* a {@link BigInteger} instance.
*/
public BigInteger integerValue();
@@ -148,7 +148,7 @@
* Returns the <tt>float</tt> representation of the value.
*
* @return A <tt>float</tt> representation of the value.
- * @throws IllegalStateException If the value cannot be represented as
+ * @throws NumberFormatException If the value cannot be represented as
* a <tt>float</tt>.
*/
public float floatValue();
@@ -157,7 +157,7 @@
* Returns the {@link BigDecimal} representation of the value.
*
* @return A {@link BigDecimal} representation of the value.
- * @throws IllegalStateException If the value cannot be represented as
+ * @throws NumberFormatException If the value cannot be represented as
* a {@link BigDecimal} instance.
*/
public BigDecimal decimalValue();
@@ -166,7 +166,7 @@
* Returns the <tt>long</tt> representation of the value.
*
* @return A <tt>long</tt> representation of the value.
- * @throws IllegalStateException If the value cannot be represented as
+ * @throws NumberFormatException If the value cannot be represented as
* a <tt>long</tt>.
*/
public long longValue();
@@ -175,7 +175,7 @@
* Returns the {@link Locator} representation of the value.
*
* @return A {@link Locator} representation of the value.
- * @throws IllegalStateException If the value cannot be represented as
+ * @throws IllegalArgumentException If the value cannot be represented as
* a {@link Locator} instance.
*/
public Locator locatorValue();
Modified: trunk/src/test/java/org/tmapi/core/TestTopicMerge.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicMerge.java 2008-08-06 12:35:05 UTC (rev 55)
+++ trunk/src/test/java/org/tmapi/core/TestTopicMerge.java 2008-08-06 13:56:44 UTC (rev 56)
@@ -25,10 +25,10 @@
super(name);
}
- /*
+ /**
*Tests if the types are merged too
*/
- public void testTypesMerged() throws Exception {
+ public void testTypesMerged() {
Topic t1 = createTopic();
Topic t2 = createTopic();
Topic t3 = createTopic();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lh...@us...> - 2008-08-06 12:34:56
|
Revision: 55
http://tmapi.svn.sourceforge.net/tmapi/?rev=55&view=rev
Author: lheuer
Date: 2008-08-06 12:35:05 +0000 (Wed, 06 Aug 2008)
Log Message:
-----------
- Fixed test
Modified Paths:
--------------
trunk/src/test/java/org/tmapi/core/TestTopicMerge.java
Modified: trunk/src/test/java/org/tmapi/core/TestTopicMerge.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicMerge.java 2008-08-05 12:18:47 UTC (rev 54)
+++ trunk/src/test/java/org/tmapi/core/TestTopicMerge.java 2008-08-06 12:35:05 UTC (rev 55)
@@ -180,8 +180,9 @@
Name name = (Name) topic1.getNames().iterator().next();
Topic reifier = null;
for (Topic topic: _tm.getTopics()) {
- if (!topic.equals(topic1)) {
+ if (!topic.equals(topic1) && !topic.equals(type)) {
reifier = topic;
+ break;
}
}
assertEquals(reifier, name.getReifier());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tma...@li...> - 2008-08-05 12:18:40
|
Revision: 54
http://tmapi.svn.sourceforge.net/tmapi/?rev=54&view=rev
Author: lheuer
Date: 2008-08-05 12:18:47 +0000 (Tue, 05 Aug 2008)
Log Message:
-----------
Removed version from LICENSE.txt
Modified Paths:
--------------
trunk/LICENSE.txt
Modified: trunk/LICENSE.txt
===================================================================
--- trunk/LICENSE.txt 2008-08-05 11:26:51 UTC (rev 53)
+++ trunk/LICENSE.txt 2008-08-05 12:18:47 UTC (rev 54)
@@ -1,6 +1,4 @@
-TMAPI 2.0
-
-Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+The Topic Maps API (TMAPI), 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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tma...@li...> - 2008-08-05 11:26:47
|
Revision: 53
http://tmapi.svn.sourceforge.net/tmapi/?rev=53&view=rev
Author: lheuer
Date: 2008-08-05 11:26:51 +0000 (Tue, 05 Aug 2008)
Log Message:
-----------
- More .core tests
- Initial .index tests
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/TestAssociation.java
trunk/src/test/java/org/tmapi/core/TestConstruct.java
trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
trunk/src/test/java/org/tmapi/core/TestLocator.java
trunk/src/test/java/org/tmapi/core/TestName.java
trunk/src/test/java/org/tmapi/core/TestOccurrence.java
trunk/src/test/java/org/tmapi/core/TestReified.java
trunk/src/test/java/org/tmapi/core/TestRole.java
trunk/src/test/java/org/tmapi/core/TestScoped.java
trunk/src/test/java/org/tmapi/core/TestTopic.java
trunk/src/test/java/org/tmapi/core/TestTopicMap.java
trunk/src/test/java/org/tmapi/core/TestTopicMapMerge.java
trunk/src/test/java/org/tmapi/core/TestTopicMapSystem.java
trunk/src/test/java/org/tmapi/core/TestTopicMerge.java
trunk/src/test/java/org/tmapi/core/TestTopicMergeDetection.java
trunk/src/test/java/org/tmapi/core/TestTyped.java
trunk/src/test/java/org/tmapi/core/TestVariant.java
Added Paths:
-----------
trunk/src/test/java/org/tmapi/index/AllIndexTests.java
trunk/src/test/java/org/tmapi/index/TestLiteralIndex.java
trunk/src/test/java/org/tmapi/index/TestScopedIndex.java
trunk/src/test/java/org/tmapi/index/TestTypeInstanceIndex.java
Modified: trunk/src/test/java/org/tmapi/core/AllCoreTests.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/AllCoreTests.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/AllCoreTests.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/test/java/org/tmapi/core/TMAPITestCase.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TMAPITestCase.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TMAPITestCase.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/test/java/org/tmapi/core/TestAssociation.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestAssociation.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestAssociation.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
@@ -46,4 +44,114 @@
assertTrue("Expected association set size to decrement for topic map.",
parent.getAssociations().isEmpty());
}
+
+ public void testRoleCreation() {
+ final Association assoc = createAssociation();
+ assertTrue("Expected no roles in a newly created association",
+ assoc.getRoles().isEmpty());
+ final Topic roleType = createTopic();
+ final Topic player = createTopic();
+ assertEquals(0, player.getRolesPlayed().size());
+ final Role role = assoc.createRole(roleType, player);
+ assertEquals("Unexpected role type", roleType, role.getType());
+ assertEquals("Unexpected role player", player, role.getPlayer());
+ assertEquals(1, player.getRolesPlayed().size());
+ assertTrue(player.getRolesPlayed().contains(role));
+ }
+
+ public void testRoleTypes() {
+ final Association assoc = createAssociation();
+ final Topic type1 = createTopic();
+ final Topic type2 = createTopic();
+ assertTrue(assoc.getRoleTypes().isEmpty());
+ final Role role1 = assoc.createRole(type1, createTopic());
+ assertEquals(1, assoc.getRoleTypes().size());
+ assertTrue(assoc.getRoleTypes().contains(type1));
+ final Role role2 = assoc.createRole(type2, createTopic());
+ assertEquals(2, assoc.getRoleTypes().size());
+ assertTrue(assoc.getRoleTypes().contains(type1));
+ assertTrue(assoc.getRoleTypes().contains(type2));
+ final Role role3 = assoc.createRole(type2, createTopic());
+ assertEquals(2, assoc.getRoleTypes().size());
+ assertTrue(assoc.getRoleTypes().contains(type1));
+ assertTrue(assoc.getRoleTypes().contains(type2));
+ role3.remove();
+ assertEquals(2, assoc.getRoleTypes().size());
+ assertTrue(assoc.getRoleTypes().contains(type1));
+ assertTrue(assoc.getRoleTypes().contains(type2));
+ role2.remove();
+ assertEquals(1, assoc.getRoleTypes().size());
+ assertTrue(assoc.getRoleTypes().contains(type1));
+ assertFalse(assoc.getRoleTypes().contains(type2));
+ role1.remove();
+ assertEquals(0, assoc.getRoleTypes().size());
+ }
+
+ public void testRoleFilter() {
+ final Association assoc = createAssociation();
+ final Topic type1 = createTopic();
+ final Topic type2 = createTopic();
+ final Topic unusedType = createTopic();
+ assertTrue(assoc.getRoles(type1).isEmpty());
+ assertTrue(assoc.getRoles(type2).isEmpty());
+ assertTrue(assoc.getRoles(unusedType).isEmpty());
+ final Role role1 = assoc.createRole(type1, createTopic());
+ assertEquals(1, assoc.getRoles(type1).size());
+ assertTrue(assoc.getRoles(type1).contains(role1));
+ assertTrue(assoc.getRoles(type2).isEmpty());
+ assertTrue(assoc.getRoles(unusedType).isEmpty());
+ final Role role2 = assoc.createRole(type2, createTopic());
+ assertEquals(1, assoc.getRoles(type2).size());
+ assertTrue(assoc.getRoles(type2).contains(role2));
+ final Role role3 = assoc.createRole(type2, createTopic());
+ assertEquals(2, assoc.getRoles(type2).size());
+ assertTrue(assoc.getRoles(type2).contains(role2));
+ assertTrue(assoc.getRoles(type2).contains(role3));
+ assertTrue(assoc.getRoles(unusedType).isEmpty());
+ role3.remove();
+ assertEquals(1, assoc.getRoles(type2).size());
+ assertTrue(assoc.getRoles(type2).contains(role2));
+ role2.remove();
+ assertEquals(0, assoc.getRoles(type2).size());
+ role1.remove();
+ assertEquals(0, assoc.getRoles(type1).size());
+ assertEquals(0, assoc.getRoles(unusedType).size());
+ }
+
+ public void testRoleFilterIllegal() {
+ final Association assoc = createAssociation();
+ try {
+ assoc.getRoles(null);
+ fail("getRoles(null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testRoleCreationInvalidPlayer() {
+ final Association assoc = createAssociation();
+ assertTrue("Expected no roles in a newly created association",
+ assoc.getRoles().isEmpty());
+ try {
+ assoc.createRole(createTopic(), null);
+ fail("Role creation where player is null shouldn't be allowed");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testRoleCreationInvalidType() {
+ final Association assoc = createAssociation();
+ assertTrue("Expected no roles in a newly created association",
+ assoc.getRoles().isEmpty());
+ try {
+ assoc.createRole(null, createTopic());
+ fail("Role creation where type is null shouldn't be allowed");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
}
Modified: trunk/src/test/java/org/tmapi/core/TestConstruct.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestConstruct.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestConstruct.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestDatatypeAware.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/test/java/org/tmapi/core/TestLocator.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestLocator.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestLocator.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/test/java/org/tmapi/core/TestName.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestName.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestName.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
@@ -148,4 +146,15 @@
}
}
+
+ public void testVariantCreationIllegalNullScope() {
+ final Name name = createName();
+ try {
+ name.createVariant("Variant", (Topic[])null);
+ fail("Creation of a variant with a null scope is not allowed");
+ }
+ catch (Exception ex) {
+
+ }
+ }
}
Modified: trunk/src/test/java/org/tmapi/core/TestOccurrence.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestOccurrence.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestOccurrence.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
@@ -53,4 +51,5 @@
assertTrue("Expected occurrence set size to decrement for topic.",
parent.getOccurrences().isEmpty());
}
+
}
Modified: trunk/src/test/java/org/tmapi/core/TestReified.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestReified.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestReified.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/test/java/org/tmapi/core/TestRole.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestRole.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestRole.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
@@ -46,37 +44,6 @@
parent.getRoles().isEmpty());
}
- public void testRoleCreation() {
- final Association assoc = createAssociation();
- assertTrue("Expected no roles in a newly created association",
- assoc.getRoles().isEmpty());
- final Topic roleType = createTopic();
- final Topic player = createTopic();
- final Role role = assoc.createRole(roleType, player);
- assertEquals("Unexpected role type", roleType, role.getType());
- assertEquals("Unexpected role player", player, role.getPlayer());
- }
-
- public void testRoleCreationInvalid() {
- final Association assoc = createAssociation();
- assertTrue("Expected no roles in a newly created association",
- assoc.getRoles().isEmpty());
- try {
- assoc.createRole(createTopic(), null);
- fail("Role creation where player is null shouldn't be allowed");
- }
- catch (Exception ex) {
- // noop.
- }
- try {
- assoc.createRole(null, createTopic());
- fail("Role creation where type is null shouldn't be allowed");
- }
- catch (Exception ex) {
- // noop.
- }
- }
-
public void testRolePlayerSetGet() {
final Association assoc = createAssociation();
assertTrue("Expected no roles in a newly created association",
@@ -94,10 +61,10 @@
player2, role.getPlayer());
assertTrue("Role is not reported in getRolesPlayed()",
player2.getRolesPlayed().contains(role));
- assertTrue("'player' does not play the role anymore",
+ assertTrue("'player' should not play the role anymore",
player.getRolesPlayed().isEmpty());
role.setPlayer(player);
- assertEquals("Unexpected role player after setting to player",
+ assertEquals("Unexpected role player after setting to 'player'",
player, role.getPlayer());
try {
role.setPlayer(null);
Modified: trunk/src/test/java/org/tmapi/core/TestScoped.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestScoped.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestScoped.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/test/java/org/tmapi/core/TestTopic.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopic.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestTopic.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
@@ -15,6 +13,10 @@
*/
package org.tmapi.core;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
/**
* Tests against the {@link Topic} interface.
*
@@ -46,4 +48,753 @@
assertTrue("Expected topic set size to decrement for topic map.",
parent.getTopics().isEmpty());
}
+
+ public void testAddSubjectIdentifierIllegal() {
+ Topic topic = createTopic();
+ try {
+ topic.addSubjectIdentifier(null);
+ fail("addSubjectIdentifier(null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testAddSubjectLocatorIllegal() {
+ Topic topic = createTopic();
+ try {
+ topic.addSubjectLocator(null);
+ fail("addSubjectLocator(null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testSubjectIdentifiers() {
+ final Locator loc1 = createLocator("http://www.example.org/1");
+ final Locator loc2 = createLocator("http://www.example.org/2");
+ final Topic topic = _tm.createTopicBySubjectIdentifier(loc1);
+ assertEquals(1, topic.getSubjectIdentifiers().size());
+ assertTrue(topic.getSubjectIdentifiers().contains(loc1));
+ topic.addSubjectIdentifier(loc2);
+ assertEquals(2, topic.getSubjectIdentifiers().size());
+ assertTrue(topic.getSubjectIdentifiers().contains(loc2));
+ topic.removeSubjectIdentifier(loc1);
+ assertEquals(1, topic.getSubjectIdentifiers().size());
+ assertTrue(topic.getSubjectIdentifiers().contains(loc2));
+ }
+
+ public void testSubjectLocators() {
+ final Locator loc1 = createLocator("http://www.example.org/1");
+ final Locator loc2 = createLocator("http://www.example.org/2");
+ final Topic topic = _tm.createTopicBySubjectLocator(loc1);
+ assertEquals(1, topic.getSubjectLocators().size());
+ assertTrue(topic.getSubjectLocators().contains(loc1));
+ topic.addSubjectLocator(loc2);
+ assertEquals(2, topic.getSubjectLocators().size());
+ assertTrue(topic.getSubjectLocators().contains(loc2));
+ topic.removeSubjectLocator(loc1);
+ assertEquals(1, topic.getSubjectLocators().size());
+ assertTrue(topic.getSubjectLocators().contains(loc2));
+ }
+
+ public void testTopicTypes() {
+ final Topic topic = createTopic();
+ final Topic type1 = createTopic();
+ final Topic type2 = createTopic();
+ assertTrue(topic.getTypes().isEmpty());
+ topic.addType(type1);
+ assertEquals(1, topic.getTypes().size());
+ assertTrue(topic.getTypes().contains(type1));
+ topic.addType(type2);
+ assertEquals(2, topic.getTypes().size());
+ assertTrue(topic.getTypes().contains(type2));
+ topic.removeType(type1);
+ assertEquals(1, topic.getTypes().size());
+ assertTrue(topic.getTypes().contains(type2));
+ topic.removeType(type2);
+ assertTrue(topic.getTypes().isEmpty());
+ }
+
+ public void testAddTypeIllegal() {
+ Topic topic = createTopic();
+ try {
+ topic.addType(null);
+ fail("addType(null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testRoleFilter() {
+ final Topic player = createTopic();
+ final Topic type1 = createTopic();
+ final Topic type2 = createTopic();
+ final Topic unusedType = createTopic();
+ final Association assoc = createAssociation();
+ assertEquals(0, player.getRolesPlayed(type1).size());
+ assertEquals(0, player.getRolesPlayed(type2).size());
+ assertEquals(0, player.getRolesPlayed(unusedType).size());
+ final Role role = assoc.createRole(type1, player);
+ assertEquals(1, player.getRolesPlayed(type1).size());
+ assertTrue(player.getRolesPlayed(type1).contains(role));
+ assertEquals(0, player.getRolesPlayed(type2).size());
+ assertEquals(0, player.getRolesPlayed(unusedType).size());
+ role.setType(type2);
+ assertEquals(1, player.getRolesPlayed(type2).size());
+ assertTrue(player.getRolesPlayed(type2).contains(role));
+ assertEquals(0, player.getRolesPlayed(type1).size());
+ assertEquals(0, player.getRolesPlayed(unusedType).size());
+ role.remove();
+ assertEquals(0, player.getRolesPlayed(type1).size());
+ assertEquals(0, player.getRolesPlayed(type2).size());
+ assertEquals(0, player.getRolesPlayed(unusedType).size());
+ }
+
+ public void testRoleFilterIllegal() {
+ final Role role = createRole();
+ final Topic player = role.getPlayer();
+ try {
+ player.getRolesPlayed(null);
+ fail("topic.getRolesPlayed(null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testRoleAssociationFilter() {
+ final Topic player = createTopic();
+ final Topic assocType1 = createTopic();
+ final Topic assocType2 = createTopic();
+ final Topic roleType1 = createTopic();
+ final Topic roleType2 = createTopic();
+ final Association assoc = _tm.createAssociation(assocType1);
+ assertEquals(0, player.getRolesPlayed(roleType1, assocType1).size());
+ assertEquals(0, player.getRolesPlayed(roleType1, assocType2).size());
+ assertEquals(0, player.getRolesPlayed(roleType2, assocType1).size());
+ assertEquals(0, player.getRolesPlayed(roleType2, assocType2).size());
+ final Role role1 = assoc.createRole(roleType1, player);
+ assertEquals(1, player.getRolesPlayed(roleType1, assocType1).size());
+ assertTrue(player.getRolesPlayed(roleType1, assocType1).contains(role1));
+ assertEquals(0, player.getRolesPlayed(roleType1, assocType2).size());
+ assertEquals(0, player.getRolesPlayed(roleType2, assocType1).size());
+ assertEquals(0, player.getRolesPlayed(roleType2, assocType2).size());
+ final Role role2 = assoc.createRole(roleType2, player);
+ assertEquals(1, player.getRolesPlayed(roleType1, assocType1).size());
+ assertTrue(player.getRolesPlayed(roleType1, assocType1).contains(role1));
+ assertEquals(0, player.getRolesPlayed(roleType1, assocType2).size());
+ assertEquals(1, player.getRolesPlayed(roleType2, assocType1).size());
+ assertTrue(player.getRolesPlayed(roleType2, assocType1).contains(role2));
+ assertEquals(0, player.getRolesPlayed(roleType2, assocType2).size());
+ role2.setType(roleType1);
+ assertEquals(2, player.getRolesPlayed(roleType1, assocType1).size());
+ assertTrue(player.getRolesPlayed(roleType1, assocType1).contains(role1));
+ assertTrue(player.getRolesPlayed(roleType1, assocType1).contains(role2));
+ assertEquals(0, player.getRolesPlayed(roleType1, assocType2).size());
+ assertEquals(0, player.getRolesPlayed(roleType2, assocType1).size());
+ assertEquals(0, player.getRolesPlayed(roleType2, assocType2).size());
+ role1.remove();
+ assertEquals(1, player.getRolesPlayed(roleType1, assocType1).size());
+ assertTrue(player.getRolesPlayed(roleType1, assocType1).contains(role2));
+ assertEquals(0, player.getRolesPlayed(roleType1, assocType2).size());
+ assertEquals(0, player.getRolesPlayed(roleType2, assocType1).size());
+ assertEquals(0, player.getRolesPlayed(roleType2, assocType2).size());
+ assoc.remove();
+ assertEquals(0, player.getRolesPlayed(roleType1, assocType1).size());
+ assertEquals(0, player.getRolesPlayed(roleType1, assocType2).size());
+ assertEquals(0, player.getRolesPlayed(roleType2, assocType1).size());
+ assertEquals(0, player.getRolesPlayed(roleType2, assocType2).size());
+ }
+
+ public void testRoleAssociationFilterIllegalAssociation() {
+ final Role role = createRole();
+ final Topic player = role.getPlayer();
+ try {
+ player.getRolesPlayed(role.getType(), null);
+ fail("topic.getRolesPlayed(type, null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testRoleAssociationFilterIllegalRole() {
+ final Role role = createRole();
+ final Topic player = role.getPlayer();
+ try {
+ player.getRolesPlayed(null, role.getParent().getType());
+ fail("topic.getRolesPlayed(null, type) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testOccurrenceFilter() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final Topic type2 = createTopic();
+ final Topic unusedType = createTopic();
+ assertEquals(0, topic.getOccurrences(type).size());
+ assertEquals(0, topic.getOccurrences(type2).size());
+ assertEquals(0, topic.getOccurrences(unusedType).size());
+ final Occurrence occ = topic.createOccurrence(type, "Occurrence");
+ assertEquals(1, topic.getOccurrences(type).size());
+ assertTrue(topic.getOccurrences(type).contains(occ));
+ assertEquals(0, topic.getOccurrences(type2).size());
+ assertEquals(0, topic.getOccurrences(unusedType).size());
+ occ.setType(type2);
+ assertEquals(1, topic.getOccurrences(type2).size());
+ assertTrue(topic.getOccurrences(type2).contains(occ));
+ assertEquals(0, topic.getOccurrences(type).size());
+ assertEquals(0, topic.getOccurrences(unusedType).size());
+ occ.remove();
+ assertEquals(0, topic.getOccurrences(type).size());
+ assertEquals(0, topic.getOccurrences(type2).size());
+ assertEquals(0, topic.getOccurrences(unusedType).size());
+ }
+
+ public void testOccurrenceFilterIllegal() {
+ final Occurrence occ = createOccurrence();
+ final Topic parent = occ.getParent();
+ try {
+ parent.getOccurrences(null);
+ fail("topic.getOccurrences(null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testNameFilter() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final Topic type2 = createTopic();
+ final Topic unusedType = createTopic();
+ assertEquals(0, topic.getNames(type).size());
+ assertEquals(0, topic.getNames(type2).size());
+ assertEquals(0, topic.getNames(unusedType).size());
+ final Name occ = topic.createName(type, "Name");
+ assertEquals(1, topic.getNames(type).size());
+ assertTrue(topic.getNames(type).contains(occ));
+ assertEquals(0, topic.getNames(type2).size());
+ assertEquals(0, topic.getNames(unusedType).size());
+ occ.setType(type2);
+ assertEquals(1, topic.getNames(type2).size());
+ assertTrue(topic.getNames(type2).contains(occ));
+ assertEquals(0, topic.getNames(type).size());
+ assertEquals(0, topic.getNames(unusedType).size());
+ occ.remove();
+ assertEquals(0, topic.getNames(type).size());
+ assertEquals(0, topic.getNames(type2).size());
+ assertEquals(0, topic.getNames(unusedType).size());
+ }
+
+ public void testNameFilterIllegal() {
+ final Name name = createName();
+ final Topic parent = name.getParent();
+ try {
+ parent.getNames(null);
+ fail("topic.getNames(null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testOccurrenceCreationTypeString() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final String value = "Occurrence";
+ final Locator dt = createLocator("http://www.w3.org/2001/XMLSchema#string");
+ assertEquals(0, topic.getOccurrences().size());
+ final Occurrence occ = topic.createOccurrence(type, value);
+ assertEquals(1, topic.getOccurrences().size());
+ assertTrue(topic.getOccurrences().contains(occ));
+ assertTrue(occ.getScope().isEmpty());
+ assertEquals(type, occ.getType());
+ assertEquals(value, occ.getValue());
+ assertEquals(dt, occ.getDatatype());
+ assertTrue(occ.getItemIdentifiers().isEmpty());
+ }
+
+ public void testOccurrenceCreationTypeURI() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final Locator value = createLocator("http://www.example.org/");
+ final Locator dt = createLocator("http://www.w3.org/2001/XMLSchema#anyURI");
+ assertEquals(0, topic.getOccurrences().size());
+ final Occurrence occ = topic.createOccurrence(type, value);
+ assertEquals(1, topic.getOccurrences().size());
+ assertTrue(topic.getOccurrences().contains(occ));
+ assertTrue(occ.getScope().isEmpty());
+ assertEquals(type, occ.getType());
+ assertEquals(value.getReference(), occ.getValue());
+ assertEquals(value, occ.locatorValue());
+ assertEquals(dt, occ.getDatatype());
+ assertTrue(occ.getItemIdentifiers().isEmpty());
+ }
+
+ public void testOccurrenceCreationTypeExplicitDatatype() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final String value = "Occurrence";
+ final Locator dt = createLocator("http://www.example.org/datatype");
+ assertEquals(0, topic.getOccurrences().size());
+ final Occurrence occ = topic.createOccurrence(type, value, dt);
+ assertEquals(1, topic.getOccurrences().size());
+ assertTrue(topic.getOccurrences().contains(occ));
+ assertTrue(occ.getScope().isEmpty());
+ assertEquals(type, occ.getType());
+ assertEquals(value, occ.getValue());
+ assertEquals(dt, occ.getDatatype());
+ assertTrue(occ.getItemIdentifiers().isEmpty());
+ }
+
+ public void testOccurrenceCreationTypeScopeArrayString() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final Topic theme1 = createTopic();
+ final Topic theme2 = createTopic();
+ final String value = "Occurrence";
+ final Locator dt = createLocator("http://www.w3.org/2001/XMLSchema#string");
+ assertEquals(0, topic.getOccurrences().size());
+ final Occurrence occ = topic.createOccurrence(type, value, theme1, theme2);
+ assertEquals(1, topic.getOccurrences().size());
+ assertTrue(topic.getOccurrences().contains(occ));
+ assertEquals(2, occ.getScope().size());
+ assertTrue(occ.getScope().contains(theme1));
+ assertTrue(occ.getScope().contains(theme2));
+ assertEquals(type, occ.getType());
+ assertEquals(value, occ.getValue());
+ assertEquals(dt, occ.getDatatype());
+ assertTrue(occ.getItemIdentifiers().isEmpty());
+ }
+
+ public void testOccurrenceCreationTypeScopeArrayURI() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final Topic theme1 = createTopic();
+ final Topic theme2 = createTopic();
+ final Locator value = createLocator("http://www.example.org/");
+ final Locator dt = createLocator("http://www.w3.org/2001/XMLSchema#anyURI");
+ assertEquals(0, topic.getOccurrences().size());
+ final Occurrence occ = topic.createOccurrence(type, value, theme1, theme2);
+ assertEquals(1, topic.getOccurrences().size());
+ assertTrue(topic.getOccurrences().contains(occ));
+ assertEquals(2, occ.getScope().size());
+ assertTrue(occ.getScope().contains(theme1));
+ assertTrue(occ.getScope().contains(theme2));
+ assertEquals(type, occ.getType());
+ assertEquals(value.getReference(), occ.getValue());
+ assertEquals(value, occ.locatorValue());
+ assertEquals(dt, occ.getDatatype());
+ assertTrue(occ.getItemIdentifiers().isEmpty());
+ }
+
+ public void testOccurrenceCreationTypeScopeArrayExplicitDatatype() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final Topic theme1 = createTopic();
+ final Topic theme2 = createTopic();
+ final String value = "Occurrence";
+ final Locator dt = createLocator("http://www.example.org/datatype");
+ assertEquals(0, topic.getOccurrences().size());
+ final Occurrence occ = topic.createOccurrence(type, value, dt, theme1, theme2);
+ assertEquals(1, topic.getOccurrences().size());
+ assertTrue(topic.getOccurrences().contains(occ));
+ assertEquals(2, occ.getScope().size());
+ assertTrue(occ.getScope().contains(theme1));
+ assertTrue(occ.getScope().contains(theme2));
+ assertEquals(type, occ.getType());
+ assertEquals(value, occ.getValue());
+ assertEquals(dt, occ.getDatatype());
+ assertTrue(occ.getItemIdentifiers().isEmpty());
+ }
+
+ public void testOccurrenceCreationTypeScopeCollectionString() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final Topic theme1 = createTopic();
+ final Topic theme2 = createTopic();
+ final String value = "Occurrence";
+ final Locator dt = createLocator("http://www.w3.org/2001/XMLSchema#string");
+ assertEquals(0, topic.getOccurrences().size());
+ final Occurrence occ = topic.createOccurrence(type, value, Arrays.asList(theme1, theme2));
+ assertEquals(1, topic.getOccurrences().size());
+ assertTrue(topic.getOccurrences().contains(occ));
+ assertEquals(2, occ.getScope().size());
+ assertTrue(occ.getScope().contains(theme1));
+ assertTrue(occ.getScope().contains(theme2));
+ assertEquals(type, occ.getType());
+ assertEquals(value, occ.getValue());
+ assertEquals(dt, occ.getDatatype());
+ assertTrue(occ.getItemIdentifiers().isEmpty());
+ }
+
+ public void testOccurrenceCreationTypeScopeCollectionURI() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final Topic theme1 = createTopic();
+ final Topic theme2 = createTopic();
+ final Locator value = createLocator("http://www.example.org/");
+ final Locator dt = createLocator("http://www.w3.org/2001/XMLSchema#anyURI");
+ assertEquals(0, topic.getOccurrences().size());
+ final Occurrence occ = topic.createOccurrence(type, value, Arrays.asList(theme1, theme2));
+ assertEquals(1, topic.getOccurrences().size());
+ assertTrue(topic.getOccurrences().contains(occ));
+ assertEquals(2, occ.getScope().size());
+ assertTrue(occ.getScope().contains(theme1));
+ assertTrue(occ.getScope().contains(theme2));
+ assertEquals(type, occ.getType());
+ assertEquals(value.getReference(), occ.getValue());
+ assertEquals(value, occ.locatorValue());
+ assertEquals(dt, occ.getDatatype());
+ assertTrue(occ.getItemIdentifiers().isEmpty());
+ }
+
+ public void testOccurrenceCreationTypeScopeCollectionExplicitDatatype() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final Topic theme1 = createTopic();
+ final Topic theme2 = createTopic();
+ final String value = "Occurrence";
+ final Locator dt = createLocator("http://www.example.org/datatype");
+ assertEquals(0, topic.getOccurrences().size());
+ final Occurrence occ = topic.createOccurrence(type, value, dt, Arrays.asList(theme1, theme2));
+ assertEquals(1, topic.getOccurrences().size());
+ assertTrue(topic.getOccurrences().contains(occ));
+ assertEquals(2, occ.getScope().size());
+ assertTrue(occ.getScope().contains(theme1));
+ assertTrue(occ.getScope().contains(theme2));
+ assertEquals(type, occ.getType());
+ assertEquals(value, occ.getValue());
+ assertEquals(dt, occ.getDatatype());
+ assertTrue(occ.getItemIdentifiers().isEmpty());
+ }
+
+ public void testOccurrenceCreationTypeIllegalString() {
+ final Topic topic = createTopic();
+ try {
+ topic.createOccurrence(createTopic(), (String)null);
+ fail("createOccurrence(topic, (String)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testOccurrenceCreationTypeIllegalURI() {
+ final Topic topic = createTopic();
+ try {
+ topic.createOccurrence(createTopic(), (Locator)null);
+ fail("createOccurrence(topic, (Locator)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testOccurrenceCreationTypeIllegalDatatype() {
+ final Topic topic = createTopic();
+ try {
+ topic.createOccurrence(createTopic(), "Occurrence", (Locator)null);
+ fail("createOccurrence(topic, \"Occurrence\", (Locator)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testOccurrenceCreationIllegalType() {
+ final Topic topic = createTopic();
+ try {
+ topic.createOccurrence(null, "Occurrence");
+ fail("createOccurrence(null, \"Occurrence\" is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testOccurrenceCreationTypeIllegalScopeArray() {
+ final Topic topic = createTopic();
+ try {
+ topic.createOccurrence(createTopic(), "Occurrence", (Topic[])null);
+ fail("createOccurrence(topic, \"Occurrence\", (Topic[])null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testOccurrenceCreationTypeIllegalScopeCollection() {
+ final Topic topic = createTopic();
+ try {
+ topic.createOccurrence(createTopic(), "Occurrence", (Collection<Topic>)null);
+ fail("createOccurrence(topic, \"Occurrence\", (Collection<Topic>)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testNameCreationType() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final String value = "Name";
+ assertTrue(topic.getNames().isEmpty());
+ final Name name = topic.createName(type, value);
+ assertEquals(1, topic.getNames().size());
+ assertTrue(topic.getNames().contains(name));
+ assertTrue(name.getScope().isEmpty());
+ assertEquals(type, name.getType());
+ assertEquals(value, name.getValue());
+ assertTrue(name.getItemIdentifiers().isEmpty());
+ }
+
+ public void testNameCreationTypeScopeCollection() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final Topic theme = createTopic();
+ final String value = "Name";
+ assertTrue(topic.getNames().isEmpty());
+ final Name name = topic.createName(type, value, Collections.singleton(theme));
+ assertEquals(1, topic.getNames().size());
+ assertTrue(topic.getNames().contains(name));
+ assertEquals(1, name.getScope().size());
+ assertTrue(name.getScope().contains(theme));
+ assertEquals(type, name.getType());
+ assertEquals(value, name.getValue());
+ assertTrue(name.getItemIdentifiers().isEmpty());
+ }
+
+ public void testNameCreationTypeScopeArray() {
+ final Topic topic = createTopic();
+ final Topic type = createTopic();
+ final String value = "Name";
+ final Topic theme1 = createTopic();
+ final Topic theme2 = createTopic();
+ assertTrue(topic.getNames().isEmpty());
+ final Name name = topic.createName(type, value, theme1, theme2);
+ assertEquals(1, topic.getNames().size());
+ assertTrue(topic.getNames().contains(name));
+ assertEquals(2, name.getScope().size());
+ assertTrue(name.getScope().contains(theme1));
+ assertTrue(name.getScope().contains(theme2));
+ assertEquals(type, name.getType());
+ assertEquals(value, name.getValue());
+ assertTrue(name.getItemIdentifiers().isEmpty());
+ }
+
+ public void testNameCreationDefaultType() {
+ final Topic topic = createTopic();
+ final String value = "Name";
+ final Locator loc = createLocator("http://psi.topicmaps.org/iso13250/model/topic-name");
+ assertTrue(topic.getNames().isEmpty());
+ final Name name = topic.createName(value);
+ assertEquals(1, topic.getNames().size());
+ assertTrue(topic.getNames().contains(name));
+ assertTrue(name.getScope().isEmpty());
+ assertNotNull(name.getType());
+ assertEquals(value, name.getValue());
+ assertTrue(name.getItemIdentifiers().isEmpty());
+ Topic type = name.getType();
+ assertTrue(type.getSubjectIdentifiers().contains(loc));
+ }
+
+ public void testNameCreationDefaultTypeScopeCollection() {
+ final Topic topic = createTopic();
+ final Topic theme = createTopic();
+ final String value = "Name";
+ final Locator loc = createLocator("http://psi.topicmaps.org/iso13250/model/topic-name");
+ assertTrue(topic.getNames().isEmpty());
+ final Name name = topic.createName(value, Collections.singleton(theme));
+ assertEquals(1, topic.getNames().size());
+ assertTrue(topic.getNames().contains(name));
+ assertEquals(1, name.getScope().size());
+ assertTrue(name.getScope().contains(theme));
+ assertNotNull(name.getType());
+ assertEquals(value, name.getValue());
+ assertTrue(name.getItemIdentifiers().isEmpty());
+ Topic type = name.getType();
+ assertTrue(type.getSubjectIdentifiers().contains(loc));
+ }
+
+ public void testNameCreationDefaultTypeScopeArray() {
+ final Topic topic = createTopic();
+ final Topic theme1 = createTopic();
+ final Topic theme2 = createTopic();
+ final String value = "Name";
+ final Locator loc = createLocator("http://psi.topicmaps.org/iso13250/model/topic-name");
+ assertTrue(topic.getNames().isEmpty());
+ final Name name = topic.createName(value, theme1, theme2);
+ assertEquals(1, topic.getNames().size());
+ assertTrue(topic.getNames().contains(name));
+ assertEquals(2, name.getScope().size());
+ assertTrue(name.getScope().contains(theme1));
+ assertTrue(name.getScope().contains(theme2));
+ assertNotNull(name.getType());
+ assertEquals(value, name.getValue());
+ assertTrue(name.getItemIdentifiers().isEmpty());
+ Topic type = name.getType();
+ assertTrue(type.getSubjectIdentifiers().contains(loc));
+ }
+
+ public void testNameCreationTypeIllegalString() {
+ final Topic topic = createTopic();
+ try {
+ topic.createName(createTopic(), (String)null);
+ fail("createName(topic, null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testNameCreationTypeIllegalScopeArray() {
+ final Topic topic = createTopic();
+ try {
+ topic.createName(createTopic(), "Name", (Topic[])null);
+ fail("createName(topic, \"Name\", (Topic[])null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testNameCreationTypeIllegalScopeCollection() {
+ final Topic topic = createTopic();
+ try {
+ topic.createName(createTopic(), "Name", (Collection<Topic>)null);
+ fail("createName(topic, \"Name\", (Collection<Topic>)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testNameCreationDefaultTypeIllegalString() {
+ final Topic topic = createTopic();
+ try {
+ topic.createName((String)null);
+ fail("createName(null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testNameCreationDefaultTypeIllegalScopeArray() {
+ final Topic topic = createTopic();
+ try {
+ topic.createName("Name", (Topic[])null);
+ fail("createName(\"Name\", (Topic[])null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testNameCreationDefaultTypeIllegalScopeCollection() {
+ final Topic topic = createTopic();
+ try {
+ topic.createName("Name", (Collection<Topic>)null);
+ fail("createName(\"Name\", (Collection<Topic>)null) is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testTopicRemovableUsedAsType() {
+ Topic topic = createTopic();
+ assertEquals(1, _tm.getTopics().size());
+ topic.remove();
+ assertEquals(0, _tm.getTopics().size());
+ topic = createTopic();
+ assertEquals(1, _tm.getTopics().size());
+ Association assoc = _tm.createAssociation(topic);
+ try {
+ topic.remove();
+ fail("The topic is used as type");
+ }
+ catch (TopicInUseException ex) {
+ assertEquals(topic, ex.getSender());
+ }
+ assoc.setType(createTopic());
+ assertEquals(2, _tm.getTopics().size());
+ topic.remove();
+ assertEquals(1, _tm.getTopics().size());
+ }
+
+ public void testTopicRemovableUsedAsPlayer() {
+ Topic topic = createTopic();
+ assertEquals(1, _tm.getTopics().size());
+ topic.remove();
+ assertEquals(0, _tm.getTopics().size());
+ topic = createTopic();
+ assertEquals(1, _tm.getTopics().size());
+ Association assoc = createAssociation();
+ assertEquals(2, _tm.getTopics().size());
+ Role role = assoc.createRole(_tm.createTopic(), topic);
+ assertEquals(3, _tm.getTopics().size());
+ try {
+ topic.remove();
+ fail("The topic is used as player");
+ }
+ catch (TopicInUseException ex) {
+ assertEquals(topic, ex.getSender());
+ }
+ role.setPlayer(createTopic());
+ assertEquals(4, _tm.getTopics().size());
+ topic.remove();
+ assertEquals(3, _tm.getTopics().size());
+ }
+
+ public void testRemovableUsedAsTheme() {
+ Topic topic = createTopic();
+ assertEquals(1, _tm.getTopics().size());
+ topic.remove();
+ assertEquals(0, _tm.getTopics().size());
+ topic = createTopic();
+ assertEquals(1, _tm.getTopics().size());
+ Association assoc = _tm.createAssociation(createTopic(), topic);
+ assertEquals(2, _tm.getTopics().size());
+ try {
+ topic.remove();
+ fail("The topic is used as theme");
+ }
+ catch (TopicInUseException ex) {
+ assertEquals(topic, ex.getSender());
+ }
+ assoc.removeTheme(topic);
+ topic.remove();
+ assertEquals(1, _tm.getTopics().size());
+ }
+
+ public void testRemovableUsedAsReifier() {
+ Topic topic = createTopic();
+ assertEquals(1, _tm.getTopics().size());
+ topic.remove();
+ assertEquals(0, _tm.getTopics().size());
+ topic = createTopic();
+ assertEquals(1, _tm.getTopics().size());
+ Association assoc = createAssociation();
+ assertEquals(2, _tm.getTopics().size());
+ assoc.setReifier(topic);
+ try {
+ topic.remove();
+ fail("The topic is used as reifier");
+ }
+ catch (TopicInUseException ex) {
+ assertEquals(topic, ex.getSender());
+ }
+ assoc.setReifier(null);
+ topic.remove();
+ assertEquals(1, _tm.getTopics().size());
+ }
}
Modified: trunk/src/test/java/org/tmapi/core/TestTopicMap.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicMap.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestTopicMap.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
@@ -15,6 +13,9 @@
*/
package org.tmapi.core;
+import java.util.Collection;
+import java.util.Collections;
+
/**
* Tests against the {@link TopicMap} interface.
*
@@ -33,4 +34,176 @@
public void testParent() throws Exception {
assertNull("A topic map has no parent", _tm.getParent());
}
+
+ public void testTopicCreationSubjectIdentifier() {
+ final Locator loc = createLocator("http://www.example.org/");
+ assertTrue(_tm.getTopics().isEmpty());
+ final Topic topic = _tm.createTopicBySubjectIdentifier(loc);
+ assertEquals(1, _tm.getTopics().size());
+ assertTrue(_tm.getTopics().contains(topic));
+ assertEquals(1, topic.getSubjectIdentifiers().size());
+ assertTrue(topic.getItemIdentifiers().isEmpty());
+ assertTrue(topic.getSubjectLocators().isEmpty());
+ final Locator loc2 = topic.getSubjectIdentifiers().iterator().next();
+ assertEquals(loc, loc2);
+ }
+
+ public void testTopicCreationSubjectIdentifierIllegal() {
+ try {
+ _tm.createTopicBySubjectIdentifier(null);
+ fail("Subject identifier == null is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testTopicCreationSubjectLocator() {
+ final Locator loc = createLocator("http://www.example.org/");
+ assertTrue(_tm.getTopics().isEmpty());
+ final Topic topic = _tm.createTopicBySubjectLocator(loc);
+ assertEquals(1, _tm.getTopics().size());
+ assertTrue(_tm.getTopics().contains(topic));
+ assertEquals(1, topic.getSubjectLocators().size());
+ assertTrue(topic.getItemIdentifiers().isEmpty());
+ assertTrue(topic.getSubjectIdentifiers().isEmpty());
+ final Locator loc2 = topic.getSubjectLocators().iterator().next();
+ assertEquals(loc, loc2);
+ }
+
+ public void testTopicCreationSubjectLocatorIllegal() {
+ try {
+ _tm.createTopicBySubjectLocator(null);
+ fail("Subject locator == null is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testTopicCreationItemIdentifier() {
+ final Locator loc = createLocator("http://www.example.org/");
+ assertTrue(_tm.getTopics().isEmpty());
+ final Topic topic = _tm.createTopicByItemIdentifier(loc);
+ assertEquals(1, _tm.getTopics().size());
+ assertTrue(_tm.getTopics().contains(topic));
+ assertEquals(1, topic.getItemIdentifiers().size());
+ assertTrue(topic.getSubjectIdentifiers().isEmpty());
+ assertTrue(topic.getSubjectLocators().isEmpty());
+ final Locator loc2 = topic.getItemIdentifiers().iterator().next();
+ assertEquals(loc, loc2);
+ }
+
+ public void testTopicCreationItemIdentifierIllegal() {
+ try {
+ _tm.createTopicByItemIdentifier(null);
+ fail("item identifier == null is illegal");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testTopicCreationAutomagicItemIdentifier() {
+ assertTrue(_tm.getTopics().isEmpty());
+ final Topic topic = _tm.createTopic();
+ assertEquals(1, _tm.getTopics().size());
+ assertTrue(_tm.getTopics().contains(topic));
+ assertEquals(1, topic.getItemIdentifiers().size());
+ assertTrue(topic.getSubjectIdentifiers().isEmpty());
+ assertTrue(topic.getSubjectLocators().isEmpty());
+ }
+
+ public void testTopicBySubjectIdentifier() {
+ final Locator loc = createLocator("http://www.example.org/");
+ Topic t = _tm.getTopicBySubjectIdentifier(loc);
+ assertNull(t);
+ final Topic topic = _tm.createTopicBySubjectIdentifier(loc);
+ t = _tm.getTopicBySubjectIdentifier(loc);
+ assertNotNull(t);
+ assertEquals(topic, t);
+ topic.remove();
+ t = _tm.getTopicBySubjectIdentifier(loc);
+ assertNull(t);
+ }
+
+ public void testTopicBySubjectLocator() {
+ final Locator loc = createLocator("http://www.example.org/");
+ Topic t = _tm.getTopicBySubjectLocator(loc);
+ assertNull(t);
+ final Topic topic = _tm.createTopicBySubjectLocator(loc);
+ t = _tm.getTopicBySubjectLocator(loc);
+ assertNotNull(t);
+ assertEquals(topic, t);
+ topic.remove();
+ t = _tm.getTopicBySubjectLocator(loc);
+ assertNull(t);
+ }
+
+ public void testAssociationCreationType() {
+ final Topic type = createTopic();
+ assertTrue(_tm.getAssociations().isEmpty());
+ final Association assoc = _tm.createAssociation(type);
+ assertEquals(1, _tm.getAssociations().size());
+ assertTrue(_tm.getAssociations().contains(assoc));
+ assertTrue(assoc.getRoles().isEmpty());
+ assertEquals(type, assoc.getType());
+ assertTrue(assoc.getScope().isEmpty());
+ }
+
+ public void testAssociationCreationTypeScopeCollection() {
+ final Topic type = createTopic();
+ final Topic theme = createTopic();
+ assertTrue(_tm.getAssociations().isEmpty());
+ final Association assoc = _tm.createAssociation(type, Collections.singleton(theme));
+ assertEquals(1, _tm.getAssociations().size());
+ assertTrue(_tm.getAssociations().contains(assoc));
+ assertTrue(assoc.getRoles().isEmpty());
+ assertEquals(type, assoc.getType());
+ assertEquals(1, assoc.getScope().size());
+ assertTrue(assoc.getScope().contains(theme));
+ }
+
+ public void testAssociationCreationTypeScopeArray() {
+ final Topic type = createTopic();
+ final Topic theme = createTopic();
+ final Topic theme2 = createTopic();
+ assertTrue(_tm.getAssociations().isEmpty());
+ final Association assoc = _tm.createAssociation(type, theme, theme2);
+ assertEquals(1, _tm.getAssociations().size());
+ assertTrue(_tm.getAssociations().contains(assoc));
+ assertTrue(assoc.getRoles().isEmpty());
+ assertEquals(type, assoc.getType());
+ assertEquals(2, assoc.getScope().size());
+ assertTrue(assoc.getScope().contains(theme));
+ assertTrue(assoc.getScope().contains(theme2));
+ }
+
+ public void testAssociationCreationIllegalType() {
+ try {
+ _tm.createAssociation(null);
+ fail("Creating an association with type == null is not allowed");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testAssociationCreationIllegalNullScope() {
+ try {
+ _tm.createAssociation(createTopic(), (Topic[])null);
+ fail("Creating an association with scope == null is not allowed");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ try {
+ _tm.createAssociation(createTopic(), (Collection<Topic>)null);
+ fail("Creating an association with scope == (Collection) null is not allowed");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
}
Modified: trunk/src/test/java/org/tmapi/core/TestTopicMapMerge.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicMapMerge.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestTopicMapMerge.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/test/java/org/tmapi/core/TestTopicMapSystem.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicMapSystem.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestTopicMapSystem.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/test/java/org/tmapi/core/TestTopicMerge.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicMerge.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestTopicMerge.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/test/java/org/tmapi/core/TestTopicMergeDetection.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTopicMergeDetection.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestTopicMergeDetection.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/test/java/org/tmapi/core/TestTyped.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestTyped.java 2008-08-05 11:25:24 UTC (rev 52)
+++ trunk/src/test/java/org/tmapi/core/TestTyped.java 2008-08-05 11:26:51 UTC (rev 53)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * The Topic Maps API (TMAPI) was created collectively by
* the membership of the ...
[truncated message content] |
|
From: <tma...@li...> - 2008-08-05 11:25:19
|
Revision: 52
http://tmapi.svn.sourceforge.net/tmapi/?rev=52&view=rev
Author: lheuer
Date: 2008-08-05 11:25:24 +0000 (Tue, 05 Aug 2008)
Log Message:
-----------
- Removed TMAPI version from license header
- Added Asscociation#getRoleTypes()
Modified Paths:
--------------
trunk/src/main/java/org/tmapi/core/Association.java
trunk/src/main/java/org/tmapi/core/Construct.java
trunk/src/main/java/org/tmapi/core/DatatypeAware.java
trunk/src/main/java/org/tmapi/core/FactoryConfigurationException.java
trunk/src/main/java/org/tmapi/core/FeatureNotRecognizedException.java
trunk/src/main/java/org/tmapi/core/FeatureNotSupportedException.java
trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java
trunk/src/main/java/org/tmapi/core/Locator.java
trunk/src/main/java/org/tmapi/core/ModelConstraintException.java
trunk/src/main/java/org/tmapi/core/Name.java
trunk/src/main/java/org/tmapi/core/Occurrence.java
trunk/src/main/java/org/tmapi/core/Reifiable.java
trunk/src/main/java/org/tmapi/core/Role.java
trunk/src/main/java/org/tmapi/core/Scoped.java
trunk/src/main/java/org/tmapi/core/TMAPIException.java
trunk/src/main/java/org/tmapi/core/TMAPIRuntimeException.java
trunk/src/main/java/org/tmapi/core/Topic.java
trunk/src/main/java/org/tmapi/core/TopicInUseException.java
trunk/src/main/java/org/tmapi/core/TopicMap.java
trunk/src/main/java/org/tmapi/core/TopicMapExistsException.java
trunk/src/main/java/org/tmapi/core/TopicMapSystem.java
trunk/src/main/java/org/tmapi/core/TopicMapSystemFactory.java
trunk/src/main/java/org/tmapi/core/Typed.java
trunk/src/main/java/org/tmapi/core/Variant.java
trunk/src/main/java/org/tmapi/index/Index.java
trunk/src/main/java/org/tmapi/index/LiteralIndex.java
trunk/src/main/java/org/tmapi/index/ScopedIndex.java
trunk/src/main/java/org/tmapi/index/TypeInstanceIndex.java
Modified: trunk/src/main/java/org/tmapi/core/Association.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Association.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/Association.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
@@ -45,6 +43,23 @@
public Set<Role> getRoles();
/**
+ * Returns the role types participating in this association.
+ *
+ * This method returns the same result as the following code:
+ * <pre>
+ * Set<Topic> types = new HashSet<Topic>();
+ * for (Role role: assoc.getRoles()) {
+ * types.add(role.getType());
+ * }
+ * </pre>
+ *
+ * The return value may be empty but must never be <tt>null</tt>.
+ *
+ * @return An unmodifiable set of role types.
+ */
+ public Set<Topic> getRoleTypes();
+
+ /**
* Returns all roles with the specified <tt>type</tt>.
*
* This method returns the same result as the following code:
@@ -59,8 +74,8 @@
*
* The return value may be empty but must never be <tt>null</tt>.
*
- * @param type The type of the {@link org.tmapi.core.Role} instances to be
- * returned.
+ * @param type The type of the {@link Role} instances to be returned,
+ * must not be <tt>null</tt>.
* @return An unmodifiable (maybe empty) set of roles with the specified
* <tt>type</tt> property.
*/
Modified: trunk/src/main/java/org/tmapi/core/Construct.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Construct.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/Construct.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
@@ -37,10 +35,10 @@
public Construct getParent();
/**
- * Returns the {@link org.tmapi.core.TopicMap} instance to which this
- * Topic Maps construct belongs.
+ * Returns the {@link TopicMap} instance to which this Topic Maps construct
+ * belongs.
*
- * A {@link org.tmapi.core.TopicMap} instance returns itself.
+ * A {@link TopicMap} instance returns itself.
*
* @return The topic map instance to which this constructs belongs.
*/
@@ -75,7 +73,7 @@
* If at least one of the two objects is not a {@link Topic}, an
* {@link IdentityConstraintException} must be reported.
*
- * @param iid The item identifier to be added.
+ * @param iid The item identifier to be added; must not be <tt>null</tt>.
* @throws IdentityConstraintException If another construct has an item
* identifier which is equal to <tt>iid</tt.
*/
Modified: trunk/src/main/java/org/tmapi/core/DatatypeAware.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/DatatypeAware.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/DatatypeAware.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/FactoryConfigurationException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/FactoryConfigurationException.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/FactoryConfigurationException.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/FeatureNotRecognizedException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/FeatureNotRecognizedException.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/FeatureNotRecognizedException.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/FeatureNotSupportedException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/FeatureNotSupportedException.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/FeatureNotSupportedException.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/IdentityConstraintException.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/Locator.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Locator.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/Locator.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/ModelConstraintException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/ModelConstraintException.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/ModelConstraintException.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
@@ -44,7 +42,9 @@
/**
* Returns the {@link Construct} which has thrown the exception.
*
- * @return The construct which has thrown the exception.
+ * @return The construct which has thrown the exception or <tt>null</tt>
+ * if no approbiate construct is available (i.e. in the factory
+ * methods).
*/
public Construct getSender() {
return _sender;
Modified: trunk/src/main/java/org/tmapi/core/Name.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Name.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/Name.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/Occurrence.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Occurrence.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/Occurrence.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/Reifiable.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Reifiable.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/Reifiable.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/Role.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Role.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/Role.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/Scoped.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Scoped.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/Scoped.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/TMAPIException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TMAPIException.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/TMAPIException.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/TMAPIRuntimeException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TMAPIRuntimeException.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/TMAPIRuntimeException.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/Topic.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Topic.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/Topic.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
@@ -41,7 +39,7 @@
*
* If adding the specified item identifier would make this topic
* represent the same subject as another topic and the feature
- * "automerge" (http://tmapi.org/features/automerge/) is disabled,
+ * "automerge" (http://tmapi.org/features/automerge) is disabled,
* an {@link IdentityConstraintException} is thrown.
*
* @see org.tmapi.core.Construct#addItemIdentifier(org.tmapi.core.Locator)
@@ -66,7 +64,7 @@
* "automerge" (http://tmapi.org/features/automerge/) is disabled,
* an {@link IdentityConstraintException} is thrown.
*
- * @param sid The subject identifier to be added.
+ * @param sid The subject identifier to be added; must not be <tt>null</tt>.
* @throws IdentityConstraintException If the feature "automerge" is
* disabled and adding the subject identifier would make this
* topic represent the same subject as another topic.
@@ -98,7 +96,7 @@
* "automerge" (http://tmapi.org/features/automerge/) is disabled,
* an {@link IdentityConstraintException} is thrown.
*
- * @param slo The subject locator to be added.
+ * @param slo The subject locator to be added; must not be <tt>null</tt>.
* @throws IdentityConstraintException If the feature "automerge" is
* disabled and adding the subject locator would make this
* topic represent the same subject as another topic.
@@ -137,7 +135,8 @@
*
* The return value may be empty but must never be <tt>null</tt>.
*
- * @param type The type of the {@link Name}s to be returned.
+ * @param type The type of the {@link Name}s to be returned;
+ * must not be <tt>null</tt>.
* @return An unmodifiable set of {@link Name}s with the specified
* <tt>type</tt>.
*/
@@ -224,7 +223,8 @@
*
* The return value may be empty but must never be <tt>null</tt>.
*
- * @param type The type of the {@link Occurrence}s to be returned.
+ * @param type The type of the {@link Occurrence}s to be returned;
+ * must not be <tt>null</tt>.
* @return An unmodifiable set of {@link Occurrence}s with the
* specified <tt>type</tt>.
*/
@@ -355,7 +355,8 @@
*
* The return value may be empty but must never be <tt>null</tt>.
*
- * @param type The type of the {@link Role}s to be returned.
+ * @param type The type of the {@link Role}s to be returned; must not
+ * be <tt>null</tt>.
* @return An unmodifiable set of {@link Role}s with the specified <tt>type</tt>.
*/
public Set<Role> getRolesPlayed(Topic type);
@@ -376,9 +377,10 @@
*
* The return value may be empty but must never be <tt>null</tt>.
*
- * @param type The type of the {@link Role}s to be returned.
+ * @param type The type of the {@link Role}s to be returned;
+ * must not be <tt>null</tt>.
* @param assocType The type of the {@link Association} from which the
- * returned roles must be part of.
+ * returned roles must be part of; must not be <tt>null</tt>.
* @return An unmodifiable set of {@link Role}s with the specified <tt>type</tt>
* which are part of {@link Association}s with the specified
* <tt>assocType</tt>.
@@ -406,7 +408,8 @@
* by this method. In any case, every type which was added by this method
* must be returned by the {@link #getTypes()} method.
*
- * @param type The type of which this topic should become an instance of.
+ * @param type The type of which this topic should become an instance of;
+ * must not be <tt>null</tt>.
*/
public void addType(Topic type);
Modified: trunk/src/main/java/org/tmapi/core/TopicInUseException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicInUseException.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/TopicInUseException.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/TopicMap.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicMap.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/TopicMap.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/TopicMapExistsException.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicMapExistsException.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/TopicMapExistsException.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/TopicMapSystem.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicMapSystem.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/TopicMapSystem.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/TopicMapSystemFactory.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/TopicMapSystemFactory.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/TopicMapSystemFactory.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/Typed.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Typed.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/Typed.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/core/Variant.java
===================================================================
--- trunk/src/main/java/org/tmapi/core/Variant.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/core/Variant.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/index/Index.java
===================================================================
--- trunk/src/main/java/org/tmapi/index/Index.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/index/Index.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/index/LiteralIndex.java
===================================================================
--- trunk/src/main/java/org/tmapi/index/LiteralIndex.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/index/LiteralIndex.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/index/ScopedIndex.java
===================================================================
--- trunk/src/main/java/org/tmapi/index/ScopedIndex.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/index/ScopedIndex.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
Modified: trunk/src/main/java/org/tmapi/index/TypeInstanceIndex.java
===================================================================
--- trunk/src/main/java/org/tmapi/index/TypeInstanceIndex.java 2008-08-04 17:56:41 UTC (rev 51)
+++ trunk/src/main/java/org/tmapi/index/TypeInstanceIndex.java 2008-08-05 11:25:24 UTC (rev 52)
@@ -1,7 +1,5 @@
/*
- * TMAPI 2.0
- *
- * Version 2.0 of the Topic Maps API (TMAPI), created collectively by
+ * 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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tma...@li...> - 2008-08-04 17:56:38
|
Revision: 51
http://tmapi.svn.sourceforge.net/tmapi/?rev=51&view=rev
Author: lheuer
Date: 2008-08-04 17:56:41 +0000 (Mon, 04 Aug 2008)
Log Message:
-----------
- Variant creation tests
Modified Paths:
--------------
trunk/src/test/java/org/tmapi/core/TestName.java
Modified: trunk/src/test/java/org/tmapi/core/TestName.java
===================================================================
--- trunk/src/test/java/org/tmapi/core/TestName.java 2008-08-04 13:55:55 UTC (rev 50)
+++ trunk/src/test/java/org/tmapi/core/TestName.java 2008-08-04 17:56:41 UTC (rev 51)
@@ -15,6 +15,8 @@
*/
package org.tmapi.core;
+import java.util.Collections;
+
/**
* Tests against the {@link Name} interface.
*
@@ -45,4 +47,105 @@
assertTrue("Expected name set size to decrement for topic.",
parent.getNames().isEmpty());
}
+
+ public void testValue() {
+ final String value1 = "TMAPI Name";
+ final String value2 = "A name";
+ final Name name = createName();
+ name.setValue(value1);
+ assertEquals(value1, name.getValue());
+ name.setValue(value2);
+ assertEquals(value2, name.getValue());
+ try {
+ name.setValue(null);
+ fail("setValue(null) is not allowed");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ // Old value kept.
+ assertEquals(value2, name.getValue());
+ }
+
+ public void testVariantCreationString() {
+ final Name name = createName();
+ final Topic theme = createTopic();
+ final Locator xsdString = createLocator("http://www.w3.org/2001/XMLSchema#string");
+ final Variant variant = name.createVariant("Variant", theme);
+ assertEquals("Variant", variant.getValue());
+ assertEquals(xsdString, variant.getDatatype());
+ assertEquals(1, variant.getScope().size());
+ assertTrue(variant.getScope().contains(theme));
+ }
+
+ public void testVariantCreationURI() {
+ final Name name = createName();
+ final Topic theme = createTopic();
+ final Locator xsdAnyURI = createLocator("http://www.w3.org/2001/XMLSchema#anyURI");
+ final Locator value = createLocator("http://www.example.org/");
+ final Variant variant = name.createVariant(value, theme);
+ assertEquals(value.getReference(), variant.getValue());
+ assertEquals(value, variant.locatorValue());
+ assertEquals(xsdAnyURI, variant.getDatatype());
+ assertEquals(1, variant.getScope().size());
+ assertTrue(variant.getScope().contains(theme));
+ }
+
+ public void testVariantCreationExplicitDatatype() {
+ final Name name = createName();
+ final Topic theme = createTopic();
+ final Locator dt = createLocator("http://www.example.org/datatype");
+ final Variant variant = name.createVariant("Variant", dt, theme);
+ assertEquals("Variant", variant.getValue());
+ assertEquals(dt, variant.getDatatype());
+ assertEquals(1, variant.getScope().size());
+ assertTrue(variant.getScope().contains(theme));
+ }
+
+ public void testVariantCreationIllegalString() {
+ final Name name = createName();
+ final Topic theme = createTopic();
+ try {
+ name.createVariant((String)null, theme);
+ fail("Creation of a variant with (String) null value is not allowed");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testVariantCreationIllegalLocator() {
+ final Name name = createName();
+ final Topic theme = createTopic();
+ try {
+ name.createVariant((Locator)null, theme);
+ fail("Creation of a variant with (Locator) null value is not allowed");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testVariantCreationIllegalDatatype() {
+ final Name name = createName();
+ final Topic theme = createTopic();
+ try {
+ name.createVariant("Variant", (Locator)null, theme);
+ fail("Creation of a variant with datatype == null is not allowed");
+ }
+ catch (Exception ex) {
+ // noop.
+ }
+ }
+
+ public void testVariantCreationIllegalEmptyScope() {
+ final Name name = createName();
+ try {
+ name.createVariant("Variant", Collections.<Topic>emptySet());
+ fail("Creation of a variant with an empty scope is not allowed");
+ }
+ catch (Exception ex) {
+
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tma...@li...> - 2008-08-04 13:55:48
|
Revision: 50
http://tmapi.svn.sourceforge.net/tmapi/?rev=50&view=rev
Author: lheuer
Date: 2008-08-04 13:55:55 +0000 (Mon, 04 Aug 2008)
Log Message:
-----------
- Added LICENSE.txt
Added Paths:
-----------
trunk/LICENSE.txt
Added: trunk/LICENSE.txt
===================================================================
--- trunk/LICENSE.txt (rev 0)
+++ trunk/LICENSE.txt 2008-08-04 13:55:55 UTC (rev 50)
@@ -0,0 +1,13 @@
+TMAPI 2.0
+
+Version 2.0 of the Topic Maps API (TMAPI), 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.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|