1 18 package org.apache.activemq.jaas; 19 20 import org.apache.activemq.jaas.UserPrincipal; 21 22 import junit.framework.TestCase; 23 24 25 28 public class UserPrincipalTest extends TestCase { 29 30 public void testArguments() { 31 UserPrincipal principal = new UserPrincipal("FOO"); 32 33 assertEquals("FOO", principal.getName()); 34 35 try { 36 new UserPrincipal(null); 37 fail("Should have thrown IllegalArgumentException"); 38 } catch (IllegalArgumentException ingore) { 39 40 } 41 } 42 43 public void testHash() { 44 UserPrincipal p1 = new UserPrincipal("FOO"); 45 UserPrincipal p2 = new UserPrincipal("FOO"); 46 47 assertEquals(p1.hashCode(), p1.hashCode()); 48 assertEquals(p1.hashCode(), p2.hashCode()); 49 } 50 51 public void testEquals() { 52 UserPrincipal p1 = new UserPrincipal("FOO"); 53 UserPrincipal p2 = new UserPrincipal("FOO"); 54 UserPrincipal p3 = new UserPrincipal("BAR"); 55 56 assertTrue(p1.equals(p1)); 57 assertTrue(p1.equals(p2)); 58 assertFalse(p1.equals(null)); 59 assertFalse(p1.equals("FOO")); 60 assertFalse(p1.equals(p3)); 61 } 62 } 63 | Popular Tags |