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(); para... [truncated message content] |