private void generateCssFromLess() { try { LessCompiler compiler = new LessCompiler(); String less = Resources.toString(getClass().getResource("/spoon.less"), UTF_8); String css = compiler.compile(less); File cssFile = FileUtils.getFile(output, STATIC_DIRECTORY, "spoon.css"); FileUtils.writeStringToFile(cssFile, css, UTF_8); } catch (Exception e) { throw new RuntimeException(e); } }
this.singleInstrumentationCall = singleInstrumentationCall; serial = SpoonUtils.sanitizeSerial(serial); this.work = FileUtils.getFile(output, TEMP_DIR, serial); this.junitReport = FileUtils.getFile(output, JUNIT_DIR, serial + ".xml"); this.imageDir = FileUtils.getFile(output, IMAGE_DIR, serial); this.fileDir = FileUtils.getFile(output, FILE_DIR, serial); this.coverageDir = FileUtils.getFile(output, COVERAGE_DIR, serial); this.testRunListeners = testRunListeners; this.grantAll = grantAll;
private void saveRawLog() { for (Map.Entry<String, DeviceResult> resultEntry : summary.getResults().entrySet()) { String serial = resultEntry.getKey(); DeviceResult result = resultEntry.getValue(); for (Map.Entry<DeviceTest, DeviceTestResult> entry : result.getTestResults().entrySet()) { DeviceTest test = entry.getKey(); File rawFile = FileUtils.getFile(output, "logs", serial, test.getClassName(), test.getMethodName() + ".log"); saveRawLogFile(rawFile, entry.getValue()); } } }
private void generateDeviceHtml(MustacheFactory mustacheFactory) { Mustache mustache = mustacheFactory.compile("page/device.html"); for (Map.Entry<String, DeviceResult> entry : summary.getResults().entrySet()) { String serial = entry.getKey(); HtmlDevice scope = HtmlDevice.from(serial, entry.getValue(), output); File file = FileUtils.getFile(output, "device", serial + ".html"); renderMustacheToFile(mustache, scope, file); } }
/** Get an {@link com.android.ddmlib.AndroidDebugBridge} instance given an SDK path. */ public static AndroidDebugBridge initAdb(File sdk, Duration timeOut) { AndroidDebugBridge.initIfNeeded(false); File adbPath = FileUtils.getFile(sdk, "platform-tools", "adb"); AndroidDebugBridge adb = AndroidDebugBridge.createBridge(adbPath.getAbsolutePath(), false); waitForAdb(adb, timeOut); return adb; }
@Test public void testGetFile() { final File expected_A = new File("src"); final File expected_B = new File(expected_A, "main"); final File expected_C = new File(expected_B, "java"); assertEquals("A", expected_A, FileUtils.getFile("src")); assertEquals("B", expected_B, FileUtils.getFile("src", "main")); assertEquals("C", expected_C, FileUtils.getFile("src", "main", "java")); try { FileUtils.getFile((String[]) null); fail("Expected NullPointerException"); } catch (final NullPointerException e) { // expected } }
@Test public void testGetFile_Parent() { final File parent = new File("parent"); final File expected_A = new File(parent, "src"); final File expected_B = new File(expected_A, "main"); final File expected_C = new File(expected_B, "java"); assertEquals("A", expected_A, FileUtils.getFile(parent, "src")); assertEquals("B", expected_B, FileUtils.getFile(parent, "src", "main")); assertEquals("C", expected_C, FileUtils.getFile(parent, "src", "main", "java")); try { FileUtils.getFile(parent, (String[]) null); fail("Expected NullPointerException"); } catch (final NullPointerException e) { // expected } try { FileUtils.getFile((File) null, "src"); fail("Expected NullPointerException"); } catch (final NullPointerException e) { // expected } }
private void generateTestHtml(MustacheFactory mustacheFactory) { Mustache mustache = mustacheFactory.compile("page/test.html"); // Create a set of unique tests. Set<DeviceTest> tests = new LinkedHashSet<>(); for (DeviceResult deviceResult : summary.getResults().values()) { tests.addAll(deviceResult.getTestResults().keySet()); } // Generate a page for each one. for (DeviceTest test : tests) { HtmlTest scope = HtmlTest.from(test, summary, output); File file = FileUtils.getFile(output, "test", test.getClassName(), test.getMethodName() + ".html"); renderMustacheToFile(mustache, scope, file); } }
private void generateLogHtml(MustacheFactory mustacheFactory) { Mustache mustache = mustacheFactory.compile("page/log.html"); for (Map.Entry<String, DeviceResult> resultEntry : summary.getResults().entrySet()) { String serial = resultEntry.getKey(); DeviceResult result = resultEntry.getValue(); DeviceDetails details = result.getDeviceDetails(); String name = (details != null) ? details.getName() : serial; for (Map.Entry<DeviceTest, DeviceTestResult> entry : result.getTestResults().entrySet()) { DeviceTest test = entry.getKey(); HtmlLog scope = HtmlLog.from(name, test, entry.getValue()); File file = FileUtils.getFile(output, "logs", serial, test.getClassName(), test.getMethodName() + ".html"); renderMustacheToFile(mustache, scope, file); } } }
continue; // Do not make an animated GIF if there is only one screenshot. File animatedGif = FileUtils.getFile(imageDir, deviceTest.getClassName(), deviceTest.getMethodName() + ".gif"); createAnimatedGif(screenshots, animatedGif);
protected String wrapPath(String path) { // Ensure the `path` exists try { FileUtils.forceMkdir(FileUtils.getFile(path)); } catch (IOException e) { throw new BackendException(e.getMessage(), e); } // Join with store type return Paths.get(path, this.store).toString(); }
public static void clearDir(String tempDir) { File file = FileUtils.getFile(tempDir); if (!file.exists()) { return; } try { FileUtils.forceDelete(file); } catch (IOException e) { throw new BackendException(e); } }
@AfterClass public static void clear() throws IOException { /* * The FileUtils.forceDelete() can only accept a `File` * in `org.apache.commons.io` version 2.4 */ FileUtils.forceDelete(FileUtils.getFile(DB_PATH)); }
public static List<PaloFile> scan(String path, List<String> tableDirs) { File directory = FileUtils.getFile(path); if (!directory.exists()) { return ImmutableList.of(); } File[] subDirs = directory.listFiles((dir, name) -> { return tableDirs.contains(name); }); if (subDirs == null || subDirs.length == 0) { return ImmutableList.of(); } List<PaloFile> paloFiles = new ArrayList<>(subDirs.length); for (File subDir : subDirs) { String[] fileNames = subDir.list(); if (fileNames == null) { continue; } for (String fileName : fileNames) { paloFiles.add(new PaloFile(path, subDir.getName(), fileName)); } } /* * Sort palo file by updated time in asc order, * let old files to be processed in priority */ paloFiles.sort((file1, file2) -> { return (int) (file1.lastModified() - file2.lastModified()); }); return paloFiles; }
public static boolean isInScope(String scopeLocation, String fileFullPath) throws IOException { if (FileUtils.getFile(fileFullPath).getCanonicalPath().startsWith(scopeLocation)) { return true; } return false; }
public String readFile(String fileNameWithPath) { try { return FileUtils.readFileToString(FileUtils.getFile(fileNameWithPath)); } catch (IOException ex) { _logger.error("Exception,", ex); return null; } } }
protected String wrapPath(String path) { // Ensure the `path` exists try { FileUtils.forceMkdir(FileUtils.getFile(path)); } catch (IOException e) { throw new BackendException(e.getMessage(), e); } // Join with store type return Paths.get(path, this.store).toString(); }
private void writeFileToDisk(String writeOnDir, MetricsCsv metricsCsv) throws IOException { File targetFile = FileUtils.getFile(FileUtils.getFile(writeOnDir).getCanonicalPath() + File.separator + metricsCsv.getFileName()); _logger.debug("FileName:{}", targetFile.getCanonicalPath()); FileUtils.getFile(targetFile.getParentFile()).mkdirs(); FileUtils.writeStringToFile(targetFile, metricsCsv.getData()); metricsCsv.setFileName(targetFile.getCanonicalPath()); }
public static List<String> getQualifiers(File baseDirectory, ProjectIdentifier project, List<String> includes, List<String> excludes) { String resourcePath = ProjectUtils.getResourcePath(project.getGroupId(), project.getArtifactId()); File resourceDirectory = FileUtils.getFile(baseDirectory, resourcePath); return getQualifiers(resourceDirectory, includes, excludes); }
public static List<String> getQualifiers(File baseDirectory, Project project, List<String> includes, List<String> excludes) { String resourcePath = ProjectUtils.getResourcePath(project.getGroupId(), project.getArtifactId()); File resourceDirectory = FileUtils.getFile(baseDirectory, resourcePath); return getQualifiers(resourceDirectory, includes, excludes); }