private ContextHolder createContext(TopicMapIF topicmap) { HashMap<TopicIF, String> topicIds = new HashMap<TopicIF, String>(); ContextHolder context = new ContextHolder(topicIds); Iterator<TopicIF> it = context.topicsInOrder(topicmap.getTopics()); int counter = 1; while (it.hasNext()) topicIds.put(it.next(), "id" + Integer.toString(counter++)); return context; }
public void testCompletelyOpen() throws InvalidQueryException, IOException { load("family2.ltm"); List matches = new ArrayList(); Iterator it = topicmap.getTopics().iterator(); while (it.hasNext()) addMatch(matches, "TOPIC", it.next()); verifyQuery(matches, "topic($TOPIC)?"); closeStore(); }
public void testWildcard4() throws InvalidQueryException { makeEmpty(); update("insert ? . "); assertEquals("problem in topic creation", topicmap.getTopics().size(), 1); update("insert ? . "); // should create *another* topic assertEquals("wildcard topics merged across queries", topicmap.getTopics().size(), 2); }
public void testWildcard() throws InvalidQueryException, IOException { load("instance-of.ltm"); int topicsbefore = topicmap.getTopics().size(); update("insert $type isa ?newtype . from " + "$type = type1"); TopicIF topic = getTopicById("type1"); assertTrue("wrong number of topics after insert", topicmap.getTopics().size() == topicsbefore + 1); assertTrue("topic does not have new type after insert", !topic.getTypes().isEmpty()); }
public void testQName2() throws InvalidQueryException, IOException { load("subclasses.ltm"); int topics = topicmap.getTopics().size(); TopicIF subclass = getTopicById("subclass"); update("using xtm for i\"http://www.topicmaps.org/xtm/1.0/core.xtm#\" " + "delete $A from $A = xtm:subclass"); assertTrue("topic still attached to TM after delete", subclass.getTopicMap() == null); assertTrue("wrong number of topics after delete", topicmap.getTopics().size() == (topics - 1)); }
@Get public Collection<TopicIF> getTopics() { addMixInAnnotations(TopicIF.class, MFlatTopic.class); TopicIF type = Parameters.TYPE.optional(this); if (type != null) { return getIndex(ClassInstanceIndexIF.class).getTopics(type); } else { return getTopicMap().getTopics(); } }
@Test public void testReadFromInputStream() throws IOException { TopicMapIF tm = new CTMTopicMapReader(new FileInputStream(file), locator).read(); Assert.assertNotNull(tm); Assert.assertEquals(1, tm.getTopics().size()); }
public void testDeclarationContext() throws InvalidQueryException, IOException { load("subclasses.ltm"); int topics = topicmap.getTopics().size(); TopicIF subclass = getTopicById("subclass"); DeclarationContextIF context = parseContext("using xtm for i\"http://www.topicmaps.org/xtm/1.0/core.xtm#\""); update("delete xtm:subclass", context); assertTrue("topic still attached to TM after delete", subclass.getTopicMap() == null); assertTrue("wrong number of topics after delete", topicmap.getTopics().size() == (topics - 1)); }
public void testParam() throws InvalidQueryException, IOException { load("subclasses.ltm"); int topics = topicmap.getTopics().size(); TopicIF subclass = getTopicById("subclass"); Map params = makeArguments("topic", subclass); update("delete %topic%", params); assertTrue("topic still attached to TM after delete", subclass.getTopicMap() == null); assertTrue("wrong number of topics after delete", topicmap.getTopics().size() == (topics - 1)); }
@Test public void testReadFromURL() throws IOException { TopicMapIF tm = read("tmreify.ltm"); Assert.assertNotNull(tm); Assert.assertEquals(2, tm.getTopics().size()); }
public void testMergeSelf() throws IOException { TopicMapIF tm1 = ImportExportUtils.getReader(TestFileUtils.getTestInputFile("query", "jill.xtm")).read(); TopicMapIF tm2 = ImportExportUtils.getReader(TestFileUtils.getTestInputFile("query", "jill.xtm")).read(); MergeUtils.mergeInto(tm1, tm2); assertEquals(tm1.getTopics().size(), tm2.getTopics().size()); assertEquals(tm1.getAssociations().size(), tm2.getAssociations().size()); }
public void testProjectedDelete() throws InvalidQueryException, IOException { load("instance-of.ltm"); int before = topicmap.getTopics().size(); assertTrue("topic4 missing", getTopicById("topic4") != null); update("delete $A from $A = topic4, $B = topic3"); assertTrue("wrong number of topics after delete", topicmap.getTopics().size() == (before - 1)); assertTrue("topic4 still available after delete", getTopicById("topic4") == null); assertTrue("topic3 not still available after delete", getTopicById("topic3") != null); }
public void testTopicRemovalPolicyTypeUse() { //! System.out.println("TM: " + tm.getTopics()); //! System.out.println("--0"); TopicIF topic = builder.makeTopic(); TopicIF other = builder.makeTopic(); //! System.out.println("--1"); other.addType(topic); //! System.out.println("--2"); topic.remove(); assertEquals("To many topics after remove", 0, topicmap.getTopics().size()); }
@Test public void testReadFromFile() throws IOException { TopicMapIF tm = new JTMTopicMapReader(file).read(); Assert.assertNotNull(tm); Assert.assertEquals(1, tm.getTopics().size()); }
@Test public void testTopicName() throws IOException { TopicMapIF tm = readTopicMap("basename.xtm"); Assert.assertTrue("wrong number of topics after import", tm.getTopics().size() == 6); Assert.assertTrue("spurious topic map constructs found", tm.getAssociations() .size() == 0); TopicIF topic = getTopicById(tm, "country"); verifySingleTopicName(topic, "Country"); }
@Test public void testReadFromReader() throws IOException { TestFileUtils.transferTestInputDirectory("various"); File file = TestFileUtils.getTransferredTestInputFile("various", "jill.xtm"); TopicMapIF tm = new XTMTopicMapReader(new FileReader(file), new URILocator(file)).read(); Assert.assertNotNull(tm); Assert.assertEquals(39, tm.getTopics().size()); }
@Test public void testReadFromInputStream() throws IOException { TestFileUtils.transferTestInputDirectory("various"); File file = TestFileUtils.getTransferredTestInputFile("various", "jill.xtm"); TopicMapIF tm = new XTMTopicMapReader(new FileInputStream(file), new URILocator(file)).read(); Assert.assertNotNull(tm); Assert.assertEquals(39, tm.getTopics().size()); }
@Test public void testReadFromFile() throws IOException { File in = TestFileUtils.getTransferredTestInputFile(testdataDirectory, "extra", "tmreify.ltm"); TopicMapIF tm = new LTMTopicMapReader(in).read(); Assert.assertNotNull(tm); Assert.assertEquals(2, tm.getTopics().size()); }
@Test public void testReadFromURL() throws IOException { TopicMapIF tm = new TMXMLReader(TestFileUtils.getTestInputURL("tmxml", "in", "empty-topic.xml")).read(); Assert.assertNotNull(tm); Assert.assertEquals(2, tm.getTopics().size()); }
public void testTopicTypeDeletion() { TopicMapIF topicmap = makeTopicMap(); TopicMapBuilderIF builder = topicmap.getBuilder(); TopicIF morituri = builder.makeTopic(); TopicIF instance = builder.makeTopic(morituri); morituri.remove(); assertTrue("Topic still connected to topic map", morituri.getTopicMap() == null); assertTrue("Topic map not empty", topicmap.getTopics().size() == 0); }