/** * Registers a format for detection. */ public void registerFormat(IChemFormatMatcher format) { formatFactory.registerFormat(format); }
/** * Registers a format for detection. */ public void registerFormat(IChemFormatMatcher format) { formatFactory.registerFormat(format); }
private void expectFormat(String filename, IResourceFormat expectedFormat) throws Exception { InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); Assert.assertNotNull("Cannot find file: " + filename, ins); if (expectedFormat instanceof IChemFormatMatcher) { factory.registerFormat((IChemFormatMatcher) expectedFormat); } ins = new BufferedInputStream(ins); IChemFormat format = factory.guessFormat(ins); Assert.assertNotNull(format); Assert.assertEquals(expectedFormat.getFormatName(), format.getFormatName()); }
@Test public void testRegisterFormat() throws IOException { factory.registerFormat(new DummyFormat()); StringReader reader = new StringReader("DummyFormat:"); IChemFormat format = factory.guessFormat(reader); Assert.assertNotNull(format); Assert.assertTrue(format instanceof DummyFormat); } }