Search in sources :

Example 61 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project android_frameworks_base by ResurrectionRemix.

the class DiskStatsLoggingServiceTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    MockitoAnnotations.initMocks(this);
    mTemporaryFolder = new TemporaryFolder();
    mTemporaryFolder.create();
    mInputFile = mTemporaryFolder.newFile();
    mDownloads = new TemporaryFolder();
    mDownloads.create();
    mRootDirectory = new TemporaryFolder();
    mRootDirectory.create();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) Before(org.junit.Before)

Example 62 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project galley by Commonjava.

the class GalleyMavenFixture method initGalley.

public void initGalley() throws IOException {
    if (temp == null) {
        temp = new TemporaryFolder();
    }
    temp.create();
    if (cacheDir == null) {
        cacheDir = temp.newFolder("cache");
    }
    mavenBuilder = new GalleyMavenBuilder();
    mavenBuilder.withCacheProviderFactory(new FileCacheProviderFactory(cacheDir));
}
Also used : GalleyMavenBuilder(org.commonjava.maven.galley.maven.GalleyMavenBuilder) TemporaryFolder(org.junit.rules.TemporaryFolder) FileCacheProviderFactory(org.commonjava.maven.galley.cache.FileCacheProviderFactory)

Example 63 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project ddf by codice.

the class SystemPropertiesAdminTest method setUp.

@Before
public void setUp() throws IOException {
    System.setProperty(SystemBaseUrl.PORT, "1234");
    System.setProperty(SystemBaseUrl.HOST, "host");
    expectedSystemPropertiesCount++;
    System.setProperty(SystemBaseUrl.HTTP_PORT, "4567");
    expectedSystemPropertiesCount++;
    System.setProperty(SystemBaseUrl.HTTPS_PORT, "8901");
    expectedSystemPropertiesCount++;
    System.setProperty(SystemInfo.ORGANIZATION, "org");
    expectedSystemPropertiesCount++;
    System.setProperty(SystemInfo.SITE_CONTACT, "contact");
    expectedSystemPropertiesCount++;
    System.setProperty(SystemInfo.SITE_NAME, "site");
    expectedSystemPropertiesCount++;
    System.setProperty(SystemInfo.VERSION, "version");
    expectedSystemPropertiesCount++;
    TemporaryFolder temporaryFolder = new TemporaryFolder();
    temporaryFolder.create();
    etcFolder = temporaryFolder.newFolder("etc");
    System.setProperty("karaf.etc", etcFolder.getAbsolutePath());
    systemPropsFile = new File(etcFolder, "system.properties");
    userPropsFile = new File(etcFolder, "users.properties");
    userAttrsFile = new File(etcFolder, "users.attributes");
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) Before(org.junit.Before)

Example 64 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project ddf by codice.

the class TestOwaspDiffRunner method before.

@Before
public void before() throws Exception {
    fakeRepo = new TemporaryFolder();
    fakeRepo.create();
    File fakeChangedPom = fakeRepo.newFile("pom.xml");
    System.setProperty("maven.repo.local", fakeChangedPom.getParent());
    //Set command line returns
    when(mavenVersionCommandProcess.getInputStream()).thenReturn(new ByteArrayInputStream(("Maven home: " + fakeRepo.getRoot().getPath()).getBytes(StandardCharsets.UTF_8)));
    when(mavenSettingCommandProcess.getInputStream()).thenReturn(new ByteArrayInputStream(("<localRepository>" + fakeRepo.getRoot().getPath() + "</localRepository>").getBytes(StandardCharsets.UTF_8)));
    when(gitShortBranchNameCommandProcess.getInputStream()).thenReturn(new ByteArrayInputStream("test-branch".getBytes(StandardCharsets.UTF_8)));
    when(gitDiffNameCommandProcess.getInputStream()).thenReturn(new ByteArrayInputStream(fakeChangedPom.getPath().getBytes(StandardCharsets.UTF_8)));
    //Set runtime when executing commands
    when(runtime.exec(MAVEN_VERSION_COMMAND)).thenReturn(mavenVersionCommandProcess);
    when(runtime.exec(MAVEN_SETTINGS_COMMAND)).thenReturn(mavenSettingCommandProcess);
    when(runtime.exec(GIT_SHORT_BRANCH_NAME_COMMAND)).thenReturn(gitShortBranchNameCommandProcess);
    when(runtime.exec(matches(GIT_DIFF_NAME_COMMAND + ".*"))).thenReturn(gitDiffNameCommandProcess);
    //Set maven executor
    when(mavenBuildResult.getExitCode()).thenReturn(0);
    when(invoker.execute(any())).thenReturn(mavenBuildResult);
    owaspDiffRunner = new OwaspDiffRunner(runtime, invoker);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) Before(org.junit.Before)

Example 65 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project sling by apache.

the class BundleListContentProviderTest method setupTemporaryFiles.

@Before
public void setupTemporaryFiles() throws IOException {
    TemporaryFolder configRoot = new TemporaryFolder(tempFolder.getRoot());
    configRoot.create();
    for (String filename : CONFIG_FILES) {
        final File f = getConfigFile(configRoot, filename);
        f.createNewFile();
        assertTrue("Expecting temporary config file to have been created: " + f.getAbsolutePath(), f.exists());
    }
    configDirectory = configRoot.getRoot();
    resourceProviderRoot = new File(tempFolder.getRoot(), "RESOURCE_PROVIDER_ROOT");
    resourceProviderRoot.mkdirs();
    resourceProviderFile = new File(resourceProviderRoot, "RP_FILE_" + System.currentTimeMillis());
    resourceProviderFile.createNewFile();
    fakeBundlePath = getFakeBundlePath();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) Before(org.junit.Before)

Aggregations

TemporaryFolder (org.junit.rules.TemporaryFolder)106 File (java.io.File)40 Before (org.junit.Before)28 Test (org.junit.Test)28 BeforeClass (org.junit.BeforeClass)13 URL (java.net.URL)7 Path (java.nio.file.Path)7 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)3 UserState (alluxio.security.user.UserState)2 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2 RocksDBPersistenceProvider (com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 URISyntaxException (java.net.URISyntaxException)2 BdpDataPlanePlugin (org.batfish.bdp.BdpDataPlanePlugin)2 Batfish (org.batfish.main.Batfish)2 NotNull (org.jetbrains.annotations.NotNull)2 DefaultSafeModeManager (alluxio.master.DefaultSafeModeManager)1 InMemoryReferenceSequenceFile (au.edu.wehi.idsv.picard.InMemoryReferenceSequenceFile)1 SynchronousReferenceLookupAdapter (au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter)1