*/
package jalview.datamodel;
-import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertNull;
+//import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
}
@Test(groups = { "Functional" })
- public void test()
+ public void testEquals()
{
- try
- {
+ PDBEntry pdbEntry = new PDBEntry("1xyz", "A", PDBEntry.Type.PDB,
+ "x/y/z/File");
- PDBEntry pdbEntry = new PDBEntry("1xyz", "A", PDBEntry.Type.PDB,
- "x/y/z/File");
+ PDBEntry case1 = new PDBEntry("1XYZ", "A", PDBEntry.Type.PDB,
+ "x/y/z/File");
+ PDBEntry case2 = new PDBEntry("1xyz", "a", PDBEntry.Type.PDB,
+ "x/y/z/File");
+ PDBEntry case3 = new PDBEntry("1xyz", "A", PDBEntry.Type.FILE,
+ "x/y/z/File");
+ PDBEntry case4 = new PDBEntry(null, null, null, null);
+ PDBEntry case5 = new PDBEntry(null, "A", PDBEntry.Type.PDB,
+ "x/y/z/File");
+ PDBEntry case6 = new PDBEntry("1xyz", null, PDBEntry.Type.PDB,
+ "x/y/z/File");
+ PDBEntry case7 = new PDBEntry("1xyz", "A", null, "x/y/z/File");
+ PDBEntry case8 = new PDBEntry("1xyz", "A", PDBEntry.Type.PDB, null);
+ PDBEntry case9 = new PDBEntry("1xyz", "A", null, "x/y/z/File");
- PDBEntry case1 = new PDBEntry("1XYZ", "A", PDBEntry.Type.PDB,
- "x/y/z/File");
- PDBEntry case2 = new PDBEntry("1xyz", "a", PDBEntry.Type.PDB,
- "x/y/z/File");
- PDBEntry case3 = new PDBEntry("1xyz", "A", PDBEntry.Type.FILE,
- "x/y/z/File");
- PDBEntry case4 = new PDBEntry(null, null, null, null);
- PDBEntry case5 = new PDBEntry(null, "A", PDBEntry.Type.PDB,
- "x/y/z/File");
- PDBEntry case6 = new PDBEntry("1xyz", null, PDBEntry.Type.PDB,
- "x/y/z/File");
- PDBEntry case7 = new PDBEntry("1xyz", "A", null, "x/y/z/File");
- PDBEntry case8 = new PDBEntry("1xyz", "A", PDBEntry.Type.PDB, null);
- PDBEntry case9 = new PDBEntry("1xyz", "A", null, "x/y/z/File");
-
- // System.out.println(">>>> Testing case 1");
- assertTrue(pdbEntry.equals(case1));
- // System.out.println(">>>> Testing case 2");
- assertTrue(pdbEntry.equals(case2));
- // System.out.println(">>>> Testing case 3");
- assertTrue(!pdbEntry.equals(case3));
- // System.out.println(">>>> Testing case 4");
- assertTrue(!pdbEntry.equals(case4));
- // System.out.println(">>>> Testing case 5");
- assertTrue(!pdbEntry.equals(case5));
- // System.out.println(">>>> Testing case 6");
- assertTrue(!pdbEntry.equals(case6));
- // System.out.println(">>>> Testing case 7");
- assertTrue(!pdbEntry.equals(case7));
- // System.out.println(">>>> Testing case 8");
- assertTrue(pdbEntry.equals(case8));
- assertTrue(pdbEntry.equals(case8));
- assertTrue(case7.equals(case9));
- } catch (Exception e)
- {
- e.printStackTrace();
- }
+ /*
+ * assertions will invoke PDBEntry.equals()
+ */
+ assertFalse(pdbEntry.equals(null));
+ assertFalse(pdbEntry.equals("a"));
+ assertEquals(case1, pdbEntry);
+ assertEquals(case2, pdbEntry);
+ assertNotEquals(case3, pdbEntry);
+ assertNotEquals(case4, pdbEntry);
+ assertNotEquals(case5, pdbEntry);
+ assertNotEquals(case6, pdbEntry);
+ assertNotEquals(case7, pdbEntry);
+ assertEquals(case8, pdbEntry);
+ assertEquals(case7, case9);
+ /*
+ * change string wrapper property to string...
+ */
+ case1.getProperty().put("chain_code", "a");
+ assertFalse(pdbEntry.equals(case1));
+ assertFalse(case1.equals(pdbEntry));
}
+ @Test(groups = { "Functional" })
+ public void testSetChainCode()
+ {
+ PDBEntry pdbEntry = new PDBEntry("1xyz", null, PDBEntry.Type.PDB,
+ "x/y/z/File");
+ assertNull(pdbEntry.getChainCode());
+
+ pdbEntry.setChainCode("a");
+ assertEquals("a", pdbEntry.getChainCode());
+
+ pdbEntry.setChainCode(null);
+ assertNull(pdbEntry.getChainCode());
+ }
}
--- /dev/null
+package jalview.util;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Test;
+
+public class CaseInsensitiveStringTest
+{
+ @Test(groups = "Functional")
+ public void testEquals()
+ {
+ CaseInsensitiveString s1 = new CaseInsensitiveString(null);
+ CaseInsensitiveString s2 = new CaseInsensitiveString("a");
+ CaseInsensitiveString s3 = new CaseInsensitiveString("A");
+ CaseInsensitiveString s4 = new CaseInsensitiveString("b");
+
+ assertFalse(s1.equals(null));
+ assertTrue(s1.equals(s1));
+ assertFalse(s1.equals(s2));
+ assertTrue(s2.equals(s2));
+ assertFalse(s2.equals(s1));
+ assertTrue(s2.equals(s3));
+ assertTrue(s3.equals(s2));
+ assertFalse(s3.equals(s4));
+ assertFalse(s4.equals(s3));
+ }
+
+ @Test(groups = "Functional")
+ public void testHashcode()
+ {
+ CaseInsensitiveString s1 = new CaseInsensitiveString(null);
+ CaseInsensitiveString s2 = new CaseInsensitiveString("a");
+ CaseInsensitiveString s3 = new CaseInsensitiveString("A");
+ CaseInsensitiveString s4 = new CaseInsensitiveString("b");
+
+ assertNotEquals(s1.hashCode(), s2.hashCode());
+ assertEquals(s2.hashCode(), s3.hashCode());
+ assertNotEquals(s3.hashCode(), s4.hashCode());
+ }
+}