RDBMSTopicMapReference extends AbstractTopicMapReference { public void setBaseAddress(LocatorIF base_address) { this.base_address = base_address; TopicMapStoreIF store = null; try { store = createStore(false); TopicMap topicmap = (TopicMap) store.getTopicMap(); topicmap.setBaseAddress(base_address); store.commit(); } finally { if (store != null) { store.close(); } } } RDBMSTopicMapReference(String _id, String _title, StorageIF _storage,
      long _topicmap_id, LocatorIF _base_address); @Override synchronized void open(); @Override synchronized TopicMapStoreIF createStore(boolean readonly); @Override void setTitle(String title); LocatorIF getBaseAddress(); void setBaseAddress(LocatorIF base_address); @Override synchronized void close(); @Override synchronized void clear(); @Override synchronized void delete(); @Override String toString(); long getTopicMapId(); @Override synchronized void storeClosed(TopicMapStoreIF store); void writeReport(java.io.Writer out, boolean dumpCaches); static final String EXHAUSED_BLOCK; static final String EXHAUSED_GROW; static final String EXHAUSED_FAIL; }
@Test public void testSetBaseAddress() throws Exception { final LocatorIF NEW_BASE_ADDRESS = URILocator.create("foo:bar-" + System.currentTimeMillis()); RDBMSTestFactory factory = new RDBMSTestFactory(); RDBMSTopicMapReference before = (RDBMSTopicMapReference) factory.makeTopicMapReference(); Assert.assertNotSame("Test reference already has base address '" + NEW_BASE_ADDRESS.getAddress() + "', cannot test for change", NEW_BASE_ADDRESS, before.getBaseAddress()); before.setBaseAddress(NEW_BASE_ADDRESS); String referenceId = before.getId(); factory = new RDBMSTestFactory(); RDBMSTopicMapReference after = null; for (TopicMapReferenceIF i : factory.getSource().getReferences()) { if (referenceId.equals(i.getId())) { after = (RDBMSTopicMapReference) i; } } Assert.assertNotNull("Reference with id '" + referenceId + "' not found", after); Assert.assertEquals("Reference base address not changed correctly", NEW_BASE_ADDRESS, after.getBaseAddress()); }