@Override public void run() { TopicNameIF bn = getTopicName(); bn.addItemIdentifier(URILocator.create("x:source-locator")); this.objectId = bn.getObjectId(); } });
public void testTopicNameItemIds() throws MalformedURLException { TopicIF topic = builder.makeTopic(); TopicNameIF bn = builder.makeTopicName(topic, "test"); bn.addItemIdentifier(new URILocator("http://psi.example.org")); TopicNameIF bn2 = builder.makeTopicName(topic, "test"); bn2.addItemIdentifier(new URILocator("http://psi.example.com")); DuplicateSuppressionUtils.removeDuplicates(topic); assertTrue("duplicate base names were not removed", topic.getTopicNames().size() == 1); bn = (TopicNameIF) topic.getTopicNames().iterator().next(); assertTrue("item IDs were not merged", bn.getItemIdentifiers().size() == 2); }
@Test public void testPreservesBasenameID() throws IOException { prepareTopicMap(); TopicIF topic = builder.makeTopic(); TopicNameIF bn = builder.makeTopicName(topic, "bongomonog"); bn.addItemIdentifier(sourceLoc); reload(); // get a topic with at least one name topic = null; for (Object obj : topicmap.getTopics()) { Collection<TopicNameIF> names = ((TopicIF) obj).getTopicNames(); if (names != null && names.size() > 0) { topic = (TopicIF) obj; break; } } Assert.assertNotNull("no topic found with a topic name after reload", topic); check("base name", (TopicNameIF) topic.getTopicNames().iterator().next()); }
public void testMergeDuplicateSourceLocator2() { // this test differs from the previous one in that the base names // are not equal, and so should not be merged try { TopicIF t1 = builder1.makeTopic(); t1.addItemIdentifier(new URILocator("http://www.example.com")); TopicNameIF bn1 = builder1.makeTopicName(t1, "boodoo"); bn1.addItemIdentifier(new URILocator("http://www.example.com/#1")); TopicIF t2 = builder2.makeTopic(); t2.addItemIdentifier(new URILocator("http://www.example.com")); TopicNameIF bn2 = builder2.makeTopicName(t2, "boovoo"); bn2.addItemIdentifier(new URILocator("http://www.example.com/#1")); MergeUtils.mergeInto(topicmap1, t2); fail("merge succeeded, even though duplicates did not match"); } catch (ConstraintViolationException e) { } catch (java.net.MalformedURLException e) { fail("URI literals malformed" + e.getMessage()); } }
public void testMergeDuplicateSourceLocator() { try { TopicIF t1 = builder1.makeTopic(); t1.addItemIdentifier(new URILocator("http://www.example.com")); TopicNameIF bn1 = builder1.makeTopicName(t1, "boodoo"); bn1.addItemIdentifier(new URILocator("http://www.example.com/#1")); TopicIF t2 = builder2.makeTopic(); t2.addItemIdentifier(new URILocator("http://www.example.com")); TopicNameIF bn2 = builder2.makeTopicName(t2, "boodoo"); bn2.addItemIdentifier(new URILocator("http://www.example.com/#1")); MergeUtils.mergeInto(topicmap1, t2); } catch (ConstraintViolationException e) { fail("merge of topics unaccountably failed" + e.getMessage()); } catch (java.net.MalformedURLException e) { fail("URI literals malformed" + e.getMessage()); } }
public void testMergeReifyingTopic() { try { TopicIF t1 = builder2.makeTopic(); TopicNameIF bn1 = builder2.makeTopicName(t1, "famous misspelling"); TopicIF t2 = builder2.makeTopic(); TopicNameIF bn2 = builder2.makeTopicName(t2, "boodoo"); bn2.addItemIdentifier(new URILocator("http://www.example.com/#1")); bn2.setReifier(t1); MergeUtils.mergeInto(topicmap1, t2); assertTrue("reifying topic was not included", topicmap1.getTopics().size() >= 2); TopicNameIF bn = (TopicNameIF) topicmap1.getObjectByItemIdentifier(new URILocator("http://www.example.com/#1")); TopicIF reifier = bn.getReifier(); assertTrue("reification link was broken", reifier != null); assertTrue("reifier base name not copied", !reifier.getTopicNames().isEmpty()); bn = (TopicNameIF) reifier.getTopicNames().iterator().next(); assertTrue("reifier base name not copied correctly", bn.getValue().equals("famous misspelling")); } catch (ConstraintViolationException e) { fail("merge of topics unaccountably failed" + e.getMessage()); } catch (MalformedURLException e) { fail("URI literals malformed" + e.getMessage()); } }
public void testTopicOtherObjectCollision() { TopicIF topic1 = builder1.makeTopic(); TopicNameIF bn = builder1.makeTopicName(topic1, ""); bn.addItemIdentifier(makeLocator("http://www.ontopia.com")); TopicIF topic2 = builder2.makeTopic(); topic2.addSubjectIdentifier(makeLocator("http://www.ontopia.net")); topic2.addSubjectLocator(makeLocator("http://www.example.com")); topic2.addItemIdentifier(makeLocator("http://www.ontopia.com")); try { MergeUtils.mergeInto(topicmap1, topic2); fail("collision not detected"); } catch (ConstraintViolationException e) { } }
tn.addItemIdentifier(tn_item_identifier);
bn.addItemIdentifier(URILocator.create("x:source-locator")); afterTest();