Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Waibel2018-06-25 05:28:36 -0400
committerFlorian Waibel2018-06-25 05:28:36 -0400
commit369da26e9ad16580e09fd10ac1e755bcad1ea580 (patch)
tree5c94912366089b359b825b535f76a4015de181a4
parenta1b96d8bc36d753cf1cfb2d14aa75a75dcc5003f (diff)
downloadorg.eclipse.virgo.medic-369da26e9ad16580e09fd10ac1e755bcad1ea580.tar.gz
org.eclipse.virgo.medic-369da26e9ad16580e09fd10ac1e755bcad1ea580.tar.xz
org.eclipse.virgo.medic-369da26e9ad16580e09fd10ac1e755bcad1ea580.zip
Add workaround for HeapDumpContributorTests.dumpHeap test failure
This commit sets the system property 'jdk.management.heapdump.allowAnyFileSuffix' during test execution. Since JDK 8u141 heap dump names are required to have the suffix 'hprof'. Also created Bug 535730 to fix the issue and track this workaround.
-rw-r--r--org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/HeapDumpContributorTests.java19
1 files changed, 8 insertions, 11 deletions
diff --git a/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/HeapDumpContributorTests.java b/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/HeapDumpContributorTests.java
index e6877c4..9513e77 100644
--- a/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/HeapDumpContributorTests.java
+++ b/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/HeapDumpContributorTests.java
@@ -12,7 +12,6 @@
package org.eclipse.virgo.medic.dump.impl;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import java.io.File;
import java.lang.management.ManagementFactory;
@@ -25,9 +24,10 @@ import org.eclipse.virgo.medic.dump.Dump;
import org.eclipse.virgo.medic.dump.DumpContributionFailedException;
import org.eclipse.virgo.medic.dump.DumpContributor;
import org.eclipse.virgo.medic.dump.impl.heap.HeapDumpContributor;
-import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
public class HeapDumpContributorTests {
@@ -35,15 +35,12 @@ public class HeapDumpContributorTests {
private static final String HOTSPOT_DIAGNOSTIC_MBEAN_NAME = "com.sun.management:type=HotSpotDiagnostic";
- private final File dumpDirectory = new File("build");
+ @Rule
+ public TemporaryFolder dumpDirectory = new TemporaryFolder();
@Before
- @After
public void cleanupHeadDumps() {
- File heapDumpFile = new File("build", "heap.out");
- if (heapDumpFile.exists()) {
- assertTrue(heapDumpFile.delete());
- }
+ System.setProperty("jdk.management.heapdump.allowAnyFileSuffix", "true");
}
@Test
@@ -54,7 +51,7 @@ public class HeapDumpContributorTests {
long timestamp = System.currentTimeMillis();
Map<String, Object> context = new HashMap<String, Object>();
- Dump dump = new StubDump(cause, timestamp, context, new Throwable[0], dumpDirectory);
+ Dump dump = new StubDump(cause, timestamp, context, new Throwable[0], this.dumpDirectory.getRoot());
contributor.contribute(dump);
@@ -62,7 +59,7 @@ public class HeapDumpContributorTests {
try {
Class<?> diagnosticMbeanClass = Class.forName("com.sun.management.HotSpotDiagnosticMXBean", true,
- HeapDumpContributor.class.getClassLoader());
+ HeapDumpContributor.class.getClassLoader());
ManagementFactory.newPlatformMXBeanProxy(MBEAN_SERVER, HOTSPOT_DIAGNOSTIC_MBEAN_NAME, diagnosticMbeanClass);
diagnostMbeanAvailable = true;
} catch (Exception e) {
@@ -78,6 +75,6 @@ public class HeapDumpContributorTests {
}
}
- assertEquals(diagnostMbeanAvailable, new File(this.dumpDirectory, "heap.out").exists());
+ assertEquals(diagnostMbeanAvailable, new File(this.dumpDirectory.getRoot(), "heap.out").exists());
}
}

Back to the top