EffectiveAlternativeSelectorTestpublic class EffectiveAlternativeSelectorTest extends TestCase
Fields Summary |
---|
private static final com.sun.xml.ws.policy.sourcemodel.PolicyModelUnmarshaller | xmlUnmarshaller |
Constructors Summary |
---|
public EffectiveAlternativeSelectorTest(String testName)
super(testName);
|
Methods Summary |
---|
public static junit.framework.Test | suite()
TestSuite suite = new TestSuite(EffectiveAlternativeSelectorTest.class);
return suite;
| public void | testDoEmptySelection()
HashSet<PolicyMapMutator> mutators = new HashSet<PolicyMapMutator>();
EffectivePolicyModifier modifier = EffectivePolicyModifier.createEffectivePolicyModifier();
mutators.add(modifier);
PolicyMapExtender extender = PolicyMapExtender.createPolicyMapExtender();
mutators.add(extender);
PolicyMap policyMap = PolicyMap.createPolicyMap(mutators);
Policy emptyPolicy = Policy.createEmptyPolicy();
PolicyMapKey key = PolicyMap.createWsdlEndpointScopeKey(new QName("service"), new QName("port"));
extender.putEndpointSubject(key, new PolicySubject("two", emptyPolicy));
EffectiveAlternativeSelector.doSelection(modifier);
assertTrue(extender.getMap().getEndpointEffectivePolicy(key).isEmpty());
| public void | testDoNegativeSelection()
HashSet<PolicyMapMutator> mutators = new HashSet<PolicyMapMutator>();
EffectivePolicyModifier myModifier = EffectivePolicyModifier.createEffectivePolicyModifier();
mutators.add(myModifier);
PolicyMapExtender myExtender = PolicyMapExtender.createPolicyMapExtender();
mutators.add(myExtender);
PolicyMap policyMap = PolicyMap.createPolicyMap(mutators);
//Policy pol1 = PolicyModelTranslator.getTranslator()
// .translate(unmarshalModel("single_alternative_policy/policy3.xml"));
Policy pol2 = loadPolicy("complex_policy/nested_assertions_with_alternatives.xml");
PolicyMapKey aKey = PolicyMap.createWsdlEndpointScopeKey(new QName("service"),new QName("port"));
//myExtender.putEndpointSubject(aKey,new PolicySubject("one",pol1));
myExtender.putEndpointSubject(aKey,new PolicySubject("two",pol2));
//System.out.println(myExtender.getMap());
if(2>myExtender.getMap().getEndpointEffectivePolicy(aKey).getNumberOfAssertionSets()) {
fail("Insufficient number of alternatives found. At least 2 of them needed.");
};
EffectiveAlternativeSelector.doSelection(myModifier);
if(1!=myExtender.getMap().getEndpointEffectivePolicy(aKey).getNumberOfAssertionSets()) {
fail("Too many alternatives has left.");
}
EffectiveAlternativeSelector.doSelection(myModifier);
if(1!=myExtender.getMap().getEndpointEffectivePolicy(aKey).getNumberOfAssertionSets()) {
fail("Too many alternatives has left.");
}
| public void | testDoNullSelection()
HashSet<PolicyMapMutator> mutators = new HashSet<PolicyMapMutator>();
EffectivePolicyModifier modifier = EffectivePolicyModifier.createEffectivePolicyModifier();
mutators.add(modifier);
PolicyMapExtender extender = PolicyMapExtender.createPolicyMapExtender();
mutators.add(extender);
PolicyMap policyMap = PolicyMap.createPolicyMap(mutators);
Policy nullPolicy = Policy.createNullPolicy();
PolicyMapKey key = PolicyMap.createWsdlEndpointScopeKey(new QName("service"), new QName("port"));
extender.putEndpointSubject(key, new PolicySubject("two", nullPolicy));
EffectiveAlternativeSelector.doSelection(modifier);
assertTrue(extender.getMap().getEndpointEffectivePolicy(key).isNull());
| public void | testDoPositiveSelection()Test of doSelection method, of class com.sun.xml.ws.policy.EffectiveAlternativeSelector.
HashSet<PolicyMapMutator> mutators = new HashSet<PolicyMapMutator>();
EffectivePolicyModifier myModifier = EffectivePolicyModifier.createEffectivePolicyModifier();
mutators.add(myModifier);
PolicyMapExtender myExtender = PolicyMapExtender.createPolicyMapExtender();
mutators.add(myExtender);
PolicyMap policyMap = PolicyMap.createPolicyMap(mutators);
//Policy pol1 = PolicyModelTranslator.getTranslator()
// .translate(unmarshalModel("single_alternative_policy/policy3.xml"));
Policy pol2 = loadPolicy("complex_policy/nested_assertions_with_alternatives.xml");
PolicyMapKey aKey = PolicyMap.createWsdlEndpointScopeKey(new QName("service"),new QName("port"));
//myExtender.putEndpointSubject(aKey,new PolicySubject("one",pol1));
myExtender.putEndpointSubject(aKey,new PolicySubject("two",pol2));
//System.out.println(myExtender.getMap());
if(2>myExtender.getMap().getEndpointEffectivePolicy(aKey).getNumberOfAssertionSets()) {
fail("Insufficient number of alternatives found. At least 2 of them needed.");
};
EffectiveAlternativeSelector.doSelection(myModifier);
if(1!=myExtender.getMap().getEndpointEffectivePolicy(aKey).getNumberOfAssertionSets()) {
fail("Too many alternatives has left.");
}
|
|