Java Code Examples for javax.security.auth.x500.X500Principal#hashCode()
The following examples show how to use
javax.security.auth.x500.X500Principal#hashCode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: X500PrincipalTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * javax.security.auth.x500.X500Principal#hashCode() */ public void test_hashCode() { String name = "CN=Duke,OU=JavaSoft,O=Sun Microsystems,C=US"; X500Principal xpr = new X500Principal(name); try { int res = xpr.hashCode(); assertNotNull(res); } catch (Exception e) { fail("Unexpected exception: " + e); } }
Example 2
Source File: X500PrincipalTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * Inits X500Principal with byte array * gets hashCode * compares with expected value */ public void testHashCode() throws Exception { byte[] mess = { 0x30, 0x18, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x42, 0x31, 0x0A, 0x30, 0x08, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x41 }; X500Principal principal = new X500Principal(mess); int hash = principal.hashCode(); assertEquals(principal.getName(X500Principal.CANONICAL).hashCode(), hash); }
Example 3
Source File: Equals.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 4
Source File: Equals.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 5
Source File: Equals.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 6
Source File: Equals.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 7
Source File: Equals.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 8
Source File: Equals.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 9
Source File: Equals.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 10
Source File: Equals.java From hottub with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 11
Source File: Equals.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 12
Source File: Equals.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 13
Source File: Equals.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 14
Source File: Equals.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }
Example 15
Source File: Equals.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { // test regular equals X500Principal p1 = new X500Principal(p1String); X500Principal p2 = new X500Principal(p2String); printName("Principal 1:", p1String, p1); printName("Principal 2:", p2String, p2); if (!p1.equals(p2)) throw new SecurityException("Equals test failed: #1"); X500Principal notEqual = new X500Principal("cn=test2"); if (p1.equals(notEqual)) throw new SecurityException("Equals test failed: #2"); if (p1.equals(null)) throw new SecurityException("Equals test failed: #3"); if (p1.hashCode() != p2.hashCode()) throw new SecurityException("Equals test failed: #4"); // test multiple AVA's in an RDN X500Principal p3 = new X500Principal(p3String); X500Principal p4 = new X500Principal(p4String); printName("Principal 3:", p3String, p3); printName("Principal 4:", p4String, p4); if (!p3.equals(p4)) throw new SecurityException("Equals test failed: #5"); if (p1.equals(p3) || p2.equals(p3)) throw new SecurityException("Equals test failed: #6"); if (p3.hashCode() != p4.hashCode()) throw new SecurityException("Equals test failed: #7"); X500Principal p5 = new X500Principal(p5String); X500Principal p6 = new X500Principal(p6String); printName("Principal 5:", p5String, p5); printName("Principal 6:", p6String, p6); if (!p5.equals(p6)) throw new SecurityException("Equals test failed: #8"); if (p5.hashCode() != p6.hashCode()) throw new SecurityException("Equals test failed: #9"); X500Principal p7 = new X500Principal(p7String); X500Principal p8 = new X500Principal(p8String); printName("Principal 7:", p7String, p7); printName("Principal 8:", p8String, p8); if (!p7.equals(p8)) throw new SecurityException("Equals test failed: #10"); if (p7.hashCode() != p8.hashCode()) throw new SecurityException("Equals test failed: #11"); System.out.println("Equals test passed"); }