Commit 0c2b3533 authored by Alinga Yeung's avatar Alinga Yeung
Browse files

Story 1657 rework. Updated test code to catch unexpected exceptions.

parent c2829de2
Loading
Loading
Loading
Loading
+22 −7
Original line number Diff line number Diff line
@@ -138,16 +138,23 @@ public class UserClientTest
    }
    
    @Test
    public void testSubjectWithNoPrincipal() throws URISyntaxException, MalformedURLException
    public void testSubjectWithNoPrincipal()
    {
    	try
    	{
	        // test subject augmentation given a subject with no principal
	    	Subject subject = new Subject();
	    	this.createUserClient().augmentSubject(subject);
	    	Assert.assertEquals("Should have no principal.", 0, subject.getPrincipals().size());
    	}
    	catch(Throwable t)
    	{
    		Assert.fail("Unexpected exception: " + t.getMessage());
    	}
    }
    
    @Test
    public void testSubjectWithMultiplePrincipal() throws URISyntaxException, MalformedURLException
    public void testSubjectWithMultiplePrincipal() 
    {
        try
        {
@@ -163,10 +170,14 @@ public class UserClientTest
            String expected = "Subject has more than one principal.";
            Assert.assertEquals(expected, e.getMessage());
        }
    	catch(Throwable t)
    	{
    		Assert.fail("Unexpected exception: " + t.getMessage());
    	}
    }
    
    @Test
    public void testSubjectWithUnsupportedPrincipal() throws URISyntaxException, MalformedURLException
    public void testSubjectWithUnsupportedPrincipal() 
    {
    	Principal principal = new JMXPrincipal("APIName");
        try
@@ -182,6 +193,10 @@ public class UserClientTest
            String expected = "Subject has unsupported principal " + principal.getName();
            Assert.assertEquals(expected, e.getMessage());
        }
    	catch(Throwable t)
    	{
    		Assert.fail("Unexpected exception: " + t.getMessage());
    	}
    }
   
    protected UserClient createUserClient() throws URISyntaxException, MalformedURLException