Search in sources :

Example 1 with AssertionData

use of com.sun.xml.ws.policy.sourcemodel.AssertionData in project metro-jax-ws by eclipse-ee4j.

the class PolicyIntersectorTest method testIntersectStrict.

public void testIntersectStrict() {
    AssertionData data1 = AssertionData.createAssertionData(new QName("testns", "name1"));
    PolicyAssertion assertion1 = new MockAssertion(data1);
    AssertionData data2 = AssertionData.createAssertionData(new QName("testns", "name2"));
    PolicyAssertion assertion2 = new MockAssertion(data2);
    AssertionData data3 = AssertionData.createAssertionData(new QName("testns", "name3"));
    PolicyAssertion assertion3 = new MockAssertion(data3);
    LinkedList<PolicyAssertion> assertions1 = new LinkedList<PolicyAssertion>();
    assertions1.add(assertion1);
    assertions1.add(assertion2);
    assertions1.add(assertion3);
    AssertionSet set1 = AssertionSet.createAssertionSet(assertions1);
    LinkedList<AssertionSet> sets1 = new LinkedList<AssertionSet>();
    sets1.add(set1);
    Policy policy1 = Policy.createPolicy(null, "policy1", sets1);
    LinkedList<PolicyAssertion> assertions2 = new LinkedList<PolicyAssertion>();
    assertions2.add(assertion1);
    assertions2.add(assertion2);
    assertions2.add(assertion3);
    AssertionSet set2 = AssertionSet.createAssertionSet(assertions2);
    LinkedList<AssertionSet> sets2 = new LinkedList<AssertionSet>();
    sets2.add(set2);
    Policy policy2 = Policy.createPolicy(null, "policy2", sets2);
    Policy[] policies = new Policy[] { policy1, policy2 };
    LinkedList<PolicyAssertion> assertions3 = new LinkedList<PolicyAssertion>();
    assertions3.add(assertion1);
    assertions3.add(assertion2);
    assertions3.add(assertion3);
    AssertionSet set3 = AssertionSet.createAssertionSet(assertions3);
    LinkedList<AssertionSet> sets3 = new LinkedList<AssertionSet>();
    sets3.add(set3);
    Policy expResult = Policy.createPolicy(null, "policy3", sets3);
    PolicyIntersector instance = PolicyIntersector.createStrictPolicyIntersector();
    Policy result = instance.intersect(policies);
    assertEquals(expResult, result);
}
Also used : QName(javax.xml.namespace.QName) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData) LinkedList(java.util.LinkedList)

Example 2 with AssertionData

use of com.sun.xml.ws.policy.sourcemodel.AssertionData in project metro-jax-ws by eclipse-ee4j.

the class PolicyIntersectorTest method testIntersectOne.

public void testIntersectOne() {
    AssertionData data1 = AssertionData.createAssertionData(new QName("testns", "name1"));
    PolicyAssertion assertion1 = new MockAssertion(data1);
    AssertionData data2 = AssertionData.createAssertionData(new QName("testns", "name2"));
    PolicyAssertion assertion2 = new MockAssertion(data2);
    AssertionData data3 = AssertionData.createAssertionData(new QName("testns", "name3"));
    PolicyAssertion assertion3 = new MockAssertion(data3);
    LinkedList<PolicyAssertion> assertions1 = new LinkedList<PolicyAssertion>();
    assertions1.add(assertion1);
    assertions1.add(assertion2);
    assertions1.add(assertion3);
    AssertionSet set1 = AssertionSet.createAssertionSet(assertions1);
    LinkedList<AssertionSet> sets1 = new LinkedList<AssertionSet>();
    sets1.add(set1);
    Policy policy = Policy.createPolicy(null, "policy1", sets1);
    PolicyIntersector instance = PolicyIntersector.createStrictPolicyIntersector();
    Policy expResult = Policy.createPolicy(null, "expectedpolicy", sets1);
    Policy result = instance.intersect(policy);
    assertEquals(expResult, result);
}
Also used : QName(javax.xml.namespace.QName) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData) LinkedList(java.util.LinkedList)

Example 3 with AssertionData

