Bug 581829 - Do not show primitive values for PHD dumps

Fix test, and some other test tidy up.

Change-Id: Ic855fb4b1c325f63edfead23758a1a5ffc516dbd
diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/acquire/AcquireDumpTest.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/acquire/AcquireDumpTest.java
index 0d0ee08..85cf967 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/acquire/AcquireDumpTest.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/acquire/AcquireDumpTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************

- * Copyright (c) 2015, 2021 IBM Corporation.

+ * Copyright (c) 2015, 2023 IBM Corporation.

  * All rights reserved. This program and the accompanying materials

  * are made available under the terms of the Eclipse Public License 2.0

  * which accompanies this distribution, and is available at

@@ -15,9 +15,9 @@
 import static org.hamcrest.CoreMatchers.containsString;

 import static org.hamcrest.CoreMatchers.notNullValue;

 import static org.hamcrest.MatcherAssert.assertThat;

+import static org.hamcrest.Matchers.equalTo;

 import static org.hamcrest.number.OrderingComparison.greaterThan;

 import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo;

-import static org.junit.Assert.assertEquals;

 import static org.junit.Assert.assertNotNull;

 import static org.junit.Assert.assertTrue;

 import static org.junit.Assume.assumeThat;

@@ -366,8 +366,8 @@
                 }

             }

         }

-        assertEquals("Expected to find a org.eclipse.mat.tests plugin", found, 1);

-        assertEquals("Expected Dependencies,Dependents, Extension Points, Extensions, Used Services from org.eclipse.mat.api", f2, 31);

+        assertThat("Expected to find a org.eclipse.mat.tests plugin", found, equalTo(1));

+        assertThat("Expected Dependencies,Dependents, Extension Points, Extensions, Used Services from org.eclipse.mat.api", f2, equalTo(31));

     }

 

     private void checkSubtree(IResultTree tree, Object o3, int minElements, String toFind, String errMsg)

diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ArrayIntTest.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ArrayIntTest.java
index aa93224..74e6873 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ArrayIntTest.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ArrayIntTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************

- * Copyright (c) 2010, 2022 IBM Corporation

+ * Copyright (c) 2010, 2023 IBM Corporation

  * All rights reserved. This program and the accompanying materials

  * are made available under the terms of the Eclipse Public License 2.0

  * which accompanies this distribution, and is available at

@@ -14,9 +14,8 @@
 

 import static org.hamcrest.CoreMatchers.equalTo;

 import static org.hamcrest.MatcherAssert.assertThat;

-import static org.hamcrest.Matchers.greaterThan;

+import static org.hamcrest.number.OrderingComparison.greaterThan;

 import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo;

-import static org.junit.Assert.assertEquals;

 import static org.junit.Assert.assertFalse;

 import static org.junit.Assert.assertTrue;

 

@@ -57,8 +56,8 @@
                 ss.add(v);

                 t += 1;

             }

-            assertTrue("At least one item should have been added", t > 0); //$NON-NLS-1$

-            assertEquals("Added items should equal size", t, ss.size()); //$NON-NLS-1$

+            assertThat("At least one item should have been added", t, greaterThan(0)); //$NON-NLS-1$

+            assertThat("Size should equal added items", ss.size(), equalTo(t)); //$NON-NLS-1$

             assertFalse("Not empty", ss.isEmpty());

         }

     }

@@ -84,7 +83,7 @@
         }

         int i = 0;

         for (IteratorInt ii = ss.iterator(); ii.hasNext(); ){

-            assertEquals("every entry should be in the iterator", ss.get(i++), ii.next()); //$NON-NLS-1$

+            assertThat("the iterator should match each entry", ii.next(), equalTo(ss.get(i++))); //$NON-NLS-1$

         }

     }

 

@@ -110,7 +109,7 @@
         for (int k = 0; k < KEYS; ++k) {

             t += ss.get(k) > 0 ? 1 : 0;

         }

-        assertEquals("contained items should equals the size", ss.size(), t); //$NON-NLS-1$

+        assertThat("contained items should equals the size", t, equalTo(ss.size())); //$NON-NLS-1$

     }

 

     /**

@@ -134,7 +133,7 @@
         ArrayInt ss2 = new ArrayInt(ss);

         int i = 0;

         for (IteratorInt ii = ss.iterator(); ii.hasNext(); ){

-            assertEquals("every entry should be in the iterator", ss2.get(i++), ii.next()); //$NON-NLS-1$

+            assertThat("the iterator should match each entry", ii.next(), equalTo(ss2.get(i++))); //$NON-NLS-1$

         }

     }

 

@@ -254,11 +253,11 @@
         }

         int i = 0;

         for (IteratorInt ii = ss.iterator(); ii.hasNext(); ){

-            assertEquals("every key should be contained in the deserialized version", ii.next(), ss2.get(i++)); //$NON-NLS-1$

+            assertThat("every key should be contained in the deserialized version", ii.next(), equalTo(ss2.get(i++))); //$NON-NLS-1$

         }

         i = 0;

         for (IteratorInt ii = ss2.iterator(); ii.hasNext(); ){

-            assertEquals("every deserialized key should be contained", ii.next(), ss.get(i++)); //$NON-NLS-1$

+            assertThat("every deserialized key should be contained", ii.next(), equalTo(ss.get(i++))); //$NON-NLS-1$

         }

     }

 

diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ArrayLongTest.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ArrayLongTest.java
index 96a6062..bb401ae 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ArrayLongTest.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/collect/ArrayLongTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************

- * Copyright (c) 2010, 2022 IBM Corporation

+ * Copyright (c) 2010, 2023 IBM Corporation

  * All rights reserved. This program and the accompanying materials

  * are made available under the terms of the Eclipse Public License 2.0

  * which accompanies this distribution, and is available at

@@ -15,8 +15,8 @@
 import static org.hamcrest.CoreMatchers.equalTo;

 import static org.hamcrest.CoreMatchers.not;

 import static org.hamcrest.MatcherAssert.assertThat;

+import static org.hamcrest.number.OrderingComparison.greaterThan;

 import static org.hamcrest.number.OrderingComparison.lessThanOrEqualTo;

-import static org.junit.Assert.assertEquals;

 import static org.junit.Assert.assertFalse;

 import static org.junit.Assert.assertTrue;

 

@@ -57,12 +57,12 @@
                 ss.add(v);

                 t += 1;

             }

-            assertTrue("At least one item should have been added", t > 0); //$NON-NLS-1$

-            assertEquals("Added items should equal size", t, ss.size()); //$NON-NLS-1$

-            assertFalse("Not empty", ss.isEmpty());

+            assertThat("At least one item should have been added", t, greaterThan(0)); //$NON-NLS-1$

+            assertThat("Size should equal added items", ss.size(), equalTo(t)); //$NON-NLS-1$

+            assertFalse("Not empty", ss.isEmpty()); //$NON-NLS-1$

         }

     }

-    

+

     /**

      * Check that set contains everything it says it has

      */

