Code example for X500Principal

Methods: getName

0
    public void test_ConstructorLjava_lang_String_java_util_Map(){ 
        Map<String, String> keyword = new HashMap<String, String>();
        keyword.put("CN", "2.19");
        keyword.put("OU", "1.2.5.19");
        keyword.put("O", "1.2.5");
        X500Principal X500p = new X500Principal("CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US ,CN=DD",keyword);
        String name = X500p.getName();
        String expectedOut = "2.19=#130444756b65,1.2.5.19=#13084a617661536f6674,1.2.5=#131053756e204d6963726f73797374656d73,C=US,2.19=#13024444";
        assertEquals("Output order precedence problem", expectedOut, name);
    } 
 
	/** 
	 * @tests javax.security.auth.x500.X500Principal#getName(java.lang.String) 
	 */ 
	public void test_getNameLjava_lang_String() { 
		X500Principal principal = new X500Principal(
				"CN=Dumbledore, OU=Administration, O=Hogwarts School, C=GB"); 
		String canonical = principal.getName(X500Principal.CANONICAL);
		String expected = "cn=dumbledore,ou=administration,o=hogwarts school,c=gb";
		assertEquals("CANONICAL output differs from expected result", expected,
				canonical);