Merge branch 'bug/JAL-1726_External-integration-test_PDB' into Release_2_9_Branch
[jalview.git] / test / jalview / viewmodel / styles / ViewStyleTest.java
index 9a0820f..115c5d3 100644 (file)
@@ -39,7 +39,10 @@ public class ViewStyleTest
     for (Field field : fields)
     {
       field.setAccessible(true);
-      changeValue(vs1, field);
+      if (!copyConstructorIgnores(field.getName()))
+      {
+        changeValue(vs1, field);
+      }
     }
 
     ViewStyle vs2 = new ViewStyle(vs1);
@@ -51,6 +54,22 @@ public class ViewStyleTest
               + value2 + ") - not set in copy constructor?";
       assertEquals(msg, value1, value2);
     }
+    assertEquals("Hashcode not equals", vs1.hashCode(), vs2.hashCode());
+  }
+
+  /**
+   * Add any field names in here that we expect to be ignored by the copy
+   * constructor
+   * 
+   * @param name
+   * @return
+   */
+  private boolean copyConstructorIgnores(String name)
+  {
+    /*
+     * currently none!
+     */
+    return false;
   }
 
   /**
@@ -64,7 +83,6 @@ public class ViewStyleTest
           throws IllegalAccessException
   {
     Class<?> type = field.getType();
-    final int numValue = 1 + r.nextInt(100);
 
     if (type.equals(boolean.class) || type.equals(Boolean.class))
     {
@@ -167,6 +185,12 @@ public class ViewStyleTest
       changeValue(vs2, field);
       assertFalse("equals method ignores " + field.getName(),
               vs1.equals(vs2));
+
+      if (vs1.hashCode() == vs2.hashCode())
+      {
+        // uncomment next line to see which fields hashCode ignores
+        // System.out.println("hashCode ignores " + field.getName());
+      }
       // restore original value before testing the next field
       field.set(vs2, oldValue);
     }