FileDocCategorySizeDatePackage
TransportBindingTest.javaAPI DocExample5738Tue May 29 16:57:42 BST 2007com.sun.xml.ws.security.impl.policy

TransportBindingTest

public class TransportBindingTest extends TestCase
author
mayank

Fields Summary
Constructors Summary
public TransportBindingTest(String testName)

        super(testName);
    
Methods Summary
private java.io.ReadergetResourceReader(java.lang.String resourceName)

        return new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName));
    
protected voidsetUp()

    
public static junit.framework.Testsuite()

        TestSuite suite = new TestSuite(TransportBindingTest.class);
        
        return suite;
    
protected voidtearDown()

    
public voidtestTransportBinding()

        String fileName="security/TransportBindingAssertions.xml";
        Policy policy = unmarshalPolicy(fileName);
        Iterator <AssertionSet> itr = policy.iterator();
        if(itr.hasNext()) {
            AssertionSet as = itr.next();
            for(PolicyAssertion assertion : as) {
                assertEquals("Invalid assertion", "TransportBinding",assertion.getName().getLocalPart());
                TransportBinding tb = (TransportBinding)assertion;
                
                AlgorithmSuite aSuite = tb.getAlgorithmSuite();
                assertEquals("Unmatched Algorithm",aSuite.getEncryptionAlgorithm(), AlgorithmSuiteValue.Basic128.getEncAlgorithm());
                
                assertTrue(tb.isIncludeTimeStamp());
                
                HttpsToken tkn = (HttpsToken)tb.getTransportToken();
                assertFalse("RequireClientCertificate should be false", tkn.isRequireClientCertificate());
            }
        }
    
public com.sun.xml.ws.policy.PolicyunmarshalPolicy(java.lang.String xmlFile)

        PolicySourceModel model =  unmarshalPolicyResource(
                xmlFile);
        Policy mbp = PolicyModelTranslator.getTranslator().translate(model);
        return mbp;
        
    
private com.sun.xml.ws.policy.sourcemodel.PolicySourceModelunmarshalPolicyResource(java.lang.String resource)

        Reader reader = getResourceReader(resource);
        PolicySourceModel model = PolicyModelUnmarshaller.getXmlUnmarshaller().unmarshalModel(reader);
        reader.close();
        return model;