Methods Summary |
---|
private java.io.Reader | getResourceReader(java.lang.String resourceName)
return new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName));
|
public boolean | hasXPathTarget(java.lang.String xpathExpr, java.util.Iterator itr)
while(itr.hasNext()){
if(xpathExpr.equals(itr.next())){
return true;
}
}
return false;
|
protected void | setUp()
|
public static junit.framework.Test | suite()
TestSuite suite = new TestSuite(SignedElementsTest.class);
return suite;
|
protected void | tearDown()
|
public void | testSignElements1()
String fileName = "security/SignElements1.xml";
Policy policy = unmarshalPolicy(fileName);
assertNotNull(policy);
Iterator <AssertionSet> itr = policy.iterator();
if(itr.hasNext()){
AssertionSet as = itr.next();
for(PolicyAssertion assertion : as){
assertEquals("Invalid assertion","SignedElements",assertion.getName().getLocalPart());
SignedElements se = (SignedElements)assertion;
assertTrue(hasXPathTarget("//soapEnv:Body",se.getTargets()));
assertTrue(hasXPathTarget("//addr:To",se.getTargets()));
assertTrue(hasXPathTarget("//addr:From",se.getTargets()));
assertTrue(hasXPathTarget("//addr:RealtesTo",se.getTargets()));
// assertFalse("Headers should not be present",se.getHeaders().hasNext());
}
}else{
throw new Exception("No Assertions found!. Unmarshalling of "+fileName+"failed!");
}
|
public void | testSignElements2()
String fileName = "security/SignElements2.xml";
Policy policy = unmarshalPolicy(fileName);
assertNotNull(policy);
Iterator <AssertionSet> itr = policy.iterator();
if(itr.hasNext()){
AssertionSet as = itr.next();
for(PolicyAssertion assertion : as){
assertEquals("Invalid assertion","SignedElements",assertion.getName().getLocalPart());
SignedElements se = (SignedElements)assertion;
assertFalse(se.getTargets().hasNext());
// assertFalse("Headers should not be present",se.getHeaders().hasNext());
}
}else{
throw new Exception("No Assertions found!. Unmarshalling of "+fileName+"failed!");
}
|
public com.sun.xml.ws.policy.Policy | unmarshalPolicy(java.lang.String xmlFile)
PolicySourceModel model = unmarshalPolicyResource(
xmlFile);
Policy mbp = PolicyModelTranslator.getTranslator().translate(model);
return mbp;
|
private com.sun.xml.ws.policy.sourcemodel.PolicySourceModel | unmarshalPolicyResource(java.lang.String resource)
Reader reader = getResourceReader(resource);
PolicySourceModel model = PolicyModelUnmarshaller.getXmlUnmarshaller().unmarshalModel(reader);
reader.close();
return model;
|