Update of /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17903/src/org/tmapiutils/query/tolog/predicates/test Modified Files: AssociationPredicateTest.java AssociationRolePredicateTest.java BaseLocatorPredicateTest.java DirectInstanceOfPredicateTest.java DynamicAssociationPredicateTest.java InstanceOfPredicateTest.java OccurrencePredicateTest.java PredicateTestBase.java ReifiesPredicateTest.java ResourcePredicateTest.java TopicMapPredicateTest.java TopicNameTest.java TypePredicateTest.java ValueLikePredicateTest.java ValuePredicateTest.java VariantPredicateTest.java Log Message: Shift to Apache License 2.0 More TMAPI compatible, some classes already compile. ;) Deleted CVS log from files Index: ResourcePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/ResourcePredicateTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ResourcePredicateTest.java 7 Mar 2005 12:32:00 -0000 1.4 --- ResourcePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.5 *************** *** 1,10 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ *************** *** 27,31 **** /** * ! * @author Kal Ahmed (ka...@te...) */ public class ResourcePredicateTest extends PredicateTestBase { --- 34,39 ---- /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ResourcePredicateTest extends PredicateTestBase { *************** *** 57,61 **** --- 65,71 ---- tmapiutils.addSubjectIdentifier(createLocator("tmapiutils")); Topic homepage = tm.createTopic(); + Topic contact_details = tm.createTopic(); tmapiutils.createOccurrence(createLocator("http://tmapiutils.org/", homepage, null); + tmapiutils.createOccurrence(createLocator("http://tmapiutils.org/contact/", contact_details, null); Topic tmapi = tm.createTopic(); tmapiutils.addSubjectIdentifier(createLocator("tmapi")); *************** *** 166,188 **** } - - /* - * $Log$ - * Revision 1.4 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.3 2005/03/06 19:37:40 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.2 2005/03/06 18:15:43 lheuer - * org.tmapi.core.Locator -> org.tmapi.core.Locator - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.1 2004/07/27 10:15:57 kal_ahmed - * Initial version - * - */ \ No newline at end of file --- 176,177 ---- Index: PredicateTestBase.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/PredicateTestBase.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PredicateTestBase.java 7 Mar 2005 13:12:38 -0000 1.6 --- PredicateTestBase.java 8 Mar 2005 12:33:58 -0000 1.7 *************** *** 1,17 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.predicates.test; import java.util.HashMap; - //import java.io.StringReader; - import junit.framework.TestCase; --- 1,24 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates.test; + import java.util.Iterator; import java.util.HashMap; import junit.framework.TestCase; *************** *** 24,32 **** import org.tmapi.core.TopicMapObject; import org.tmapi.core.TopicMap; /** - * @author Kal * ! * Describe PredicateTestBase here. */ public abstract class PredicateTestBase extends TestCase { --- 31,40 ---- import org.tmapi.core.TopicMapObject; import org.tmapi.core.TopicMap; + import org.tmapi.core.TMAPIException; /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public abstract class PredicateTestBase extends TestCase { *************** *** 34,38 **** protected Predicate m_predicate; ! protected TopicMap _topicMap; private HashMap _maps; private HashMap _objectMap; --- 42,46 ---- protected Predicate m_predicate; ! protected TopicMap m_tm; private HashMap _maps; private HashMap _objectMap; *************** *** 53,62 **** public void setUp() throws Exception { ! super().setUp(); ! _tmSystem = TopicMapSystemFactory().newInstance().newTopicMapSystem(); removeAllMaps(); ! m_tm = createTopicMap('http://tmapiutils.org/test/tolog1.0/'); m_predicate = (Predicate) getPredicateClass().newInstance(); - m_predicate.createTestMap(m_tm); m_predicate.initialise(m_tm); m_context = new TologContext(); --- 61,70 ---- public void setUp() throws Exception { ! super.setUp(); ! _tmSystem = TopicMapSystemFactory.newInstance().newTopicMapSystem(); removeAllMaps(); ! m_tm = createTopicMap("http://tmapiutils.org/test/tolog1.0/"); ! createTestMap(m_tm); m_predicate = (Predicate) getPredicateClass().newInstance(); m_predicate.initialise(m_tm); m_context = new TologContext(); *************** *** 67,71 **** _objectMap.clear(); // remove created TopicMaps from TopicMapSystem ! removeAllMaps(); // Close TopicMapSystem instance _tmSystem.close(); --- 75,79 ---- _objectMap.clear(); // remove created TopicMaps from TopicMapSystem ! removeAllMaps(); // Close TopicMapSystem instance _tmSystem.close(); *************** *** 85,135 **** protected void removeAllMaps() throws TMAPIException { ! for (Iterator iter = _tmSystem.getBaseLocators().iterator(); iter.hasNext();) removeTopicMap(_tmSystem.getTopicMap((Locator)iter.next())); } } ! protected TopicMap createTopicMap(String reference)throws TopicMapExistsException{ TopicMap tm = _tmSystem.createTopicMap(reference); ! _maps.put(reference,tm); return tm; } ! protected void removeTopicMap(TopicMap tm)throws TMAPIException{ _maps.remove(tm.getBaseLocator().getReference()); tm.remove(); } - - } - /* - * $Log$ - * Revision 1.6 2005/03/07 13:12:38 lheuer - * Clear the _objectMap in tearDown() - * - * Revision 1.5 2005/03/07 13:00:41 lheuer - * Typo _system vs. _tmSystem - * - * Revision 1.4 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.3 2005/03/06 19:37:40 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.2 2005/03/06 18:15:43 lheuer - * org.tmapi.core.Locator -> org.tmapi.core.Locator - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.4 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.3 2004/06/13 11:30:26 kal_ahmed - * Initial implementation of value-like predicate. - * - * Revision 1.2 2004/06/10 17:09:35 kal_ahmed - * Added reifies and instance-of predicates. - * - */ \ No newline at end of file --- 93,110 ---- protected void removeAllMaps() throws TMAPIException { ! for (Iterator iter = _tmSystem.getBaseLocators().iterator(); iter.hasNext();) { removeTopicMap(_tmSystem.getTopicMap((Locator)iter.next())); } } ! protected TopicMap createTopicMap(String reference) throws TMAPIException { TopicMap tm = _tmSystem.createTopicMap(reference); ! _maps.put(reference, tm); return tm; } ! ! protected void removeTopicMap(TopicMap tm) throws TMAPIException { _maps.remove(tm.getBaseLocator().getReference()); tm.remove(); } } Index: TopicMapPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/TopicMapPredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TopicMapPredicateTest.java 7 Mar 2005 12:32:00 -0000 1.3 --- TopicMapPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.predicates.test; *************** *** 22,27 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class TopicMapPredicateTest extends PredicateTestBase { --- 29,35 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TopicMapPredicateTest extends PredicateTestBase { *************** *** 62,66 **** assertEquals(m_tm, out.getRow(0).get(0)); } ! public void testClosedMatch() throws Exception { tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); --- 70,74 ---- assertEquals(m_tm, out.getRow(0).get(0)); } ! public void testClosedMatch() throws Exception { tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); *************** *** 75,79 **** assertEquals(1, out.getRows().size()); assertEquals(m_tm, out.getRow(0).get(0)); ! TopicMapObject tmo = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("hello-world")); params.set(0, tmo); --- 83,87 ---- assertEquals(1, out.getRows().size()); assertEquals(m_tm, out.getRow(0).get(0)); ! TopicMapObject tmo = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("hello-world")); params.set(0, tmo); *************** *** 84,106 **** } - - /* - * $Log$ - * Revision 1.3 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.2 2005/03/06 19:37:40 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.1 2004/06/13 10:32:29 kal_ahmed - * Initial implementation of topicmap() predicate. - * - */ \ No newline at end of file --- 92,93 ---- Index: ReifiesPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/ReifiesPredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReifiesPredicateTest.java 7 Mar 2005 12:32:00 -0000 1.3 --- ReifiesPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates.test; *************** *** 17,26 **** // import org.tmapi.core.utils.TopicMapBuilder; // import org.tmapi.core.utils.XTMBuilder; ! import org.tmapi.index.core.TopicMapObjectsIndex; /** ! * @author Kal ! * ! * Describe ReifiesPredicateTest here. */ public class ReifiesPredicateTest extends PredicateTestBase { --- 25,38 ---- // import org.tmapi.core.utils.TopicMapBuilder; // import org.tmapi.core.utils.XTMBuilder; ! //import org.tmapi.index.core.TopicMapObjectsIndex; ! // TMAPI ! import org.tmapi.core.TopicMap; ! import org.tmapi.core.Topic; ! import org.tmapi.core.Association; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ReifiesPredicateTest extends PredicateTestBase { *************** *** 37,41 **** */ public String getTestMap() { ! return "<topicMap xmlns=\"http://www.topicmaps.org/xtm/1.0/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" + "<topic id=\"fred\"/> <topic id=\"bigco\"/> <topic id=\"worksfor\"/>" + "<association id=\"assoc1\">" + "<instanceOf><topicRef xlink:href=\"#worksfor\"/></instanceOf>" + "<member id=\"m1\"><topicRef xlink:href=\"#fred\"/></member>" + "<member id=\"m2\"><topicRef xlink:href=\"#bigco\"/></member>" + "</association>" + "<topic id=\"fredemp\"> <subjectIdentity><resourceRef xlink:href=\"#assoc1\"/> </subjectIdentity> </topic>" + "</topicMap>"; } --- 49,60 ---- */ public String getTestMap() { ! return "<topicMap xmlns=\"http://www.topicmaps.org/xtm/1.0/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" + ! "<topic id=\"fred\"/> <topic id=\"bigco\"/> <topic id=\"worksfor\"/>" ! "<association id=\"assoc1\">" + ! "<instanceOf><topicRef xlink:href=\"#worksfor\"/></instanceOf>" + ! "<member id=\"m1\"><topicRef xlink:href=\"#fred\"/></member>" + ! "<member id=\"m2\"><topicRef xlink:href=\"#bigco\"/></member>" + ! "</association>" + ! "<topic id=\"fredemp\"> <subjectIdentity><resourceRef xlink:href=\"#assoc1\"/> </subjectIdentity> </topic>" + "</topicMap>"; } *************** *** 49,66 **** Topic fred = tm.createTopic(); Topic fredemp = tm.createTopic(); - fred.addSubjectIdentifier(tm.createLocator("fred")); Topic barney = tm.createTopic(); - barney.addSubjectIdentifier(tm.createLocator("barney")); Topic employee = tm.createTopic(); Topic employer = tm.createTopic(); Topic bigco = tm.createTopic(); ! Association assoc = tm.createAssociation(); ! assoc.setType(works_for); ! assoc.createAssociationRole(fred, employee); ! assoc.createAssociationRole(bigco, employer); ! assoc.createAssociationRole(barney, employee); } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.test.PredicateTestBase#getPredicateClass() --- 68,88 ---- Topic fred = tm.createTopic(); Topic fredemp = tm.createTopic(); Topic barney = tm.createTopic(); Topic employee = tm.createTopic(); Topic employer = tm.createTopic(); Topic bigco = tm.createTopic(); ! Association assoc1 = tm.createAssociation(); ! assoc1.setType(works_for); ! assoc1.createAssociationRole(fred, employee); ! assoc1.createAssociationRole(bigco, employer); ! assoc1.createAssociationRole(barney, employee); ! ! registerObject("assoc1", assoc1); ! registerObject("fred", fred); ! registerObject("barney", barney); ! registerObject("fredemp", fredemp); } ! /* (non-Javadoc) * @see org.tmapiutils.query.tolog.predicates.test.PredicateTestBase#getPredicateClass() *************** *** 71,81 **** public void testMatchReifier() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); params.add(a); ! params.add(m_tm.getObjectById("assoc1")); m_predicate.setParameters(params); VariableSet out = m_predicate.matches(params, m_context); --- 93,100 ---- public void testMatchReifier() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); params.add(a); ! params.add(getObjectById("assoc1")); m_predicate.setParameters(params); VariableSet out = m_predicate.matches(params, m_context); *************** *** 83,97 **** assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! TopicMapObject tmo = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("fredemp")); ! assertTrue(out.getRow(0).contains(tmo)); } ! public void testMatchReified() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! params.add(m_tm.getObjectById("fredemp")); params.add(a); m_predicate.setParameters(params); --- 102,112 ---- assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getRow(0).contains(getObjectById("fredemp"))); } ! public void testMatchReified() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! params.add(fredemp); params.add(a); m_predicate.setParameters(params); *************** *** 100,111 **** assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! TopicMapObject tmo = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("assoc1")); ! assertTrue(out.getRow(0).contains(tmo)); } ! public void testOpenMatch() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 115,122 ---- assertEquals(1, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getRow(0).contains(getObjectById("fredemp"))); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); *************** *** 118,131 **** assertEquals(2, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! TopicMapObject fredemp = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("fredemp")); ! TopicMapObject assoc1 = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("assoc1")); ! assertTrue(out.getRow(0).get(0).equals(fredemp)); ! assertTrue(out.getRow(0).get(1).equals(assoc1)); } ! public void testClosedMatch() throws Exception { - tmoIdx = (TopicMapObjectsIndex) m_tm.getHelperObject(TopicMapObjectsIndex.class); - tmoIdx.open(); - tmoIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 129,137 ---- assertEquals(2, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! assertTrue(out.getRow(0).get(0).equals(getObjectById("fredemp"))); ! assertTrue(out.getRow(0).get(1).equals(getObjectById("assoc1"))); } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); *************** *** 134,173 **** params.add(b); m_predicate.setParameters(params); ! TopicMapObject fredemp = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("fredemp")); ! TopicMapObject assoc1 = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("assoc1")); ! params.set(0, fredemp)); ! params.set(1, assoc1)); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(2, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! TopicMapObject m1 = tmoIdx.getTopicMapObjectBySourceLocator(createLocator("m1")); ! params.set(0, fredemp)); ! params.set(1, m1)); out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(2, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! } } - /* - * $Log$ - * Revision 1.3 2005/03/07 12:32:00 lheuer - * More TM4J -> TMAPI translations - * Updated ToDo - * ResourcePredicate can handle Variants, too - * - * Revision 1.2 2005/03/06 21:11:33 lheuer - * More TM4J -> TMAPI translations - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.1 2004/06/10 17:09:35 kal_ahmed - * Added reifies and instance-of predicates. - * - */ \ No newline at end of file --- 140,156 ---- params.add(b); m_predicate.setParameters(params); ! params.set(0, getObjectById("fredemp"))); ! params.set(1, getObjectById("assoc1"))); VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(2, out.getColumns().size()); assertEquals(1, out.getRows().size()); ! params.set(0, getObjectById("fredemp"))); ! params.set(1, getObjectById("m1"))); out = m_predicate.matches(params, m_context); assertNotNull(out); assertEquals(2, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! } } Index: AssociationRolePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/AssociationRolePredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AssociationRolePredicateTest.java 7 Mar 2005 12:32:00 -0000 1.3 --- AssociationRolePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 *************** *** 1,11 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ *************** *** 24,33 **** import org.tmapi.core.Association; import org.tmapi.core.AssociationRole; - import org.tmapi.index.core.TopicsIndex; /** - * @author Kal * ! * Describe AssociationRolePredicateTest here. */ public class AssociationRolePredicateTest extends PredicateTestBase { --- 30,38 ---- import org.tmapi.core.Association; import org.tmapi.core.AssociationRole; /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class AssociationRolePredicateTest extends PredicateTestBase { *************** *** 64,67 **** --- 69,75 ---- assoc.createAssociationRole(bigco, employer); assoc.createAssociationRole(barney, employee); + + registerObject("fred", fred); + registerObject("barney", barney); } *************** *** 74,83 **** public void testMatchAssociation() throws Exception { - TopicsIndex topicsIdx = m_tm.getHelperObjects(TopicsIndex.class); - topicsIdx.open(); - topicsIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! Topic fred = topicsIdx.getTopicBySubjectIdentifier(createLocator("fred")); AssociationRole role = (AssociationRole) fred.getRolesPlayed().iterator().next(); params.add(a); --- 82,88 ---- public void testMatchAssociation() throws Exception { ArrayList params = new ArrayList(); Variable a = new Variable("A"); ! Topic fred = (Topic) getObjectById("fred"); AssociationRole role = (AssociationRole) fred.getRolesPlayed().iterator().next(); params.add(a); *************** *** 92,100 **** public void testMatchRoles() throws Exception { - TopicsIndex topicsIdx = m_tm.getHelperObjects(TopicsIndex.class); - topicsIdx.open(); - topicsIdx.reindex(); ArrayList params = new ArrayList(); ! Topic barney = topicsIdx.getTopicBySubjectIdentifier(createLocator("fred")); Association assoc = ((AssociationRole) barney.getRolesPlayed().iterator().next()).getAssociation(); Variable a = new Variable("A"); --- 97,102 ---- public void testMatchRoles() throws Exception { ArrayList params = new ArrayList(); ! Topic barney =(Topic) getObjectById("barney"); Association assoc = ((AssociationRole) barney.getRolesPlayed().iterator().next()).getAssociation(); Variable a = new Variable("A"); *************** *** 106,111 **** assertEquals(1, out.getColumns().size()); assertEquals(2, out.getRows().size()); ! assertEquals(assoc, ((AssociationRole)out.getRow(0).get(0)).getParent()); ! assertEquals(assoc, ((AssociationRole)out.getRow(1).get(0)).getParent()); } --- 108,113 ---- assertEquals(1, out.getColumns().size()); assertEquals(2, out.getRows().size()); ! assertEquals(assoc, ((AssociationRole)out.getRow(0).get(0)).getAssociation()); ! assertEquals(assoc, ((AssociationRole)out.getRow(1).get(0)).getAssociation()); } *************** *** 129,135 **** public void testClosedMatch() throws Exception { - TopicsIndex topicsIdx = m_tm.getHelperObjects(TopicsIndex.class); - topicsIdx.open(); - topicsIdx.reindex(); ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 131,134 ---- *************** *** 138,142 **** params.add(b); m_predicate.setParameters(params); ! Topic fred = topicsIdx.getTopicBySubjectIdentifier(createLocator("fred")); AssociationRole role = (AssociationRole) fred.getRolesPlayed().iterator().next(); Association assoc = role.getAssociation(); --- 137,141 ---- params.add(b); m_predicate.setParameters(params); ! Topic fred = (Topic) getObjectById("fred"); AssociationRole role = (AssociationRole) fred.getRolesPlayed().iterator().next(); Association assoc = role.getAssociation(); *************** *** 148,152 **** assertEquals(1, out.getRows().size()); ! Topic barney = topicsIdx.getTopicBySubjectIdentifier(createLocator("barney")); AssociationRole role2 = (AssociationRole)barney.getRolesPlayed().iterator().next(); params.set(1, role2); --- 147,151 ---- assertEquals(1, out.getRows().size()); ! Topic barney =(Topic) getObjectById("barney"); AssociationRole role2 = (AssociationRole)barney.getRolesPlayed().iterator().next(); params.set(1, role2); *************** *** 157,178 **** } } ! /* ! * $Log$ ! * Revision 1.3 2005/03/07 12:32:00 lheuer ! * More TM4J -> TMAPI translations ! * Updated ToDo ! * ResourcePredicate can handle Variants, too ! * ! * Revision 1.2 2005/03/06 19:37:23 lheuer ! * Changed getTopicByID to getObjectById ! * ! * Revision 1.1 2005/03/06 17:33:23 lheuer ! * Initial tolog import ! * ! * Revision 1.2 2004/06/14 20:09:46 kal_ahmed ! * Updated test code to work with new Predicate interface. ! * ! * Revision 1.1 2004/06/11 08:29:29 kal_ahmed ! * Added association and association-role predicates. ! * ! */ \ No newline at end of file --- 156,158 ---- } } ! Index: DirectInstanceOfPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/DirectInstanceOfPredicateTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DirectInstanceOfPredicateTest.java 7 Mar 2005 12:32:00 -0000 1.5 --- DirectInstanceOfPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.6 *************** *** 1,6 **** /* ! * Created on 10-Jun-2004 ! * @author Kal */ package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates.test; *************** *** 27,33 **** /** - * @author Kal * ! * Describe DirectInstanceOfPredicateTest here. */ public class DirectInstanceOfPredicateTest extends TestCase { --- 40,46 ---- /** * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class DirectInstanceOfPredicateTest extends TestCase { Index: BaseLocatorPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/BaseLocatorPredicateTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BaseLocatorPredicateTest.java 7 Mar 2005 12:32:00 -0000 1.2 --- BaseLocatorPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.3 *************** *** 1,6 **** /* ! * Created on 11-Jun-2004 ! * @author Kal */ package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates.test; *************** *** 10,18 **** import org.tmapiutils.query.tolog.predicates.BaseLocatorPredicate; import org.tmapiutils.query.tolog.utils.VariableSet; /** ! * @author Kal ! * ! * Describe BaseLocatorPredicateTest here. */ public class BaseLocatorPredicateTest extends PredicateTestBase { --- 23,33 ---- import org.tmapiutils.query.tolog.predicates.BaseLocatorPredicate; import org.tmapiutils.query.tolog.utils.VariableSet; + // TMAPI + import org.tmapi.core.TopicMap; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class BaseLocatorPredicateTest extends PredicateTestBase { *************** *** 31,35 **** return "[test]"; } ! public void createTestMap(TopicMap tm) { // noop. --- 46,50 ---- return "[test]"; } ! public void createTestMap(TopicMap tm) { // noop. *************** *** 42,46 **** return BaseLocatorPredicate.class; } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); --- 57,61 ---- return BaseLocatorPredicate.class; } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 52,58 **** assertEquals(1, out.getRows().size()); assertEquals(m_tm.getBaseLocator(), out.getRow(0).get(0)); ! } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); --- 67,73 ---- assertEquals(1, out.getRows().size()); assertEquals(m_tm.getBaseLocator(), out.getRow(0).get(0)); ! } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 72,76 **** assertEquals(1, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! } --- 87,91 ---- assertEquals(1, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! } Index: DynamicAssociationPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/DynamicAssociationPredicateTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DynamicAssociationPredicateTest.java 6 Mar 2005 19:37:23 -0000 1.3 --- DynamicAssociationPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.4 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.predicates.test; *************** *** 33,38 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class DynamicAssociationPredicateTest extends TestCase { --- 40,46 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class DynamicAssociationPredicateTest extends TestCase { *************** *** 76,80 **** } ! public void testMultipleMatch() throws Exception { --- 84,88 ---- } ! public void testMultipleMatch() throws Exception { *************** *** 105,109 **** } } ! public void testRoleMatch() throws Exception { ClauseList c = new ClauseList(); --- 113,117 ---- } } ! public void testRoleMatch() throws Exception { ClauseList c = new ClauseList(); *************** *** 135,139 **** } } ! /* (non-Javadoc) * @see junit.framework.TestCase#setUp() --- 143,147 ---- } } ! /* (non-Javadoc) * @see junit.framework.TestCase#setUp() *************** *** 152,184 **** } - - /* - * $Log$ - * Revision 1.3 2005/03/06 19:37:23 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.2 2005/03/06 18:15:43 lheuer - * org.tmapi.core.Locator -> org.tmapi.core.Locator - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.3 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.2 2004/06/09 20:20:30 kal_ahmed - * Major reworking of the predicate interfaces and internal implementation of VariableSet to reduce the use of HashMaps. - * - * Revision 1.1 2004/06/07 20:42:24 kal_ahmed - * Added infrastructure for backend-specific implementations and start of a default in-memory implementation. - * - * Revision 1.3 2004/06/03 20:04:56 kal_ahmed - * Completed initial package restructuring. - * - * Revision 1.2 2004/06/03 19:55:17 kal_ahmed - * Created utils package to hold common utility classes for Tolog implementations. - * - * Revision 1.1 2004/05/30 22:08:25 kal_ahmed - * Initial version of tolog 1.0 engine - * - */ \ No newline at end of file --- 160,161 ---- Index: VariantPredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/VariantPredicateTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VariantPredicateTest.java 6 Mar 2005 19:37:40 -0000 1.2 --- VariantPredicateTest.java 8 Mar 2005 12:33:58 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.predicates.test; *************** *** 20,25 **** /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class VariantPredicateTest extends PredicateTestBase { --- 27,33 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class VariantPredicateTest extends PredicateTestBase { *************** *** 53,58 **** params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); params.set(0, fredName); VariableSet out = m_predicate.matches(params, m_context); --- 61,66 ---- params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); params.set(0, fredName); VariableSet out = m_predicate.matches(params, m_context); *************** *** 61,65 **** assertEquals(fredName.getVariants().iterator().next(), out.getRow(0).get(1)); } ! public void testGetTopicName() throws Exception { ArrayList params = new ArrayList(); --- 69,73 ---- assertEquals(fredName.getVariants().iterator().next(), out.getRow(0).get(1)); } ! public void testGetTopicName() throws Exception { ArrayList params = new ArrayList(); *************** *** 69,74 **** params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(1, fredVar); --- 77,82 ---- params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(1, fredVar); *************** *** 78,82 **** assertEquals(fredName, out.getRow(0).get(0)); } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); --- 86,90 ---- assertEquals(fredName, out.getRow(0).get(0)); } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 86,91 **** params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(0, fredName); --- 94,99 ---- params.add(b); m_predicate.setParameters(params); ! ! TopicName fredName = (TopicName) m_tm.getObjectById("fred").getTopicNames().iterator().next(); Variant fredVar = (Variant) fredName.getVariants().iterator().next(); params.set(0, fredName); *************** *** 97,101 **** assertEquals(fredVar, out.getRow(0).get(1)); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); --- 105,109 ---- assertEquals(fredVar, out.getRow(0).get(1)); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 105,109 **** params.add(b); m_predicate.setParameters(params); ! VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); --- 113,117 ---- params.add(b); m_predicate.setParameters(params); ! VariableSet out = m_predicate.matches(params, m_context); assertNotNull(out); *************** *** 112,129 **** } - - /* - * $Log$ - * Revision 1.2 2005/03/06 19:37:40 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.1 2005/03/06 17:33:24 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.1 2004/06/13 10:56:32 kal_ahmed - * Initial implementation of variant() predicate. - * - */ \ No newline at end of file --- 120,121 ---- Index: ValuePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/ValuePredicateTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ValuePredicateTest.java 6 Mar 2005 19:37:40 -0000 1.2 --- ValuePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.3 *************** *** 1,12 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ ! package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ ! package org.tmapiutils.query.tolog.predicates.test; *************** *** 19,33 **** import org.tmapiutils.query.tolog.utils.VariableSet; - // TODO: - import org.tmapi.core.DataObject; - // TMAPI import org.tmapi.core.Topic; - import org.tmapi.core.TopicName; import org.tmapi.core.Occurrence; /** ! * ! * @author Kal Ahmed (ka...@te...) */ public class ValuePredicateTest extends PredicateTestBase { --- 26,40 ---- import org.tmapiutils.query.tolog.utils.VariableSet; // TMAPI + import org.tmapi.core.TopicMap import org.tmapi.core.Topic; import org.tmapi.core.Occurrence; + import org.tmapi.core.TopicName; + import org.tmapi.core.Variant; /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class ValuePredicateTest extends PredicateTestBase { *************** *** 44,48 **** */ public String getTestMap() { ! return "[bond = \"James Bond\";\"bond, james\";\"James Bond\"\n" + " = \"007\" / hmg]" + "{bond, favourite-drink, [[\"Vodka martini. Shaken not stirred\"]]}"; } --- 51,68 ---- */ public String getTestMap() { ! return "[bond = \"James Bond\";\"bond, james\";\"James Bond\"\n" + ! " = \"007\" / hmg]" + ! "{bond, favourite-drink, [[\"Vodka martini. Shaken not stirred\"]]}"; ! } ! ! public void createTestMap(TopicMap tm) { ! Topic bond = tm.createTopic(); ! Topic fav_drink = tm.createTopic(); ! TopicName tn bond.createTopicName("James Bond", null); ! // ToDo: Create variants! ! bond.createOccurrence("Vodka martini. Shaken not stirred", fav_drink, null); ! ! registerObject("bond", bond); ! registerObject("favourite-drink", fav_drink); } *************** *** 75,79 **** } } ! public void testMatchOnObject() throws Exception { ArrayList params = new ArrayList(); --- 95,99 ---- } } ! public void testMatchOnObject() throws Exception { ArrayList params = new ArrayList(); *************** *** 83,87 **** params.add(b); m_predicate.setParameters(params); ! TopicName bn = (TopicName) ((Topic) m_tm.getObjectById("bond")).getTopicNames().iterator().next(); params.set(0, bn); VariableSet out = m_predicate.matches(params, m_context); --- 103,107 ---- params.add(b); m_predicate.setParameters(params); ! TopicName bn = (TopicName) ((Topic) getObjectById("bond")).getTopicNames().iterator().next(); params.set(0, bn); VariableSet out = m_predicate.matches(params, m_context); *************** *** 95,100 **** assertEquals(bn.getValue(), o); } ! ! Occurrence o = (Occurrence) ((Topic) m_tm.getObjectById("bond")).getOccurrences().iterator().next(); assertNotNull(o.getValue()); params.set(0, o); --- 115,120 ---- assertEquals(bn.getValue(), o); } ! ! Occurrence o = (Occurrence) ((Topic) getObjectById("bond")).getOccurrences().iterator().next(); assertNotNull(o.getValue()); params.set(0, o); *************** *** 105,109 **** assertEquals(o.getValue(), out.getRow(0).get(1)); } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); --- 125,129 ---- assertEquals(o.getValue(), out.getRow(0).get(1)); } ! public void testClosedMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 113,117 **** params.add(b); m_predicate.setParameters(params); ! TopicName bn = (TopicName) ((Topic) m_tm.getObjectById("bond")).getTopicNames().iterator().next(); params.set(0, bn); params.set(1, bn.getValue()); --- 133,137 ---- params.add(b); m_predicate.setParameters(params); ! TopicName bn = (TopicName) ((Topic) getObjectById("bond")).getTopicNames().iterator().next(); params.set(0, bn); params.set(1, bn.getValue()); *************** *** 132,137 **** assertEquals(2, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! ! Occurrence o = (Occurrence) ((Topic) m_tm.getObjectById("bond")).getOccurrences().iterator().next(); assertNotNull(o.getValue()); params.set(0, o); --- 152,157 ---- assertEquals(2, out.getColumns().size()); assertEquals(0, out.getRows().size()); ! ! Occurrence o = (Occurrence) ((Topic) getObjectById("bond")).getOccurrences().iterator().next(); assertNotNull(o.getValue()); params.set(0, o); *************** *** 147,153 **** assertNotNull(out); assertEquals(2, out.getColumns().size()); ! assertEquals(0, out.getRows().size()); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); --- 167,173 ---- assertNotNull(out); assertEquals(2, out.getColumns().size()); ! assertEquals(0, out.getRows().size()); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 168,193 **** if (o instanceof TopicName) { assertEquals(v, ((TopicName)o).getValue()); ! } else if (o instanceof DataObject) { ! assertEquals(v, ((DataObject)o).getValue()); } } ! } } - - /* - * $Log$ - * Revision 1.2 2005/03/06 19:37:40 lheuer - * Changed getTopicByID to getObjectById - * - * Revision 1.1 2005/03/06 17:33:23 lheuer - * Initial tolog import - * - * Revision 1.2 2004/06/14 20:09:46 kal_ahmed - * Updated test code to work with new Predicate interface. - * - * Revision 1.1 2004/06/13 09:06:43 kal_ahmed - * Initial version of value() predicate. - * - */ \ No newline at end of file --- 188,197 ---- if (o instanceof TopicName) { assertEquals(v, ((TopicName)o).getValue()); ! } else if (o instanceof Variant) { ! assertEquals(v, ((Variant)o).getValue()); } } ! } } Index: TopicNameTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/TopicNameTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TopicNameTest.java 7 Mar 2005 16:34:51 -0000 1.3 --- TopicNameTest.java 8 Mar 2005 12:33:58 -0000 1.4 *************** *** 1,6 **** /* ! * Created on 14-Jun-2004 ! * @author Kal */ package org.tmapiutils.query.tolog.predicates.test; --- 1,19 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the License at ! * ! * http://www.apache.org/licenses/LICENSE-2.0 ! * ! * Unless required by applicable law or agreed to in writing, software ! * distributed under the License is distributed on an "AS IS" BASIS, ! * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ! * See the License for the specific language governing permissions and ! * limitations under the License. */ + package org.tmapiutils.query.tolog.predicates.test; *************** *** 17,23 **** /** ! * @author Kal ! * ! * Describe TopicNameTest here. */ public class TopicNameTest extends PredicateTestBase { --- 30,36 ---- /** ! * ! * @author Kal Ahmed (kal[at]techquila.com) ! * @author Lars Heuer (heuer[at]semagia.com) */ public class TopicNameTest extends PredicateTestBase { *************** *** 49,53 **** Topic topic3 = tm.createTopic(); topic3.createTopicName("Topic3", null); ! // Should be the display name. // Todo: Test if this breaks something topic3.createTopicName("topic3", null); --- 62,66 ---- Topic topic3 = tm.createTopic(); topic3.createTopicName("Topic3", null); ! // Should be the display name. // Todo: Test if this breaks something topic3.createTopicName("topic3", null); *************** *** 71,75 **** Topic topic1 = (Topic) getObjectById("topic1"); TopicName bn = (TopicName) topic1.getTopicNames().iterator().next(); ! ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 84,88 ---- Topic topic1 = (Topic) getObjectById("topic1"); TopicName bn = (TopicName) topic1.getTopicNames().iterator().next(); ! ArrayList params = new ArrayList(); Variable a = new Variable("A"); *************** *** 78,82 **** params.add(b); m_predicate.setParameters(params); ! params.set(1, bn); VariableSet out = m_predicate.matches(params, new TologContext()); --- 91,95 ---- params.add(b); m_predicate.setParameters(params); ! params.set(1, bn); VariableSet out = m_predicate.matches(params, new TologContext()); *************** *** 85,89 **** assertEquals(topic1, out.getRow(0).get(0)); } ! public void testMatchOnTopic() throws Exception { Topic topic3 = (Topic) getObjectById("topic3"); --- 98,102 ---- assertEquals(topic1, out.getRow(0).get(0)); } ! public void testMatchOnTopic() throws Exception { Topic topic3 = (Topic) getObjectById("topic3"); *************** *** 94,98 **** params.add(b); m_predicate.setParameters(params); ! params.set(0, topic3); VariableSet out = m_predicate.matches(params, new TologContext()); --- 107,111 ---- params.add(b); m_predicate.setParameters(params); ! params.set(0, topic3); VariableSet out = m_predicate.matches(params, new TologContext()); *************** *** 105,109 **** assertTrue(data.equals("Topic3") || data.equals("Topic Three")); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); --- 118,122 ---- assertTrue(data.equals("Topic3") || data.equals("Topic Three")); } ! public void testOpenMatch() throws Exception { ArrayList params = new ArrayList(); *************** *** 113,117 **** params.add(b); m_predicate.setParameters(params); ! VariableSet out = m_predicate.matches(params, new TologContext()); assertNotNull(out); --- 126,130 ---- params.add(b); m_predicate.setParameters(params); ! VariableSet out = m_predicate.matches(params, new TologContext()); assertNotNull(out); *************** *** 119,128 **** assertFalse(out.getColumn(a).contains(getObjectById("topic4"))); } ! public void testClosedMatch() throws Exception { Topic topic1 = (Topic) getObjectById("topic1"); TopicName bn1 = (TopicName) topic1.getTopicNames().iterator().next(); Topic topic2 = (Topic) getObjectById("topic2"); ! ArrayList params = new ArrayList(); Variable a = new Variable("A"); --- 132,141 ---- assertFalse(out.getColumn(a).contains(getObjectById("topic4"))); } ! public void testClosedMatch() throws Exception { Topic topic1 = (Topic) getObjectById("topic1"); TopicName bn1 = (TopicName) topic1.getTopicNames().iterator().next(); Topic topic2 = (Topic) getObjectById("topic2"); ! ArrayList params = new ArrayList(); Variable a = new Variable("A"); *************** *** 131,135 **** params.add(b); m_predicate.setParameters(params); ! params.set(0, topic1); params.set(1, bn1); --- 144,148 ---- params.add(b); m_predicate.setParameters(params); ! params.set(0, topic1); params.set(1, bn1); *************** *** 137,141 **** assertNotNull(out); assertEquals(1, out.getRows().size()); ! params.set(0, topic2); out = m_predicate.matches(params, new TologContext()); --- 150,154 ---- assertNotNull(out); assertEquals(1, out.getRows().size()); ! params.set(0, topic2); out = m_predicate.matches(params, new TologContext()); *************** *** 144,145 **** --- 157,159 ---- } } + Index: TypePredicateTest.java =================================================================== RCS file: /cvsroot/tmapi-utils/tmapi-utils/src/org/tmapiutils/query/tolog/predicates/test/TypePredicateTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TypePredicateTest.java 7 Mar 2005 13:05:41 -0000 1.4 --- TypePredicateTest.java 8 Mar 2005 12:33:58 -0000 1.5 *************** *** 1,10 **** /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! The license for this source code can be found in the file ! LICENSE.TXT with this distribution or at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ */ --- 1,17 ---- /* ! * Copyright 2005 TMAPI Utils / Kal Ahmed, Lars Heuer ! * Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! * ! * Licensed under the Apache License, Version 2.0 (the "License"); ! * you may not use this file except in compliance with the License. ! * You may obtain a copy of the L... [truncated message content] |