Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add hybrid test case

  • Loading branch information...
commit 7a9824506ad70f1f39eddee315abf5bf65eedb3c 1 parent c82c161
Norbert Hu authored
View
2  pom.xml
@@ -147,7 +147,7 @@
<goal>verify</goal>
</goals>
<configuration>
- <argLine>-javaagent:${project.build.directory}/${project.artifactId}-${project.version}.jar="-Xconditional -Aorg/apache/maven/.+ -Ajunit/.+ -Aorg/junit/.+"</argLine>
+ <argLine>-javaagent:${project.build.directory}/${project.artifactId}-${project.version}.jar="-Xconditional -Aorg/apache/maven/.+ -Ajunit/.+ -Aorg/junit/.+" -Djavaagent=${project.build.directory}/${project.artifactId}-${project.version}.jar</argLine>
<workingDirectory>${project.build.directory}</workingDirectory>
<includes>
<include>**/Test*.java</include>
View
37 src/test/java/com/foursquare/heapaudit/test/TestHybrid.java
@@ -0,0 +1,37 @@
+package com.foursquare.heapaudit.test;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class TestHybrid {
+
+ // Test hybrid scenario.
+
+ @Test public void Hybrid() throws InterruptedException, IOException {
+
+ Process process = Runtime.getRuntime().exec("java -javaagent:" + System.getProperty("javaagent") + "=-Icom.foursquare.heapaudit.tutorials.Example@allocateBar.+ -classpath test-classes com/foursquare/heapaudit/tutorials/example4/Hybrid");
+
+ process.waitFor();
+
+ BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()));
+
+ String result = "";
+
+ for (String s = input.readLine(); s != null; s = input.readLine()) {
+
+ result += s + "\n";
+
+ }
+
+ assertTrue(result.matches("(?m)^HEAP: com/foursquare/heapaudit/tutorials/Example@allocateBar\\(\\)V x1$[\\s\\S]*^ - com.foursquare.heapaudit.tutorials.Example[$]Bar \\(\\d+ bytes\\) x1$[\\s\\S]*"));
+
+ assertFalse(result.matches("(?m)[\\s\\S]*^ - com.foursquare.heapaudit.tutorials.Example[$]Foo \\(\\d+ bytes\\) x\\d+$[\\s\\S]*"));
+
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.