FileDocCategorySizeDatePackage
PolicySubjectTest.javaAPI DocExample5655Tue May 29 16:57:36 BST 2007com.sun.xml.ws.policy

PolicySubjectTest

public class PolicySubjectTest extends TestCase
author
Marek Potociar (marek.potociar@sun.com)

Fields Summary
private Object
subject
private PolicyMerger
merger
Constructors Summary
public PolicySubjectTest(String testName)

    
       
        super(testName);
    
Methods Summary
protected voidsetUp()

    
protected voidtearDown()

    
public voidtestAttachingNoPolicyToAnyPolicyResultsInNoEffectivePolicy()

        PolicySubject ps = new PolicySubject(subject, Policy.createEmptyPolicy());        
        Policy noPolicy = Policy.createNullPolicy();
        ps.attach(noPolicy);
        
        assertEquals(noPolicy, ps.getEffectivePolicy(merger));
    
public voidtestAttachingNullPolicyThrowsIAE()

        PolicySubject ps = new PolicySubject(subject, Policy.createNullPolicy());        
        try {
        ps.attach(null);
        fail("Attaching a 'null' policy to the policyt subject must throw IllegalArgumentException");
        } catch (IllegalArgumentException e) {
            // ok.
        }
    
public voidtestCreatePolicySubjectWithEmptyPolicyCollectionMustThrowIAE()

        try {
            Collection<Policy> c = new ArrayList<Policy>();
            new PolicySubject(subject, c);
            fail ("PolicySubject creation must throw IllegalArgumentException on empty policy collection");
        } catch (IllegalArgumentException e) {
            // ok.
        }        
    
public voidtestCreatePolicySubjectWithNullPolicyCollcetionMustThrowIAE()

        try {
            Collection<Policy> c = null;
            new PolicySubject(subject, c);
            fail ("PolicySubject creation must throw IllegalArgumentException on 'null' policy collection");
        } catch (IllegalArgumentException e) {
            // ok.
        }        
    
public voidtestCreatePolicySubjectWithNullPolicyMustThrowIAE()

        try {
            Policy p = null;
            new PolicySubject(subject, p);
            fail ("PolicySubject creation must throw IllegalArgumentException on 'null' policy");
        } catch (IllegalArgumentException e) {
            // ok.
        }        
    
public voidtestCreatePolicySubjectWithNullSubjectMustThrowIAE()

        try {
            new PolicySubject(null, Policy.createNullPolicy());
            fail ("PolicySubject creation must throw IllegalArgumentException on 'null' subject");
        } catch (IllegalArgumentException e) {
            // ok.
        }
    
public voidtestGetSubjectReturnsCorrectReference()

        StringBuffer subject = new StringBuffer('a");
        PolicySubject ps = new PolicySubject(subject, Policy.createNullPolicy());
        subject.append('b");
        assertEquals("Subject used in constructor must equal to subject returned from getter.", subject, ps.getSubject());
    
public voidtestGetSubjectReturnsCorrectSubject()

        PolicySubject ps = new PolicySubject(subject, Policy.createNullPolicy());
        assertEquals("Subject used in constructor must equal to subject returned from getter.", subject, ps.getSubject());