Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Johnson2018-11-25 17:44:38 -0500
committerAndrew Johnson2018-11-25 17:44:38 -0500
commit7de2189059ac6668422c662bb1c22566c532a942 (patch)
tree5552b9ed26fc107c792a35163a747d5a14f13183
parent84103389acb0dd1292de2eec26e4a99e94a522c0 (diff)
downloadorg.eclipse.mat-7de2189059ac6668422c662bb1c22566c532a942.tar.gz
org.eclipse.mat-7de2189059ac6668422c662bb1c22566c532a942.tar.xz
org.eclipse.mat-7de2189059ac6668422c662bb1c22566c532a942.zip
[541539] Simple batch mode comparison of two snapshots
Problems with secondary snapshots and tests Change-Id: Ib48618a87d378354a7ca468af2a920dd96d1418b
-rw-r--r--plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueriesTest.java83
1 files changed, 39 insertions, 44 deletions
diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueriesTest.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueriesTest.java
index fed31058..5be89653 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueriesTest.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueriesTest.java
@@ -976,48 +976,50 @@ public class QueriesTest
public void testCompareQuery() throws SnapshotException, IOException
{
ISnapshot snapshot2 = TestSnapshots.getSnapshot(TestSnapshots.SUN_JDK6_18_64BIT, false);
- try
+ SnapshotQuery query = SnapshotQuery.parse("delta_histogram -snapshot2 "+snapshot2.getSnapshotInfo().getPath(), snapshot);
+ IResult t = query.execute(new VoidProgressListener());
+ assertNotNull(t);
+ int intplus = 0;
+ int intminus = 0;
+ if (t instanceof IResultTable)
{
- SnapshotQuery query = SnapshotQuery.parse("delta_histogram -snapshot2 "+snapshot2.getSnapshotInfo().getPath(), snapshot);
- IResult t = query.execute(new VoidProgressListener());
- assertNotNull(t);
- int intplus = 0;
- int intminus = 0;
- if (t instanceof IResultTable)
+ IResultTable tr = (IResultTable)t;
+ int rc = tr.getRowCount();
+ for (int i = 0; i < rc; ++i)
{
- IResultTable tr = (IResultTable)t;
- int rc = tr.getRowCount();
- for (int i = 0; i < rc; ++i)
+ Object rw = tr.getRow(i);
+ // columns are String, Long, Bytes
+ Object v = tr.getColumnValue(rw, 1);
+ if (v instanceof Integer)
{
- Object rw = tr.getRow(i);
- // columns are String, Long, Bytes
- Object v = tr.getColumnValue(rw, 1);
- if (v instanceof Integer)
- {
- int in = (Integer)v;
- if (in < 0)
- ++intminus;
- else if (in > 0)
- ++intplus;
- }
- else if (v instanceof Long)
- {
- long ln = (Long)v;
- if (ln < 0)
- ++intminus;
- else if (ln > 0)
- ++intplus;
- }
+ int in = (Integer)v;
+ if (in < 0)
+ ++intminus;
+ else if (in > 0)
+ ++intplus;
}
+ else if (v instanceof Long)
+ {
+ long ln = (Long)v;
+ if (ln < 0)
+ ++intminus;
+ else if (ln > 0)
+ ++intplus;
+ }
+ }
+ if (snapshot.getSnapshotInfo().getNumberOfObjects() == snapshot2.getSnapshotInfo().getNumberOfObjects())
+ {
+ // Check we have no pluses and minuses
+ assertThat(intplus, equalTo(0));
+ assertThat(intminus, equalTo(0));
+ }
+ else
+ {
// Check we have some pluses and minuses
assertThat(intplus, greaterThan(0));
assertThat(intminus, greaterThan(0));
}
}
- finally
- {
- snapshot2.dispose();
- }
}
/**
@@ -1028,16 +1030,9 @@ public class QueriesTest
@Test
public void testCompareReport() throws SnapshotException, IOException
{
- ISnapshot snapshot2 = TestSnapshots.getSnapshot(TestSnapshots.ORACLE_JDK8_05_64BIT, false);
- try
- {
- SnapshotQuery query = SnapshotQuery.parse("default_report org.eclipse.mat.api:compare -params snapshot2="+snapshot2.getSnapshotInfo().getPath(), snapshot);
- IResult t = query.execute(new VoidProgressListener());
- assertNotNull(t);
- }
- finally
- {
- snapshot2.dispose();
- }
+ ISnapshot snapshot2 = TestSnapshots.getSnapshot(TestSnapshots.SUN_JDK6_18_64BIT, false); // Do not dispose this as shared
+ SnapshotQuery query = SnapshotQuery.parse("default_report org.eclipse.mat.api:compare -params snapshot2="+snapshot2.getSnapshotInfo().getPath(), snapshot);
+ IResult t = query.execute(new VoidProgressListener());
+ assertNotNull(t);
}
}

Back to the top