use of com.sun.xml.ws.policy.sourcemodel.AssertionData in project metro-jax-ws by eclipse-ee4j.

the class PolicyMapUtilTest method testRejectAlternativesComplex.

public void testRejectAlternativesComplex() throws PolicyException {
    PolicySourceModel model = PolicySourceModel.createPolicySourceModel(NamespaceVersion.v1_5, "id", null);
    ModelNode root = model.getRootNode();
    ModelNode alternatives = root.createChildExactlyOneNode();
    ModelNode alternative1 = alternatives.createChildAllNode();
    ModelNode alternative2 = alternatives.createChildAllNode();
    AssertionData assertion1 = AssertionData.createAssertionData(new QName("test1", "test1"));
    alternative1.createChildAssertionNode(assertion1);
    AssertionData assertion2 = AssertionData.createAssertionData(new QName("test2", "test2"));
    alternative2.createChildAssertionNode(assertion2);
    PolicyModelTranslator translator = PolicyModelTranslator.getTranslator();
    Policy policy = translator.translate(model);
    PolicyMapExtender extender = PolicyMapExtender.createPolicyMapExtender();
    PolicyMap map = PolicyMap.createPolicyMap(Arrays.asList(new PolicyMapMutator[] { extender }));
    PolicySubject subject = new PolicySubject("dummy", policy);
    PolicyMapKey key = PolicyMap.createWsdlServiceScopeKey(new QName("1"));
    extender.putServiceSubject(key, subject);
    key = PolicyMap.createWsdlServiceScopeKey(new QName("2"));
    extender.putServiceSubject(key, subject);
    try {
        PolicyMapUtil.rejectAlternatives(map);
        fail("Expected a PolicyException");
    } catch (PolicyException e) {
    }
}
Also used : PolicySourceModel(com.sun.xml.ws.policy.sourcemodel.PolicySourceModel) QName(javax.xml.namespace.QName) PolicyModelTranslator(com.sun.xml.ws.policy.sourcemodel.PolicyModelTranslator) ModelNode(com.sun.xml.ws.policy.sourcemodel.ModelNode) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData)

Example 4 with AssertionData

use of com.sun.xml.ws.policy.sourcemodel.AssertionData in project metro-jax-ws by eclipse-ee4j.

the class PolicyMergerTest method testMergePolicyNamespace.

/**
 * Test of merge method, of class PolicyMerger.
 */
public void testMergePolicyNamespace() {
    AssertionData assertionData1 = AssertionData.createAssertionData(new QName("http://example.test/", "Assertion1"));
    PolicyAssertion assertion1 = new PolicyAssertion(assertionData1, null) {
    };
    Collection<PolicyAssertion> assertions1 = new LinkedList<PolicyAssertion>();
    assertions1.add(assertion1);
    AssertionSet assertionSet1 = AssertionSet.createAssertionSet(assertions1);
    Collection<AssertionSet> assertionSets1 = new LinkedList<AssertionSet>();
    assertionSets1.add(assertionSet1);
    Policy policy1 = Policy.createPolicy(NamespaceVersion.v1_2, null, null, assertionSets1);
    AssertionData assertionData2 = AssertionData.createAssertionData(new QName("http://example.test/", "Assertion2"));
    PolicyAssertion assertion2 = new PolicyAssertion(assertionData2, null) {
    };
    Collection<PolicyAssertion> assertions2 = new LinkedList<PolicyAssertion>();
    assertions2.add(assertion2);
    AssertionSet assertionSet2 = AssertionSet.createAssertionSet(assertions2);
    Collection<AssertionSet> assertionSets2 = new LinkedList<AssertionSet>();
    assertionSets2.add(assertionSet2);
    Policy policy2 = Policy.createPolicy(NamespaceVersion.v1_5, null, null, assertionSets2);
    final Collection<Policy> policies = new LinkedList<Policy>();
    policies.add(policy1);
    policies.add(policy2);
    Collection<PolicyAssertion> assertionsExp = new LinkedList<PolicyAssertion>();
    assertionsExp.add(assertion1);
    assertionsExp.add(assertion2);
    AssertionSet assertionSetExp = AssertionSet.createAssertionSet(assertionsExp);
    Collection<AssertionSet> assertionSetsExp = new LinkedList<AssertionSet>();
    assertionSetsExp.add(assertionSetExp);
    Policy expResult = Policy.createPolicy(assertionSetsExp);
    final PolicyMerger instance = PolicyMerger.getMerger();
    final Policy result = instance.merge(policies);
    assertEquals(expResult, result);
}
Also used : QName(javax.xml.namespace.QName) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData) LinkedList(java.util.LinkedList)

