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

PolicyAssertionTest

public class PolicyAssertionTest extends AbstractPolicyApiClassTestBase
author
Marek Potociar (marek.potociar@sun.com)

Fields Summary
Constructors Summary
public PolicyAssertionTest(String testName)

        super(testName);
    
Methods Summary
protected PolicyAssertion[][]getEqualInstanceRows()

        Collection<PolicyAssertion[]> rows = new LinkedList<PolicyAssertion[]>();
        
        for (String name : PolicyResourceLoader.SINGLE_ALTERNATIVE_POLICY) {
            Iterator<AssertionSet> setsA = PolicyResourceLoader.loadPolicy(name).iterator();
            Iterator<AssertionSet> setsB = PolicyResourceLoader.loadPolicy(name).iterator();
            
            if (setsA.hasNext()) {
                AssertionSet setA = setsA.next();
                AssertionSet setB = setsB.next();
                
                Iterator<PolicyAssertion> assertionsA = setA.iterator();
                Iterator<PolicyAssertion> assertionsB = setB.iterator();
                
                while (assertionsA.hasNext()) {
                    rows.add(new PolicyAssertion[] {assertionsA.next(), assertionsB.next()});
                }
            }            
        }
        
        return rows.toArray(new PolicyAssertion[rows.size()][]);
    
protected voidsetUp()

    
protected voidtearDown()

    
public voidtestGetAttributesValueReturnsProperValue()

        QName headerParameterName = new QName("http://schemas.xmlsoap.org/ws/2005/07/securitypolicy", "Header");
        QName nameAttributeName = new QName("Name");
        QName namespaceAttributeName = new QName("Namespace");
        
        Policy policy = PolicyResourceLoader.loadPolicy("bug_reproduction/securityPolicy1.xml");
        AssertionSet alternative = policy.iterator().next();
        PolicyAssertion signedParts = alternative.get(new QName("http://schemas.xmlsoap.org/ws/2005/07/securitypolicy", "SignedParts")).iterator().next();
        Iterator<PolicyAssertion> iterator = signedParts.getNestedAssertionsIterator();
        while (iterator.hasNext()) {
            PolicyAssertion assertion = iterator.next();
            if (assertion.getName().equals(headerParameterName)) {
                System.out.println(assertion.toString());
                String nameValue = assertion.getAttributeValue(nameAttributeName);
                String namespaceValue = assertion.getAttributeValue(namespaceAttributeName);
                System.out.println();
                System.out.println("Name value: '" + nameValue + "'");
                System.out.println("Namespace value: '" + namespaceValue + "'");
                System.out.println("==========================================");
                assertNotNull("'Name' attribute of 'Header' parameter is expected to be not null.", nameValue);
                assertNotNull("'Namespace' attribute of 'Header' parameter is expected to be not null.", namespaceValue);
            }           
        }