List of usage examples for org.apache.commons.io FileUtils toFile
public static File toFile(URL url)
URL
to a File
. From source file:org.sonar.colorizer.UserGuideTest.java
private FileReader readFile(String path) throws FileNotFoundException { return new FileReader(FileUtils.toFile(getClass().getResource(path))); }
From source file:org.sonar.core.platform.PluginExploderTest.java
private File getFile(String filename) { return FileUtils.toFile(getClass().getResource("/org/sonar/core/plugins/" + filename)); }
From source file:org.sonar.core.platform.PluginInfoTest.java
@Test public void create_from_file() { File checkstyleJar = FileUtils .toFile(getClass().getResource("/org/sonar/core/platform/sonar-checkstyle-plugin-2.8.jar")); PluginInfo checkstyleInfo = PluginInfo.create(checkstyleJar); assertThat(checkstyleInfo.getName()).isEqualTo("Checkstyle"); assertThat(checkstyleInfo.getMinimalSqVersion()).isEqualTo(Version.create("2.8")); }
From source file:org.sonar.core.platform.PluginJarExploderTest.java
private File getFile(String filename) { return FileUtils.toFile(getClass().getResource("/org/sonar/core/platform/" + filename)); }
From source file:org.sonar.core.platform.PluginLoaderTest.java
@Test public void load_and_unload_plugins() { File checkstyleJar = FileUtils .toFile(getClass().getResource("/org/sonar/core/plugins/sonar-checkstyle-plugin-2.8.jar")); PluginInfo checkstyleInfo = PluginInfo.create(checkstyleJar); PluginLoader loader = new PluginLoader(new TempPluginExploder()); Map<String, Plugin> instances = loader.load(ImmutableMap.of("checkstyle", checkstyleInfo)); assertThat(instances).containsOnlyKeys("checkstyle"); Plugin checkstyleInstance = instances.get("checkstyle"); assertThat(checkstyleInstance.getClass().getName()) .isEqualTo("org.sonar.plugins.checkstyle.CheckstylePlugin"); loader.unload(instances.values());/* w ww . j a v a2s . com*/ // TODO test that classloaders are closed. Two strategies: // }
From source file:org.sonar.core.plugins.PluginInstallerTest.java
static File getFile(String filename) { return FileUtils.toFile(PluginInstallerTest.class.getResource("/org/sonar/core/plugins/" + filename)); }
From source file:org.sonar.core.plugins.PluginJarInstallerTest.java
File getFileFromCache(String filename) throws IOException { File src = FileUtils .toFile(PluginJarInstallerTest.class.getResource("/org/sonar/core/plugins/" + filename)); File destFile = new File(new File(userHome, "" + filename.hashCode()), filename); FileUtils.copyFile(src, destFile);/*from w w w . j a v a 2 s. c om*/ return destFile; }
From source file:org.sonar.plugins.android.lint.AndroidLintProfileExporterTest.java
protected void assertXmlAreSimilar(String actualContent, String expectedFileName) throws SAXException, IOException { File expectedContent = FileUtils.toFile(getClass().getResource("/" + expectedFileName)); assertSimilarXml(expectedContent, actualContent); }
From source file:org.sonar.plugins.csharp.checks.CheckUtils.java
public static Set<CheckMessage> extractViolations(String cFilePath, CSharpAstVisitor... visitors) { SourceProject project = new SourceProject("C# Project"); SquidIndex index = new SquidIndex(); index.index(project);// www. j a v a 2 s. c o m CSharpAstScanner scanner = new CSharpAstScanner(project, new CSharpConfiguration()); registerDefaultVisitors(scanner); registerVisitors(scanner, visitors); File cFileToTest = FileUtils.toFile(CheckUtils.class.getResource(cFilePath)); if (cFileToTest == null || !cFileToTest.exists()) { throw new AssertionError("The C# file to test '" + cFilePath + "' doesn't exist."); } scanner.scanFile(cFileToTest); SourceCodeTreeDecorator decorator = new SourceCodeTreeDecorator(project); decorator.decorateWith(CSharpMetric.values()); Collection<SourceCode> sources = index.search(new QueryByType(SourceFile.class)); if (sources.size() != 1) { throw new AssertionError( "Only one SourceFile was expected whereas " + sources.size() + " has been returned."); } else { SourceFile file = (SourceFile) sources.iterator().next(); return file.getCheckMessages(); } }
From source file:org.sonar.plugins.flex.flexmetrics.FlexMetricsParserTest.java
@Before public void setUp() { context = mock(SensorContext.class); xmlFile = FileUtils .toFile(getClass().getResource("/org/sonar/plugins/flex/flexmetrics/javancss-raw-report.xml")); parser = new FlexMetricsParser(context); }