Search in sources :

Example 86 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project flow by vaadin.

the class StaticFileServerTest method isStaticResource_jarInAJar_detectsAsStaticResources.

@Test
public void isStaticResource_jarInAJar_detectsAsStaticResources() throws IOException {
    fileServer.writeResponse = false;
    Assert.assertTrue("Can not run concurrently with other test", StaticFileServer.openFileSystems.isEmpty());
    final TemporaryFolder folder = TemporaryFolder.builder().build();
    folder.create();
    File archiveFile = new File(folder.getRoot(), "fake.jar");
    archiveFile.createNewFile();
    Path tempArchive = archiveFile.toPath();
    File warFile = new File(folder.getRoot(), "war.jar");
    warFile.createNewFile();
    Path warArchive = warFile.toPath();
    generateJarInJar(archiveFile, tempArchive, warArchive);
    setupRequestURI("", "", "/frontend/.");
    Mockito.when(servletService.getStaticResource("/frontend/.")).thenReturn(new URL("jar:" + warFile.toURI().toURL() + "!/" + archiveFile.getName() + "!/frontend"));
    Assert.assertTrue("Request should return as static request as we can not determine non file resources in jar files.", fileServer.serveStaticResource(request, response));
    setupRequestURI("", "", "/file.txt");
    Mockito.when(servletService.getStaticResource("/file.txt")).thenReturn(new URL("jar:" + warFile.toURI().toURL() + "!/" + archiveFile.getName() + "!/file.txt"));
    Assert.assertTrue("Request should return as static request as we can not determine non file resources in jar files.", fileServer.serveStaticResource(request, response));
    folder.delete();
}
Also used : Path(java.nio.file.Path) TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 87 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project flow by vaadin.

the class StaticFileServerTest method isStaticResource_jarWarFileScheme_detectsAsStaticResources.

@Test
public void isStaticResource_jarWarFileScheme_detectsAsStaticResources() throws IOException {
    fileServer.writeResponse = false;
    Assert.assertTrue("Can not run concurrently with other test", StaticFileServer.openFileSystems.isEmpty());
    final TemporaryFolder folder = TemporaryFolder.builder().build();
    folder.create();
    File archiveFile = new File(folder.getRoot(), "fake.jar");
    archiveFile.createNewFile();
    Path tempArchive = archiveFile.toPath();
    File warFile = new File(folder.getRoot(), "war.jar");
    warFile.createNewFile();
    Path warArchive = warFile.toPath();
    generateJarInJar(archiveFile, tempArchive, warArchive);
    // Instantiate URL stream handler factory to be able to handle war:
    WarURLStreamHandlerFactory.getInstance();
    final URL folderResourceURL = new URL("jar:war:" + warFile.toURI().toURL() + "!/" + archiveFile.getName() + "!/frontend");
    setupRequestURI("", "", "/frontend/.");
    Mockito.when(servletService.getStaticResource("/frontend/.")).thenReturn(folderResourceURL);
    Assert.assertTrue("Request should return as static request as we can not determine non file resources in jar files.", fileServer.serveStaticResource(request, response));
    folder.delete();
}
Also used : Path(java.nio.file.Path) TemporaryFolder(org.junit.rules.TemporaryFolder) File(java.io.File) URL(java.net.URL) Test(org.junit.Test)

Example 88 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project batfish by batfish.

the class NodJobTest method setupDataPlane.

private void setupDataPlane() throws IOException {
    TemporaryFolder tmp = new TemporaryFolder();
    tmp.create();
    Batfish batfish = BatfishTestUtils.getBatfish(_configs, tmp);
    _bdpDataPlanePlugin = new BdpDataPlanePlugin();
    _bdpDataPlanePlugin.initialize(batfish);
    batfish.registerDataPlanePlugin(_bdpDataPlanePlugin, "bdp");
    batfish.computeDataPlane(false);
    _dataPlane = batfish.loadDataPlane();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) BdpDataPlanePlugin(org.batfish.bdp.BdpDataPlanePlugin) Batfish(org.batfish.main.Batfish)

Example 89 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project batfish by batfish.

the class BatfishCompressionTest method getDataPlane.

private DataPlane getDataPlane(SortedMap<String, Configuration> configs) throws IOException {
    // make sure to reconstruct the network, since compression mutates it
    TemporaryFolder tmp = new TemporaryFolder();
    tmp.create();
    Batfish batfish = BatfishTestUtils.getBatfish(configs, tmp);
    BdpDataPlanePlugin bdpDataPlanePlugin = new BdpDataPlanePlugin();
    bdpDataPlanePlugin.initialize(batfish);
    batfish.registerDataPlanePlugin(bdpDataPlanePlugin, "bdp");
    batfish.computeDataPlane(false);
    return batfish.loadDataPlane();
}
Also used : TemporaryFolder(org.junit.rules.TemporaryFolder) BdpDataPlanePlugin(org.batfish.bdp.BdpDataPlanePlugin) Batfish(org.batfish.main.Batfish) IBatfish(org.batfish.common.plugin.IBatfish)

Example 90 with TemporaryFolder

use of org.junit.rules.TemporaryFolder in project gridss by PapenfussLab.

the class SplitReadEvidenceTest method indel_mismapping_false_positive_assembly_should_not_throw_homology_error.

@Test
@Category(Hg19Tests.class)
public void indel_mismapping_false_positive_assembly_should_not_throw_homology_error() throws IOException {
    File ref = Hg19Tests.findHg19Reference();
    IndexedFastaSequenceFile indexed = new IndexedFastaSequenceFile(ref);
    TemporaryFolder folder = new TemporaryFolder();
    folder.create();
    ProcessingContext pc = new ProcessingContext(new FileSystemContext(folder.getRoot(), folder.getRoot(), 500000), ref, new SynchronousReferenceLookupAdapter(indexed), new ArrayList<Header>(), getConfig());
    // File bam = new File(folder.getRoot(), "input.bam");
    // Files.copy(new File("src/test/resources/indel_mismapping_false_positive_assembly.sv.bam"), bam);
    SAMEvidenceSource ses = new MockSAMEvidenceSource(pc);
    List<SAMRecord> records = IntermediateFilesTest.getRecords(new File("src/test/resources/indel_mismapping_false_positive_assembly.sv.bam"));
    for (SAMRecord r : records) {
        if ("asm5".equals(r.getReadName())) {
            for (SplitReadEvidence e : SplitReadEvidence.create(ses, r)) {
                assertTrue(e.isReference());
            }
        }
    }
    folder.delete();
}
Also used : IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) Header(htsjdk.samtools.metrics.Header) SAMFileHeader(htsjdk.samtools.SAMFileHeader) SAMRecord(htsjdk.samtools.SAMRecord) TemporaryFolder(org.junit.rules.TemporaryFolder) InMemoryReferenceSequenceFile(au.edu.wehi.idsv.picard.InMemoryReferenceSequenceFile) File(java.io.File) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) SynchronousReferenceLookupAdapter(au.edu.wehi.idsv.picard.SynchronousReferenceLookupAdapter) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

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