PolicyMapTestpublic class PolicyMapTest extends TestCase
Constructors Summary |
---|
public PolicyMapTest(String testName)
super(testName);
|
Methods Summary |
---|
protected void | setUp()
| protected void | tearDown()
| public void | testCreatePolicyMapWithEmptyMutatorCollection()
assertNotNull("Policy map instance should not be null", PolicyMap.createPolicyMap(new LinkedList<PolicyMapMutator>()));
| public void | testCreatePolicyMapWithNonemptyMutatorCollection()
assertNotNull("Policy map instance should not be null", PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] {PolicyMapExtender.createPolicyMapExtender()})));
| public void | testCreatePolicyMapWithNullMutatorCollection()
assertNotNull("Policy map instance should not be null", PolicyMap.createPolicyMap(null));
| public void | testGetFaultMessageEffectivePolicy()
PolicyMap policyMap = PolicyConfigParser.parse(getResourceUrl("effective/all.wsdl"), false);
Policy expectedPolicy = loadPolicy("effective/resultFault.xml");
PolicyMapKey policyMapKey = policyMap.createWsdlFaultMessageScopeKey(new QName("http://example.org/","Service"),new QName("http://example.org/","Port"),new QName("http://example.org/","Operation"),new QName("http://example.org/","Fault"));
Policy policy = policyMap.getFaultMessageEffectivePolicy(policyMapKey);
assertEquals(expectedPolicy, policy);
| public void | testGetFaultMessageWithTwoServicesEffectivePolicy()
PolicyMap policyMap = PolicyConfigParser.parse(getResourceUrl("effective/twoservices.wsdl"), false);
Policy expectedPolicy = loadPolicy("effective/resultFault.xml");
PolicyMapKey policyMapKey = policyMap.createWsdlFaultMessageScopeKey(new QName("http://example.org/","Service"),new QName("http://example.org/","Port"),new QName("http://example.org/","Operation"),new QName("http://example.org/","Fault"));
Policy policy = policyMap.getFaultMessageEffectivePolicy(policyMapKey);
assertEquals(expectedPolicy, policy);
| public void | testGetInputMessageEffectivePolicy()
PolicyMap policyMap = PolicyConfigParser.parse(getResourceUrl("effective/all.wsdl"), false);
Policy expectedPolicy = loadPolicy("effective/resultInput.xml");
PolicyMapKey policyMapKey = policyMap.createWsdlMessageScopeKey(new QName("http://example.org/","Service"),new QName("http://example.org/","Port"),new QName("http://example.org/","Operation"));
Policy policy = policyMap.getInputMessageEffectivePolicy(policyMapKey);
assertEquals(expectedPolicy, policy);
| public void | testGetOperationEffectivePolicy()
PolicyMap policyMap = PolicyConfigParser.parse(getResourceUrl("effective/all.wsdl"), false);
Policy expectedPolicy = loadPolicy("effective/resultOperation.xml");
PolicyMapKey policyMapKey = policyMap.createWsdlOperationScopeKey(new QName("http://example.org/","Service"),new QName("http://example.org/","Port"),new QName("http://example.org/","Operation"));
Policy policy = policyMap.getOperationEffectivePolicy(policyMapKey);
assertEquals(expectedPolicy, policy);
| public void | testIsEmpty()
PolicyMap map = PolicyMap.createPolicyMap(null);
assertTrue(map.isEmpty());
map = PolicyMap.createPolicyMap(new LinkedList<PolicyMapMutator>());
assertTrue(map.isEmpty());
map = PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] {PolicyMapExtender.createPolicyMapExtender()}));
assertTrue(map.isEmpty());
PolicyMapExtender extender = PolicyMapExtender.createPolicyMapExtender();
PolicyMapMutator[] mutators = new PolicyMapMutator[] {extender};
PolicyMapKey key = map.createWsdlServiceScopeKey(new QName("service"));
map = PolicyMap.createPolicyMap(Arrays.asList(mutators));
extender.putServiceSubject(key, null);
assertFalse(map.isEmpty());
mutators[0].disconnect();
key = map.createWsdlEndpointScopeKey(new QName("service"), new QName("port"));
map = PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] {extender}));
extender.putEndpointSubject(key, null);
assertFalse(map.isEmpty());
mutators[0].disconnect();
key = map.createWsdlOperationScopeKey(new QName("service"), new QName("port"), new QName("operation"));
map = PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] {extender}));
extender.putOperationSubject(key, null);
assertFalse(map.isEmpty());
mutators[0].disconnect();
key = map.createWsdlMessageScopeKey(new QName("service"), new QName("port"), new QName("operation"));
map = PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] {extender}));
extender.putInputMessageSubject(key, null);
assertFalse(map.isEmpty());
mutators[0].disconnect();
key = map.createWsdlMessageScopeKey(new QName("service"), new QName("port"), new QName("operation"));
map = PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] {extender}));
extender.putOutputMessageSubject(key, null);
assertFalse(map.isEmpty());
mutators[0].disconnect();
key = map.createWsdlMessageScopeKey(new QName("service"), new QName("port"), new QName("operation"));
map = PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] {extender}));
extender.putFaultMessageSubject(key, null);
assertFalse(map.isEmpty());
| public void | testPolicyMapIterator()
PolicyMapExtender extender = PolicyMapExtender.createPolicyMapExtender();
PolicyMap map = PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] {extender}));
PolicySubject subject = new PolicySubject("dummy", Policy.createEmptyPolicy());
PolicyMapKey key = map.createWsdlServiceScopeKey(new QName("1"));
extender.putServiceSubject(key, subject);
key = map.createWsdlServiceScopeKey(new QName("2"));
extender.putServiceSubject(key, subject);
key = map.createWsdlEndpointScopeKey(new QName("3"), new QName("port"));
extender.putEndpointSubject(key, subject);
key = map.createWsdlEndpointScopeKey(new QName("4"), new QName("port"));
extender.putEndpointSubject(key, subject);
key = map.createWsdlEndpointScopeKey(new QName("5"), new QName("port"));
extender.putEndpointSubject(key, subject);
key = map.createWsdlMessageScopeKey(new QName("6"), new QName("port"), new QName("operation"));
extender.putInputMessageSubject(key, subject);
key = map.createWsdlMessageScopeKey(new QName("7"), new QName("port"), new QName("operation"));
extender.putOutputMessageSubject(key, subject);
key = map.createWsdlMessageScopeKey(new QName("8"), new QName("port"), new QName("operation"));
extender.putFaultMessageSubject(key, subject);
int counter = 0;
for (Policy policy : map) {
counter++;
}
assertEquals("Did not iterate over expected number of policies.", 8, counter);
| public void | testToString()
PolicyMap policyMap = getPolicyMap("bug_reproduction/simple.wsdl");
String result = policyMap.toString();
assertNotNull(result);
|
|