MergeConfigurationCLI { public static MergeToolConfiguration createConfigurationFromFile(final File configFile) throws MergeConfigurationException { try { final JAXBContext context = JAXBContext.newInstance(DBType.class, MergeToolConfiguration.class, AccumuloMergeToolConfiguration.class, TimestampMergePolicyConfiguration.class, MergePolicy.class, InstanceType.class); final Unmarshaller unmarshaller = context.createUnmarshaller(); final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); XmlFactoryConfiguration.harden(dbf); final DocumentBuilder db = dbf.newDocumentBuilder(); return unmarshaller.unmarshal(db.parse(configFile), MergeToolConfiguration.class).getValue(); } catch (final JAXBException | IllegalArgumentException | ParserConfigurationException | SAXException | IOException JAXBe) { throw new MergeConfigurationException("Failed to create a config based on the provided configuration.", JAXBe); } } MergeConfigurationCLI(final String[] args); @VisibleForTesting static Options getOptions(); static MergeToolConfiguration createConfigurationFromFile(final File configFile); Date getRyaStatementMergeTime(); MergeConfiguration createConfiguration(); static final DateFormat DATE_FORMAT; }
@Test public void testCreate1ConfigurationFromFile() throws MergeConfigurationException, JAXBException { final MergeToolConfiguration conf = MergeConfigurationCLI.createConfigurationFromFile(new File("conf/config.xml")); assertEquals("10.10.10.100", conf.getParentHostname()); assertEquals("accumuloUsername", conf.getParentUsername()); assertEquals("accumuloPassword", conf.getParentPassword()); assertEquals("accumuloInstance", conf.getParentRyaInstanceName()); assertEquals("rya_demo_export_", conf.getParentTablePrefix()); assertEquals("http: assertEquals(DBType.ACCUMULO, conf.getParentDBType()); assertEquals(1111, conf.getParentPort()); assertEquals("10.10.10.101", conf.getChildHostname()); assertEquals("rya_demo_child", conf.getChildRyaInstanceName()); assertEquals("rya_demo_export_", conf.getChildTablePrefix()); assertEquals("http: assertEquals(DBType.MONGO, conf.getChildDBType()); assertEquals(27017, conf.getChildPort()); assertEquals(MergePolicy.TIMESTAMP, conf.getMergePolicy()); assertEquals(Boolean.FALSE, conf.isUseNtpServer()); assertEquals(null, conf.getNtpServerHost()); }