### Question:
FromJavaRadlExtractor implements RadlExtractor, Application { @Override public int run(Arguments arguments) { Timer timer = new Timer(); RunOptions options = getOptions(arguments); String configurationFileName = options.getConfigurationFileName(); String annotationProcessorOptions = null; Properties configuration = new Properties(); if (configurationFileName != null) { File configurationFile = new File(configurationFileName); if (configurationFile.exists()) { configuration = loadConfigurationFrom(configurationFile); annotationProcessorOptions = (String)configuration.remove("annotation.processor.options"); } else { Log.error("Configuration file not found: " + configurationFile); } } resourceModel.configure(configuration); Document radl = extractFrom(options.getServiceName(), options.getBaseDir(), new FromJavaExtractOptions( options.getExtraSource(), options.getClasspath(), options.getExtraProcessors(), options.getJavaVersion(), annotationProcessorOptions, options.isSerializeModel())); writeRadl(radl, options.getRadlFile(), options.getScm()); Log.info("-> RADL extraction took " + timer); return 0; } FromJavaRadlExtractor();  FromJavaRadlExtractor(ResourceModelMerger merger, ResourceModel resourceModel); static void main(String[] args); @Override int run(Arguments arguments); @Override Document extractFrom(String serviceName, File baseDir, ExtractOptions options);  }### Answer:
@Test public void appliesConfiguration() throws IOException { Properties properties = randomProperties(); File radlFile = TestUtil.randomFile(FromJavaRadlExtractorTest.class, ".radl"); File configurationFile = TestUtil.randomFile(FromJavaRadlExtractorTest.class, ".properties"); try (PrintWriter writer = new PrintWriter(configurationFile, "UTF8")) { properties.store(writer, ""); } radlExtractor.run(new Arguments(new String[] { "", dir.getPath(), radlFile.getAbsolutePath(), configurationFile.getAbsolutePath() })); verify(resourceModel).configure(eq(properties)); }
@Test public void appliesConfigurationFromArgumentsFile() throws IOException { Properties properties = randomProperties(); File radlFile = TestUtil.randomFile(FromJavaRadlExtractorTest.class, ".radl"); File configurationFile = TestUtil.randomFile(FromJavaRadlExtractorTest.class, ".properties"); try (PrintWriter writer = new PrintWriter(configurationFile, "UTF8")) { properties.store(writer, ""); } File argumentsFile = TestUtil.randomFile(FromJavaRadlExtractorTest.class, ".arguments"); try (PrintWriter writer = new PrintWriter(argumentsFile, "UTF8")) { writer.println("base.dir = " + encodePathForPropertiesFile(dir)); writer.println("radl.file = " + encodePathForPropertiesFile(radlFile)); writer.println("configuration.file = " + encodePathForPropertiesFile(configurationFile)); } try { radlExtractor.run(new Arguments(new String[] { '@' + argumentsFile.getAbsolutePath() })); } catch (IllegalArgumentException e) { assertEquals("Exception", "Compilation failed", e.getMessage()); } verify(resourceModel).configure(eq(properties)); }
@Test public void keepsManuallyAddedInformation() throws Exception { String oldServiceName = aName(); String newServiceName = aName(); File radlFile = TestUtil.randomFile(FromJavaRadlExtractorTest.class, ".radl"); try (PrintWriter writer = new PrintWriter(radlFile, "UTF8")) { writer.println(Xml.toString(simpleRadlDocument(oldServiceName))); } when(merger.toRadl(resourceModel)).thenReturn(simpleRadlDocument(newServiceName)); radlExtractor.run(new Arguments(new String[] { newServiceName, dir.getPath(), radlFile.getAbsolutePath() })); TestUtil.assertXmlEquals("RADL", simpleRadlDocument(newServiceName), Xml.parse(radlFile)); }