Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Waibel2015-06-02 07:39:10 -0400
committerFlorian Waibel2015-06-02 07:39:10 -0400
commit528efbe059c78f4a40c7649e4f34749be3f6db4c (patch)
tree8ec08e8f6c2e10caf0c9d35370010af8db34551a
parent52c05676def6a025e088e3aed1ba6b6f6dd69d51 (diff)
downloadorg.eclipse.virgo.kernel-528efbe059c78f4a40c7649e4f34749be3f6db4c.tar.gz
org.eclipse.virgo.kernel-528efbe059c78f4a40c7649e4f34749be3f6db4c.tar.xz
org.eclipse.virgo.kernel-528efbe059c78f4a40c7649e4f34749be3f6db4c.zip
Fixes resource leak in JUnit test setup method
-rwxr-xr-xorg.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/scoping/ScoperTests.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/scoping/ScoperTests.java b/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/scoping/ScoperTests.java
index 18d7415c..6f573d31 100755
--- a/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/scoping/ScoperTests.java
+++ b/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/scoping/ScoperTests.java
@@ -1,3 +1,4 @@
+
package org.eclipse.virgo.kernel.install.artifact.internal.scoping;
import java.io.File;
@@ -22,12 +23,12 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-
public class ScoperTests {
private static final String SCOPE_NAME = "test_scope";
private static BundleManifest manifest = null;
+
private static BundleManifest unscopedManifest = null;
private static List<BundleManifest> bundleManifests = new ArrayList<BundleManifest>();
@@ -38,25 +39,25 @@ public class ScoperTests {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
- FileReader reader = new FileReader(new File(bundleFile, "META-INF/MANIFEST.MF"));
- manifest = BundleManifestFactory.createBundleManifest(reader);
- reader.close();
- unscopedManifest = BundleManifestFactory.createBundleManifest(manifest.toDictionary());
- bundleManifests.add(manifest);
+ try (FileReader reader = new FileReader(new File(bundleFile, "META-INF/MANIFEST.MF"))) {
+ manifest = BundleManifestFactory.createBundleManifest(reader);
+ reader.close();
+ unscopedManifest = BundleManifestFactory.createBundleManifest(manifest.toDictionary());
+ bundleManifests.add(manifest);
+ }
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
-
+
@Test
- public void testScoping() throws UnsupportedBundleManifestVersionException, DuplicateExportException, DuplicateBundleSymbolicNameException {
+ public void testScoping() throws UnsupportedBundleManifestVersionException, DuplicateExportException, DuplicateBundleSymbolicNameException {
Scoper scoper = new Scoper(bundleManifests, SCOPE_NAME);
- scoper.scope();
+ scoper.scope();
checkImports();
checkDynamicImports();
checkExports();
-// Assert.assertEquals(bundleManifest, actual);
}
private void checkImports() {
@@ -74,7 +75,7 @@ public class ScoperTests {
Assert.assertTrue(uipList.get(i).getAttributes().size() + 1 == ipList.get(i).getAttributes().size());
}
}
-
+
private void checkDynamicImports() {
DynamicImportPackage dynamicImportPackage = manifest.getDynamicImportPackage();
DynamicImportPackage unscopedDynamicImportPackage = unscopedManifest.getDynamicImportPackage();
@@ -91,7 +92,7 @@ public class ScoperTests {
}
Assert.assertTrue(dipList.size() == udipList.size() * 2);
}
-
+
private void checkExports() {
ExportPackage exportPackage = manifest.getExportPackage();
ExportPackage unscopedExportPackage = unscopedManifest.getExportPackage();
@@ -107,5 +108,5 @@ public class ScoperTests {
Assert.assertTrue(uepList.get(i).getAttributes().size() + 1 == epList.get(i).getAttributes().size());
}
}
-
+
}

Back to the top