@@ -84,7 +84,7 @@
         }

         int i = 0;

         for (IteratorLong ii = ss.iterator(); ii.hasNext(); ){

-            assertEquals("every entry should be in the iterator", ss.get(i++), ii.next()); //$NON-NLS-1$

+            assertThat("the iterator should match each entry", ii.next(), equalTo(ss.get(i++))); //$NON-NLS-1$

         }

     }

 

@@ -113,7 +113,7 @@
         for (int k = 0; k < KEYS; ++k) {

             t += ss.get(k) != 0 ? 1 : 0;

         }

-        assertEquals("contained items should equals the size", ss.size(), t); //$NON-NLS-1$

+        assertThat("contained items should equals the size", t, equalTo(ss.size())); //$NON-NLS-1$

     }

 

     /**

@@ -137,7 +137,7 @@
         ArrayLong ss2 = new ArrayLong(ss);

         int i = 0;

         for (IteratorLong ii = ss.iterator(); ii.hasNext(); ){

-            assertEquals("every entry should be in the iterator", ss2.get(i++), ii.next()); //$NON-NLS-1$

+            assertThat("the iterator should match each entry", ii.next(), equalTo(ss2.get(i++))); //$NON-NLS-1$

         }

     }

 

@@ -260,11 +260,11 @@
         }

         int i = 0;

         for (IteratorLong ii = ss.iterator(); ii.hasNext(); ){

-            assertEquals("every key should be contained in the deserialized version", ii.next(), ss2.get(i++)); //$NON-NLS-1$

+            assertThat("every key should be contained in the deserialized version", ii.next(), equalTo(ss2.get(i++))); //$NON-NLS-1$

         }

         i = 0;

         for (IteratorLong ii = ss2.iterator(); ii.hasNext(); ){

-            assertEquals("every deserialized key should be contained", ii.next(), ss.get(i++)); //$NON-NLS-1$

+            assertThat("every deserialized key should be contained", ii.next(), equalTo(ss.get(i++))); //$NON-NLS-1$

         }

     }

 

diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/GeneralSnapshotTests.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/GeneralSnapshotTests.java
index 3dfb127..95121f3 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/GeneralSnapshotTests.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/GeneralSnapshotTests.java
@@ -1307,7 +1307,8 @@
         assertNotNull(t);

         // Will run name resolvers on every object!

         IResultTable table = (IResultTable)t;

-        // Every PHD files have some empty char arrays which get resolved.

+        // PHD files do have char arrays and byte arrays, but these no longer get resolved (bug 581829).

+        assumeThat(snapshot.getSnapshotInfo().getProperty("$heapFormat"), not(equalTo((Serializable)"DTFJ-PHD")));

         assumeThat(snapshot.getSnapshotInfo().getProperty("$heapFormat"), not(equalTo((Serializable)"DTFJ-Javacore")));

         // More than one different line, so some name resolvers are working

         assertThat(table.getRowCount(), greaterThan(1));

diff --git a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueryLookupTest.java b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueryLookupTest.java
index 0038393..0b7cf88 100644
--- a/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueryLookupTest.java
+++ b/plugins/org.eclipse.mat.tests/src/org/eclipse/mat/tests/snapshot/QueryLookupTest.java
@@ -1,5 +1,5 @@
 /*******************************************************************************

- * Copyright (c) 2010, 2022 SAP AG and IBM Corporation

+ * Copyright (c) 2010, 2023 SAP AG and IBM Corporation

  * All rights reserved. This program and the accompanying materials

  * are made available under the terms of the Eclipse Public License 2.0

  * which accompanies this distribution, and is available at

@@ -752,7 +752,7 @@
                      * without conversion.

                      */

                     if (v < limit && v >= -limit || !s.contains("\u2248"))

-                        assertTrue(colIdx+":"+c.getLabel()+" "+f.toString() +" " + vc + "\n" + v + "\n" + d2 + "\n" + s + "\n" + s2, s2.matches("[+-]?[0-9,]+(\\.[0-9]+)?(\\s?%)?"));

+                        assertTrue(colIdx+":"+c.getLabel()+" "+f.toString() +" " + vc + "\n" + v + "\n" + d2 + "\n" + s + "\n" + s2, s2.matches("[+-]?[0-9,]+(\\.[0-9]{1,20})?(\\s?%)?"));

                 }

             }

         }