public void testDuplicateSubject() { try { URILocator loc = new URILocator("http://www.ontopia.net"); topic.addSubjectLocator(loc); TopicIF topic2 = builder.makeTopic(); try { topic2.addSubjectLocator(loc); fail("duplicate subject allowed"); } catch (ConstraintViolationException e) { } } catch (MalformedURLException e) { fail("(INTERNAL) URL malformed"); } catch (ConstraintViolationException e) { fail("constraint violated for no good reason"); } }
public void testSubjectIndicatorUnassignable() { TopicIF topic = builder.makeTopic(); topic.remove(); try { URILocator loc = new URILocator("http://www.ontopia.net"); topic.addSubjectIdentifier(loc); fail("subject indicator assigned when not attached to topic map"); } catch (MalformedURLException e) { fail("(INTERNAL) URL malformed"); } catch (ConstraintViolationException e) { } }
public void testSubjectIndicatorDuplicate() { TopicIF t1 = builder.makeTopic(); TopicIF t2 = builder.makeTopic(); try { URILocator loc = new URILocator("http://www.ontopia.net"); t1.addSubjectIdentifier(loc); try { t2.addSubjectIdentifier(loc); fail("accepted two subject indicators being set to the same URI"); } catch (ConstraintViolationException e) { } } catch (MalformedURLException e) { fail("(INTERNAL) URL malformed"); } catch (ConstraintViolationException e) { fail("constraint violated for no good reason"); } }
public void testSubjectUnassignable() { TopicIF topic = builder.makeTopic(); topic.remove(); try { URILocator loc = new URILocator("http://www.ontopia.net"); topic.addSubjectLocator(loc); fail("subject assigned when not attached to topic map"); } catch (MalformedURLException e) { fail("(INTERNAL) URL malformed"); } catch (ConstraintViolationException e) { } }
public void testSourceLocatorTopicSubjectIndicator2() { // this is forbidden, according to the TMDM try { URILocator loc = new URILocator("http://www.ontopia.net"); topic.addItemIdentifier(loc); TopicIF topic2 = builder.makeTopic(); topic2.addSubjectIdentifier(loc); fail("item identifier of one topic allowed to be subject identifier " + "of another"); } catch (MalformedURLException e) { fail("(INTERNAL) bad URL given" + e); } catch (ConstraintViolationException e) { } }
@Override public void testSourceLocatorTopicSubjectIndicator() { // this is forbidden, according to the TMDM try { URILocator loc = new URILocator("http://www.ontopia.net"); TopicIF topic2 = builder.makeTopic(); topic2.addSubjectIdentifier(loc); topic.addItemIdentifier(loc); fail("subject identifier of one topic allowed to be item identifier " + "of another"); } catch (MalformedURLException e) { fail("(INTERNAL) bad URL given" + e); } catch (ConstraintViolationException e) { } }
@Override public void testTopicSubjectIndicatorSourceLocator() { // this is overridden from AbstractTMObject, because in this case // the collision is not allowed, but for all other TMObjectIFs it // is allowed (to provide reification) try { URILocator loc = new URILocator("http://www.ontopia.net"); TopicIF topic = builder.makeTopic(); object.addItemIdentifier(loc); topic.addSubjectIdentifier(loc); fail("allowed subject indicator of one topic to be source locator of another"); } catch (MalformedURLException e) { fail("(INTERNAL) bad URL given" + e); } catch (ConstraintViolationException e) { } }
public void testBug652c() { try { TopicIF t1 = builder.makeTopic(); URILocator loc = new URILocator("http://www.ontopia.net/B"); t1.addSubjectIdentifier(loc); TopicIF t2 = builder.makeTopic(); t2.addItemIdentifier(loc); fail("subject identifier of one topic allowed to be item identifier of " + "another"); } catch (MalformedURLException e) { fail("(INTERNAL) bad URL given" + e); } catch (UniquenessViolationException e) { // this is the expected outcome } }
public void testSubject() { assertTrue("subject not null initially", topic.getSubjectLocators().isEmpty()); try { URILocator loc = new URILocator("http://www.ontopia.net/"); topic.addSubjectLocator(loc); assertTrue("subject not set properly", topic.getSubjectLocators().contains(loc)); topic.removeSubjectLocator(loc); assertTrue("couldn't set subject to null", topic.getSubjectLocators().isEmpty()); } catch (MalformedURLException e) { fail("(INTERNAL) URL malformed"); } catch (ConstraintViolationException e) { fail("constraint violated for no good reason"); } }
public void testRoles() { // STATE 1 assertTrue("role set not empty initially", topic.getRoles().size() == 0); // STATE 2 AssociationIF assoc = builder.makeAssociation(builder.makeTopic()); AssociationRoleIF role = builder.makeAssociationRole(assoc, builder.makeTopic(), topic); assertTrue("role not added", topic.getRoles().size() == 1); assertTrue("role identity not retained", topic.getRoles().iterator().next().equals(role)); role.setPlayer(topic); assertTrue("duplicate not rejected", topic.getRoles().size() == 1); try { role.setPlayer(null); fail("player could be set to null"); } catch (NullPointerException e) { } assertTrue("player not retained", role.getPlayer().equals(topic)); }
public void testBug652a() { try { TopicIF topic = builder.makeTopic(); URILocator loc = new URILocator("http://www.ontopia.net/A"); topic.addItemIdentifier(loc); topic.addSubjectIdentifier(loc); topic.removeSubjectIdentifier(loc); topic.removeItemIdentifier(loc); topic.remove(); } catch (MalformedURLException e) { fail("(INTERNAL) bad URL given" + e); } }
public void testBug652b() { try { TopicIF topic = builder.makeTopic(); URILocator loc = new URILocator("http://www.ontopia.net/B"); topic.addSubjectIdentifier(loc); topic.addItemIdentifier(loc); topic.removeItemIdentifier(loc); topic.removeSubjectIdentifier(loc); topic.remove(); } catch (MalformedURLException e) { fail("(INTERNAL) bad URL given" + e); } }