|
From: <lh...@us...> - 2008-08-21 12:04:10
|
Revision: 139
http://tinytim.svn.sourceforge.net/tinytim/?rev=139&view=rev
Author: lheuer
Date: 2008-08-21 12:04:16 +0000 (Thu, 21 Aug 2008)
Log Message:
-----------
- Updated to unofficial TMAPI 2.0 a1
- Minor tweaks
- Prepared build for tinyTiM 2.0 a1
Modified Paths:
--------------
tinytim/trunk/build.properties
tinytim/trunk/build.xml
tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java
tinytim/trunk/src/main/java/org/tinytim/core/IScope.java
tinytim/trunk/src/main/java/org/tinytim/core/Scope.java
tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java
tinytim/trunk/src/main/java/org/tinytim/internal/utils/Check.java
tinytim/trunk/src/main/java/org/tinytim/internal/utils/WeakObjectRegistry.java
tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java
Added Paths:
-----------
tinytim/trunk/lib/tmapi-2.0a1-tests.jar
tinytim/trunk/lib/tmapi-2.0a1.jar
tinytim/trunk/src/test/java/org/tinytim/core/TestIConstruct.java
Modified: tinytim/trunk/build.properties
===================================================================
--- tinytim/trunk/build.properties 2008-08-19 14:03:18 UTC (rev 138)
+++ tinytim/trunk/build.properties 2008-08-21 12:04:16 UTC (rev 139)
@@ -1,4 +1,4 @@
version=2.0.0
-version_suffix=alpha1
+version_suffix=a1
debug=off
optimize=on
Modified: tinytim/trunk/build.xml
===================================================================
--- tinytim/trunk/build.xml 2008-08-19 14:03:18 UTC (rev 138)
+++ tinytim/trunk/build.xml 2008-08-21 12:04:16 UTC (rev 139)
@@ -27,12 +27,27 @@
<property name="dir.test" value="${basedir}/src/test/java"/>
<property name="dir.lib" value="${basedir}/lib"/>
<property name="dir.res" value="${basedir}/src/main/resources"/>
+ <property name="dir.coverage" value="${basedir}/coverage"/>
<property name="lib.junit" value="${dir.lib}/junit-4.4.jar"/>
- <property name="lib.trove" value="${dir.lib}/trove-2.0.3.jar"/>
- <property name="lib.tmapi" value="${dir.lib}/tmapi-1_0SP1.jar"/>
- <property name="lib.tmapi.tests" value="${dir.lib}/tmapi-test-1_0SP1.jar"/>
+ <property name="lib.trove" value="${dir.lib}/trove-2.0.4.jar"/>
+ <property name="lib.tmapi" value="${dir.lib}/tmapi-2.0a1.jar"/>
+ <property name="lib.tmapi.tests" value="${dir.lib}/tmapi-2.0a1-tests.jar"/>
+ <property name="lib.emma" value="${dir.lib}/emma.jar"/>
+ <property name="lib.emma.task" value="${dir.lib}/emma_ant.jar"/>
+ <!-- directory that contains emma.jar and emma_ant.jar: -->
+ <property name="dir.emma" value="${dir.lib}" />
+
+ <!-- path element used by EMMA taskdef below: -->
+ <path id="emma.lib" >
+ <pathelement location="${dir.emma}/emma.jar" />
+ <pathelement location="${dir.emma}/emma_ant.jar" />
+ </path>
+
+ <!-- this loads <emma> and <emmajava> custom tasks: -->
+ <taskdef resource="emma_ant.properties" classpathref="emma.lib" />
+
<target name="help">
<echo message="--------------------"/>
<echo message="tinyTiM - Build file"/>
@@ -40,9 +55,11 @@
<echo message=""/>
<echo message="Available targets:"/>
<echo message=""/>
- <echo message=" jar Creates the jar"/>
- <echo message=" doc Creates the API documentation"/>
- <echo message=" release Creates the jar and a distributable file"/>
+ <echo message=" jar Creates the jar"/>
+ <echo message=" testjar Creates the jar with the tests"/>
+ <echo message=" doc Creates the API documentation"/>
+ <echo message=" coverage Creates a coverage report"/>
+ <echo message=" release Creates the jar and a distributable file"/>
</target>
<target name="init">
@@ -50,6 +67,7 @@
<property name="dist.name" value="tinytim-${dist.version}"/>
<property name="tinytim.jar" value="${dist.name}.jar"/>
+ <property name="tinytim-test.jar" value="${dist.name}-tests.jar"/>
<property name="tinytim.tar" value="${dist.name}.tar"/>
<property name="tinytim.tar.gz" value="${tinytim.tar}.gz"/>
<property name="tinytim.zip" value="${dist.name}.zip"/>
@@ -60,6 +78,15 @@
<property name="dir.build.classes" value="${dir.build}/classes"/>
<property name="dir.build.tests" value="${dir.build}/tests"/>
<property name="dir.javadocs" value="${dir.dist}/docs/api"/>
+
+ <path id="run.classpath" >
+ <pathelement location="${dir.build.classes}" />
+ <pathelement location="${dir.build.tests}" />
+ <pathelement location="${lib.junit}"/>
+ <pathelement location="${lib.tmapi}"/>
+ <pathelement location="${lib.tmapi.tests}"/>
+ <pathelement location="${lib.trove}"/>
+ </path>
</target>
<!-- =================================================================== -->
@@ -79,9 +106,9 @@
</target>
<!-- =================================================================== -->
- <!-- Tests -->
+ <!-- Coverage Tests -->
<!-- =================================================================== -->
- <target name="test" depends="compile">
+ <target name="coverage" depends="compile">
<mkdir dir="${dir.build.tests}"/>
<javac destdir="${dir.build.tests}"
debug="${debug}"
@@ -96,23 +123,42 @@
</classpath>
<src path="${dir.test}"/>
</javac>
- <junit printsummary="true" showoutput="false"
- errorProperty="test.failed" failureProperty="test.failed">
+ <mkdir dir="${dir.coverage}"/>
+ <emmajava libclasspathref="emma.lib"
+ sourcepath="${dir.src}"
+ fullmetadata="yes"
+ classname="org.tinytim.core.AllTests"
+ classpathref="run.classpath"
+ >
+ <filter includes="org.tinytim.*" excludes="org.tinytim.*Test*, org.tinytim.*$*" />
+ <html outfile="${dir.coverage}/index.html" />
+ </emmajava>
+ </target>
+
+ <!-- =================================================================== -->
+ <!-- Tests -->
+ <!-- =================================================================== -->
+ <target name="test" depends="compile">
+ <mkdir dir="${dir.build.tests}"/>
+ <javac destdir="${dir.build.tests}"
+ debug="${debug}"
+ optimize="${optimize}"
+ target="1.5">
<classpath>
<pathelement location="${dir.build.classes}"/>
- <pathelement location="${dir.build.tests}"/>
<pathelement location="${lib.junit}"/>
<pathelement location="${lib.tmapi}"/>
<pathelement location="${lib.tmapi.tests}"/>
<pathelement location="${lib.trove}"/>
</classpath>
+ <src path="${dir.test}"/>
+ </javac>
+ <junit printsummary="true" showoutput="false"
+ errorProperty="test.failed" failureProperty="test.failed"
+ fork="true">
+ <classpath refid="run.classpath"/>
<formatter type="brief" usefile="false"/>
- <batchtest fork="no" todir="${dir.build}">
- <fileset dir="${dir.build.tests}/">
- <include name="**/Test**.class"/>
- <exclude name="**/Test*$**.class"/>
- </fileset>
- </batchtest>
+ <test name="org.tinytim.core.AllTests"/>
</junit>
<fail message="Tests failed. Check test output." if="test.failed"/>
</target>
@@ -147,15 +193,16 @@
windowtitle="tinyTiM API v${dist.version}"
doctitle="tinyTiM API v${dist.version}">
<fileset dir="${dir.src}">
- <exclude name="**/*Impl.*"/>
+ <exclude name="org/tinytim/core/**"/>
<exclude name="org/tinytim/index/**"/>
- <exclude name="org/tinytim/IConstruct*"/>
- <exclude name="org/tinytim/IDatatypeAware*"/>
- <exclude name="org/tinytim/IRI*"/>
- <exclude name="org/tinytim/IEvent*"/>
- <exclude name="org/tinytim/Event*"/>
+ <exclude name="org/tinytim/internal/**"/>
</fileset>
- <link href="http://www.tmapi.org/apiDocs/"/>
+<!--
+ <doclet name="net.gleamynode.apiviz.APIviz"
+ path="${dir.lib}/apiviz-1.1.3.jar">
+ </doclet>
+-->
+ <link href="http://www.tmapi.org/2.0/api/"/>
</javadoc>
</target>
@@ -179,12 +226,29 @@
</target>
<!-- =================================================================== -->
+ <!-- Creates the test jar -->
+ <!-- =================================================================== -->
+ <target name="testjar" depends="compile, test">
+ <jar destfile="${dir.build}/${tinytim-test.jar}">
+ <fileset dir="${dir.build.tests}">
+ <include name="**/*.*"/>
+ </fileset>
+ <manifest>
+ <attribute name="Implementation-Title" value="tinyTiM Tests"/>
+ <attribute name="Implementation-Version" value="${dist.version}"/>
+ <attribute name="Implementation-URL" value="http://sourceforge.net/projects/tinytim"/>
+ </manifest>
+ </jar>
+ </target>
+
+ <!-- =================================================================== -->
<!-- Prepares a distribution -->
<!-- =================================================================== -->
- <target name="dist" depends="jar, doc">
+ <target name="dist" depends="jar, testjar, doc">
<mkdir dir="${dir.dist}"/>
<copy todir="${dir.dist}" file="${dir.build}/${tinytim.jar}"/>
+ <copy todir="${dir.dist}" file="${dir.build}/${tinytim-test.jar}"/>
<copy todir="${dir.dist}/src">
<fileset dir="${dir.src}"/>
@@ -193,7 +257,12 @@
<fileset dir="${dir.test}"/>
</copy>
<copy todir="${dir.dist}/lib">
- <fileset dir="${dir.lib}"/>
+ <fileset dir="${dir.lib}">
+ <include name="tmapi*"/>
+ <include name="junit*"/>
+ <include name="LICENSE.junit*"/>
+ <include name="LICENSE.tmapi*"/>
+ </fileset>
</copy>
<copy todir="${dir.dist}" file="CHANGES.txt"/>
Property changes on: tinytim/trunk/lib/tmapi-2.0a1-tests.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: tinytim/trunk/lib/tmapi-2.0a1.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java 2008-08-19 14:03:18 UTC (rev 138)
+++ tinytim/trunk/src/main/java/org/tinytim/core/ConstructImpl.java 2008-08-21 12:04:16 UTC (rev 139)
@@ -116,7 +116,7 @@
*/
@Override
public final int hashCode() {
- return _id.hashCode();
+ return super.hashCode();
}
/**
Modified: tinytim/trunk/src/main/java/org/tinytim/core/IScope.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/IScope.java 2008-08-19 14:03:18 UTC (rev 138)
+++ tinytim/trunk/src/main/java/org/tinytim/core/IScope.java 2008-08-21 12:04:16 UTC (rev 139)
@@ -20,6 +20,7 @@
*/
package org.tinytim.core;
+import java.util.Collection;
import java.util.Set;
import org.tmapi.core.Topic;
@@ -83,4 +84,6 @@
*/
public int size();
+ public boolean containsAll(Collection<Topic> scope);
+
}
Modified: tinytim/trunk/src/main/java/org/tinytim/core/Scope.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/core/Scope.java 2008-08-19 14:03:18 UTC (rev 138)
+++ tinytim/trunk/src/main/java/org/tinytim/core/Scope.java 2008-08-21 12:04:16 UTC (rev 139)
@@ -99,6 +99,13 @@
}
/* (non-Javadoc)
+ * @see org.tinytim.core.IScope#containsAll(java.util.Collection)
+ */
+ public boolean containsAll(Collection<Topic> scope) {
+ return _set.containsAll(scope);
+ }
+
+ /* (non-Javadoc)
* @see org.tinytim.core.IScope#add(org.tmapi.core.Topic)
*/
public IScope add(Topic theme) {
Modified: tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java 2008-08-19 14:03:18 UTC (rev 138)
+++ tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndexImpl.java 2008-08-21 12:04:16 UTC (rev 139)
@@ -87,6 +87,9 @@
*/
public Collection<Association> getAssociations(Topic[] themes,
boolean matchAll) {
+ if (themes == null) {
+ throw new IllegalArgumentException("The themes must not be null");
+ }
Set<Association> result = CollectionFactory.createIdentitySet();
if (!matchAll) {
for (Topic theme: themes) {
@@ -125,6 +128,9 @@
*/
public Collection<Occurrence> getOccurrences(Topic[] themes,
boolean matchAll) {
+ if (themes == null) {
+ throw new IllegalArgumentException("The themes must not be null");
+ }
Set<Occurrence> result = CollectionFactory.createIdentitySet();
if (!matchAll) {
for (Topic theme: themes) {
@@ -162,6 +168,9 @@
* @see org.tmapi.index.ScopedIndex#getNames(org.tmapi.core.Topic[], boolean)
*/
public Collection<Name> getNames(Topic[] themes, boolean matchAll) {
+ if (themes == null) {
+ throw new IllegalArgumentException("The themes must not be null");
+ }
Set<Name> result = CollectionFactory.createIdentitySet();
if (!matchAll) {
for (Topic theme: themes) {
@@ -190,6 +199,9 @@
* @see org.tmapi.index.ScopedIndex#getVariants(org.tmapi.core.Topic)
*/
public Collection<Variant> getVariants(Topic theme) {
+ if (theme == null) {
+ throw new IllegalArgumentException("The theme must not be null");
+ }
Collection<Variant> vars = _theme2Variants.get(theme);
return vars == null ? Collections.<Variant>emptySet()
: CollectionFactory.createList(vars);
@@ -199,6 +211,9 @@
* @see org.tmapi.index.ScopedIndex#getVariants(org.tmapi.core.Topic[], boolean)
*/
public Collection<Variant> getVariants(Topic[] themes, boolean matchAll) {
+ if (themes == null) {
+ throw new IllegalArgumentException("The themes must not be null");
+ }
Set<Variant> result = CollectionFactory.createIdentitySet();
if (!matchAll) {
for (Topic theme: themes) {
Modified: tinytim/trunk/src/main/java/org/tinytim/internal/utils/Check.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/internal/utils/Check.java 2008-08-19 14:03:18 UTC (rev 138)
+++ tinytim/trunk/src/main/java/org/tinytim/internal/utils/Check.java 2008-08-21 12:04:16 UTC (rev 139)
@@ -31,7 +31,7 @@
*
*
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
- * @version $Rev:$ - $Date:$
+ * @version $Rev$ - $Date$
*/
public class Check {
Modified: tinytim/trunk/src/main/java/org/tinytim/internal/utils/WeakObjectRegistry.java
===================================================================
--- tinytim/trunk/src/main/java/org/tinytim/internal/utils/WeakObjectRegistry.java 2008-08-19 14:03:18 UTC (rev 138)
+++ tinytim/trunk/src/main/java/org/tinytim/internal/utils/WeakObjectRegistry.java 2008-08-21 12:04:16 UTC (rev 139)
@@ -21,8 +21,6 @@
package org.tinytim.internal.utils;
import java.lang.ref.WeakReference;
-import java.util.AbstractSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.WeakHashMap;
@@ -32,7 +30,7 @@
* @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
* @version $Rev$ - $Date$
*/
-public final class WeakObjectRegistry<E> extends AbstractSet<E> {
+public final class WeakObjectRegistry<E> {
private final Map<E, WeakReference<E>> _obj2Ref;
@@ -60,7 +58,6 @@
/* (non-Javadoc)
* @see java.util.AbstractCollection#add(java.lang.Object)
*/
- @Override
public boolean add(E obj) {
WeakReference<E> ref = new WeakReference<E>(obj);
ref = _obj2Ref.put(obj, ref);
@@ -68,42 +65,15 @@
}
/* (non-Javadoc)
- * @see java.util.AbstractCollection#remove(java.lang.Object)
- */
- @Override
- public boolean remove(Object obj) {
- WeakReference<E> ref = _obj2Ref.remove(obj);
- return ref != null && ref.get() != null;
- }
-
- /* (non-Javadoc)
* @see java.util.AbstractCollection#clear()
*/
- @Override
public void clear() {
_obj2Ref.clear();
}
/* (non-Javadoc)
- * @see java.util.AbstractCollection#contains(java.lang.Object)
- */
- @Override
- public boolean contains(Object obj) {
- return get(obj) != null;
- }
-
- /* (non-Javadoc)
- * @see java.util.AbstractCollection#iterator()
- */
- @Override
- public Iterator<E> iterator() {
- return _obj2Ref.keySet().iterator();
- }
-
- /* (non-Javadoc)
* @see java.util.AbstractCollection#size()
*/
- @Override
public int size() {
return _obj2Ref.size();
}
Modified: tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java 2008-08-19 14:03:18 UTC (rev 138)
+++ tinytim/trunk/src/test/java/org/tinytim/core/AllTests.java 2008-08-21 12:04:16 UTC (rev 139)
@@ -42,6 +42,7 @@
TestSuite suite = new TestSuite();
suite.addTestSuite(TestDuplicateRemovalUtils.class);
suite.addTestSuite(TestIRI.class);
+ suite.addTestSuite(TestIConstruct.class);
suite.addTestSuite(TestScope.class);
suite.addTestSuite(TestLiteral.class);
suite.addTestSuite(TestItemIdentifierConstraint.class);
Added: tinytim/trunk/src/test/java/org/tinytim/core/TestIConstruct.java
===================================================================
--- tinytim/trunk/src/test/java/org/tinytim/core/TestIConstruct.java (rev 0)
+++ tinytim/trunk/src/test/java/org/tinytim/core/TestIConstruct.java 2008-08-21 12:04:16 UTC (rev 139)
@@ -0,0 +1,79 @@
+/*
+ * This is tinyTiM, a tiny Topic Maps engine.
+ *
+ * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+package org.tinytim.core;
+
+import org.tmapi.core.Association;
+import org.tmapi.core.Construct;
+import org.tmapi.core.Name;
+import org.tmapi.core.Occurrence;
+import org.tmapi.core.Role;
+import org.tmapi.core.Topic;
+import org.tmapi.core.TopicMap;
+import org.tmapi.core.Variant;
+
+/**
+ *
+ *
+ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a>
+ * @version $Rev:$ - $Date:$
+ */
+public class TestIConstruct extends TinyTimTestCase {
+
+
+ private void _testConstruct(Construct construct) {
+ IConstruct c = (IConstruct) construct;
+ assertEquals(c.isTopicMap(), c instanceof TopicMap);
+ assertEquals(c.isTopic(), c instanceof Topic);
+ assertEquals(c.isAssociation(), c instanceof Association);
+ assertEquals(c.isRole(), c instanceof Role);
+ assertEquals(c.isOccurrence(), c instanceof Occurrence);
+ assertEquals(c.isName(), c instanceof Name);
+ assertEquals(c.isVariant(), c instanceof Variant);
+ }
+
+ public void testTopicMap() {
+ _testConstruct(_tm);
+ }
+
+ public void testTopic() {
+ _testConstruct(createTopic());
+ }
+
+ public void testAssociation() {
+ _testConstruct(createAssociation());
+ }
+
+ public void testRole() {
+ _testConstruct(createRole());
+ }
+
+ public void testOccurrence() {
+ _testConstruct(createOccurrence());
+ }
+
+ public void testName() {
+ _testConstruct(createName());
+ }
+
+ public void testVariant() {
+ _testConstruct(createVariant());
+ }
+}
Property changes on: tinytim/trunk/src/test/java/org/tinytim/core/TestIConstruct.java
___________________________________________________________________
Added: svn:keywords
+ Rev Date Id
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|