Search in sources :

Example 1 with CachedTOCJars

use of org.eclipse.ceylon.model.loader.impl.reflect.CachedTOCJars in project ceylon by eclipse.

the class CachedTOCJarsTest method spacesOnPathTest.

@Test
public void spacesOnPathTest() throws IOException {
    CachedTOCJars cachedTOCJars = new CachedTOCJars();
    Module module = new Module();
    module.setName(Collections.singletonList("testModule"));
    module.setVersion("testVersion");
    final File artifactFile = File.createTempFile("path with spaces", ".jar");
    try {
        artifactFile.deleteOnExit();
        ZipOutputStream artifactOut = new ZipOutputStream(new FileOutputStream(artifactFile));
        try {
            artifactOut.putNextEntry(new ZipEntry(ALSO_INSIDE_JAR));
        } finally {
            artifactOut.close();
        }
        ArtifactResult artifact = new TestArtifactResult(artifactFile, module);
        cachedTOCJars.addJar(artifact, module);
        String uriPart = cachedTOCJars.getContentUri(module, ALSO_INSIDE_JAR).getSchemeSpecificPart();
        // I'm not comparing URI part for equality to avoid symbolic links resolution issues.
        Assert.assertTrue(uriPart, uriPart.endsWith(artifactFile.getName() + "!" + ALSO_INSIDE_JAR));
    } finally {
        artifactFile.delete();
    }
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) FileOutputStream(java.io.FileOutputStream) ZipEntry(java.util.zip.ZipEntry) CachedTOCJars(org.eclipse.ceylon.model.loader.impl.reflect.CachedTOCJars) Module(org.eclipse.ceylon.model.typechecker.model.Module) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Test(org.junit.Test)

Aggregations

File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 ZipEntry (java.util.zip.ZipEntry)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)1 CachedTOCJars (org.eclipse.ceylon.model.loader.impl.reflect.CachedTOCJars)1 Module (org.eclipse.ceylon.model.typechecker.model.Module)1 Test (org.junit.Test)1