org.junitpioneer.jupiter.TempDirectory Java Examples

The following examples show how to use org.junitpioneer.jupiter.TempDirectory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SignatureScanTest.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
@Test
@ExtendWith(TempDirectory.class)
public void testOfflineScanWithSnippetMatching(@TempDirectory.TempDir final Path tempOutputDirectory) throws Exception {
    final String projectName = "synopsys-detect-junit";
    final String projectVersionName = "offline-scan";
    assertProjectVersionReady(projectName, projectVersionName);

    final List<String> detectArgs = getInitialArgs(projectName, projectVersionName);
    detectArgs.add("--detect.output.path=" + tempOutputDirectory.toString());
    detectArgs.add("--detect.blackduck.signature.scanner.snippet.matching=SNIPPET_MATCHING");
    detectArgs.add("--detect.blackduck.signature.scanner.dry.run=true");
    Application.main(detectArgs.toArray(new String[0]));

    assertDirectoryStructureForOfflineScan(tempOutputDirectory);
}
 
Example #2
Source File: SignatureScanTest.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
private void assertDirectoryStructureForOfflineScan(@TempDirectory.TempDir final Path tempOutputDirectory) {
    final Path runsPath = tempOutputDirectory.resolve("runs");
    assertTrue(runsPath.toFile().exists());
    assertTrue(runsPath.toFile().isDirectory());

    final File[] runDirectories = runsPath.toFile().listFiles();

    assertNotNull(runDirectories);
    assertEquals(1, runDirectories.length);

    final File runDirectory = runDirectories[0];
    assertTrue(runDirectory.exists());
    assertTrue(runDirectory.isDirectory());

    final File scanDirectory = new File(runDirectory, "scan");
    assertTrue(scanDirectory.exists());
    assertTrue(scanDirectory.isDirectory());

    final File blackDuckScanOutput = new File(scanDirectory, "BlackDuckScanOutput");
    assertTrue(blackDuckScanOutput.exists());
    assertTrue(blackDuckScanOutput.isDirectory());

    final File[] outputDirectories = blackDuckScanOutput.listFiles();
    assertNotNull(outputDirectories);
    assertEquals(1, outputDirectories.length);

    final File outputDirectory = outputDirectories[0];
    assertTrue(outputDirectory.exists());
    assertTrue(outputDirectory.isDirectory());

    final File dataDirectory = new File(outputDirectory, "data");
    assertTrue(dataDirectory.exists());
    assertTrue(dataDirectory.isDirectory());

    final File[] dataFiles = dataDirectory.listFiles();
    assertNotNull(dataFiles);
    assertEquals(1, dataFiles.length);
    assertTrue(dataFiles[0].length() > HALF_MILLION_BYTES);
}
 
Example #3
Source File: PioneerTest.java    From demo-junit-5 with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Test
@ExtendWith(TempDirectory.class)
void testTempDirInjection(@TempDir Path tempDir, TestReporter reporter) {
	assertNotNull(tempDir);
	reporter.publishEntry("Temporary directory", tempDir.toString());
}