Example 5 with AssertionData

use of com.sun.xml.ws.policy.sourcemodel.AssertionData in project metro-jax-ws by eclipse-ee4j.

the class PolicyMergerTest method testMergeId.

/**
 * Test of merge method, of class PolicyMerger.
 */
public void testMergeId() {
    AssertionData assertionData1 = AssertionData.createAssertionData(new QName("http://example.test/", "Assertion1"));
    PolicyAssertion assertion1 = new PolicyAssertion(assertionData1, null) {
    };
    Collection<PolicyAssertion> assertions1 = new LinkedList<PolicyAssertion>();
    assertions1.add(assertion1);
    AssertionSet assertionSet1 = AssertionSet.createAssertionSet(assertions1);
    Collection<AssertionSet> assertionSets1 = new LinkedList<AssertionSet>();
    assertionSets1.add(assertionSet1);
    Policy policy1 = Policy.createPolicy(null, "id1", assertionSets1);
    AssertionData assertionData2 = AssertionData.createAssertionData(new QName("http://example.test/", "Assertion2"));
    PolicyAssertion assertion2 = new PolicyAssertion(assertionData2, null) {
    };
    Collection<PolicyAssertion> assertions2 = new LinkedList<PolicyAssertion>();
    assertions2.add(assertion2);
    AssertionSet assertionSet2 = AssertionSet.createAssertionSet(assertions2);
    Collection<AssertionSet> assertionSets2 = new LinkedList<AssertionSet>();
    assertionSets2.add(assertionSet2);
    Policy policy2 = Policy.createPolicy(null, "id2", assertionSets2);
    final Collection<Policy> policies = new LinkedList<Policy>();
    policies.add(policy1);
    policies.add(policy2);
    final String expResult1 = "id1-id2";
    final String expResult2 = "id2-id1";
    final PolicyMerger instance = PolicyMerger.getMerger();
    final Policy mergedPolicy = instance.merge(policies);
    final String result = mergedPolicy.getId();
    if (!expResult1.equals(result)) {
        assertEquals(expResult2, result);
    }
}
Also used : QName(javax.xml.namespace.QName) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData) LinkedList(java.util.LinkedList)

Aggregations

AssertionData (com.sun.xml.ws.policy.sourcemodel.AssertionData)54 QName (javax.xml.namespace.QName)49 HashMap (java.util.HashMap)39 LinkedList (java.util.LinkedList)16 Setting (com.sun.xml.ws.api.config.management.policy.ManagementAssertion.Setting)10 PolicyAssertion (com.sun.xml.ws.policy.PolicyAssertion)9 ImplementationRecord (com.sun.xml.ws.api.config.management.policy.ManagedServiceAssertion.ImplementationRecord)7 SimpleAssertion (com.sun.xml.ws.policy.SimpleAssertion)7 NestedParameters (com.sun.xml.ws.api.config.management.policy.ManagedServiceAssertion.NestedParameters)5 ModelNode (com.sun.xml.ws.policy.sourcemodel.ModelNode)3 PolicySourceModel (com.sun.xml.ws.policy.sourcemodel.PolicySourceModel)3 AssertionSet (com.sun.xml.ws.policy.AssertionSet)2 PolicyModelTranslator (com.sun.xml.ws.policy.sourcemodel.PolicyModelTranslator)2 ModelTranslator (com.sun.xml.ws.api.policy.ModelTranslator)1 Policy (com.sun.xml.ws.policy.Policy)1 AssertionCreationException (com.sun.xml.ws.policy.spi.AssertionCreationException)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 AddressingFeature (jakarta.xml.ws.soap.AddressingFeature)1 StringReader (java.io.StringReader)1 URI (java.net.URI)1