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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations