diff --git a/platform/util/testSrc/com/intellij/execution/CommandLineWrapperUtilTest.java b/platform/util/testSrc/com/intellij/execution/CommandLineWrapperUtilTest.java index c6f2f6cb7080..ec8f51b8cc22 100644 --- a/platform/util/testSrc/com/intellij/execution/CommandLineWrapperUtilTest.java +++ b/platform/util/testSrc/com/intellij/execution/CommandLineWrapperUtilTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,26 +30,25 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class CommandLineWrapperUtilTest { - @Test public void testManifestWithJarsAndDirectories() throws Exception { - final File tempDirectory = FileUtil.createTempDirectory("dirWithClasses", "suffix"); - File jarFile = null; + File tempDirectory = FileUtil.createTempDirectory("dirWithClasses", "suffix"); try { - final List paths = Arrays.asList(tempDirectory.getAbsolutePath(), tempDirectory.getAbsolutePath() + "/directory with spaces/some.jar"); - jarFile = CommandLineWrapperUtil.createClasspathJarFile(new Manifest(), paths); - final JarInputStream inputStream = new JarInputStream(new FileInputStream(jarFile)); - final Manifest manifest = inputStream.getManifest(); - final String classPath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH); - final String tempDirectoryUrl = tempDirectory.toURI().toURL().toString(); - assertTrue(tempDirectoryUrl, tempDirectoryUrl.endsWith("/")); - assertEquals(tempDirectoryUrl + " " + tempDirectoryUrl +"directory%20with%20spaces/some.jar", classPath); - } - finally { - FileUtil.delete(tempDirectory); - if (jarFile != null) { + List paths = Arrays.asList(tempDirectory.getAbsolutePath(), tempDirectory.getAbsolutePath() + "/directory with spaces/some.jar"); + File jarFile = CommandLineWrapperUtil.createClasspathJarFile(new Manifest(), paths); + try (JarInputStream inputStream = new JarInputStream(new FileInputStream(jarFile))) { + Manifest manifest = inputStream.getManifest(); + String classPath = manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH); + String tempDirectoryUrl = tempDirectory.toURI().toURL().toString(); + assertTrue(tempDirectoryUrl, tempDirectoryUrl.endsWith("/")); + assertEquals(tempDirectoryUrl + " " + tempDirectoryUrl +"directory%20with%20spaces/some.jar", classPath); + } + finally { FileUtil.delete(jarFile); } } + finally { + FileUtil.delete(tempDirectory); + } } } \ No newline at end of file