JTMTopicMapReader extends AbstractTopicMapReader { @Override protected TopicMapIF read(TopicMapStoreFactoryIF store_factory) throws IOException { TopicMapStoreIF store = store_factory.createStore(); TopicMapIF topicmap = store.getTopicMap(); if ((store instanceof AbstractTopicMapStore) && store.getBaseAddress() == null) ((AbstractTopicMapStore) store).setBaseAddress(getBaseAddress()); try (Reader reader = makeReader((String) null, new JTMEncodingSniffer())) { JTMStreamingParser parser = new JTMStreamingParser(topicmap); parser.parse(reader); } catch (JTMException e) { throw new IOException("Could not deserialize JTM fragment: " + e.getMessage()); } ClassInstanceUtils.resolveAssociations2(topicmap); return topicmap; } JTMTopicMapReader(URL url);  JTMTopicMapReader(Reader reader, LocatorIF base_address);  JTMTopicMapReader(InputStream stream, LocatorIF base_address);  JTMTopicMapReader(File file);   }
@Test public void testReadFromURL() throws IOException { TopicMapIF tm = new JTMTopicMapReader(TestFileUtils.getTestInputURL("jtm", "in", "topic.xtm2.jtm")).read(); Assert.assertNotNull(tm); Assert.assertEquals(1, tm.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 testReadFromInputStream() throws IOException { TopicMapIF tm = new JTMTopicMapReader(new FileInputStream(file), locator).read(); Assert.assertNotNull(tm); Assert.assertEquals(1, tm.getTopics().size()); }
@Test public void testReadFromReader() throws IOException { TopicMapIF tm = new JTMTopicMapReader(new FileReader(file), locator).read(); Assert.assertNotNull(tm); Assert.assertEquals(1, tm.getTopics().size()); }