X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fviewmodel%2Fstyles%2FViewStyleTest.java;h=9e259a9be62114abebac61c3aaa3be504731ffa8;hb=ab22918ab8fc67d30dad1fb1ae0f37e51f49df95;hp=9a0820fac8ebeea81d7238810400cdd7704b51d7;hpb=882adcab8cf6f9c72a7e946223f817878c5ee444;p=jalview.git diff --git a/test/jalview/viewmodel/styles/ViewStyleTest.java b/test/jalview/viewmodel/styles/ViewStyleTest.java index 9a0820f..9e259a9 100644 --- a/test/jalview/viewmodel/styles/ViewStyleTest.java +++ b/test/jalview/viewmodel/styles/ViewStyleTest.java @@ -1,15 +1,15 @@ package jalview.viewmodel.styles; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertTrue; import java.awt.Color; import java.lang.reflect.Field; import java.util.Random; -import org.junit.Assert; -import org.junit.Test; +import org.testng.AssertJUnit; +import org.testng.annotations.Test; public class ViewStyleTest @@ -30,7 +30,7 @@ public class ViewStyleTest * @throws IllegalAccessException * @throws IllegalArgumentException */ - @Test + @Test(groups ={ "Functional" }) public void testCopyConstructor() throws IllegalArgumentException, IllegalAccessException { @@ -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)) { @@ -119,7 +137,7 @@ public class ViewStyleTest } else { - Assert.fail("Unhandled field type (add to test): " + field.getName() + AssertJUnit.fail("Unhandled field type (add to test): " + field.getName() + ":" + type); } } @@ -147,7 +165,7 @@ public class ViewStyleTest * @throws IllegalAccessException * @throws IllegalArgumentException */ - @Test + @Test(groups ={ "Functional" }) public void testEquals() throws IllegalArgumentException, IllegalAccessException { @@ -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); }