Search in sources :

Example 26 with AssertionData

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

the class ExternalAttachmentsUnmarshallerTest method testUnmarshal.

/**
 * Test of unmarshal method, of class ExternalAttachmentsUnmarshaller.
 */
public void testUnmarshal() throws Exception {
    final String policies = "<sunman:Policies " + "xmlns:sunman=\"http://java.sun.com/xml/ns/metro/management\" " + "xmlns:wsp=\"http://www.w3.org/ns/ws-policy\" " + "xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\" " + "xmlns:foo=\"http://schemas.example.net/\">" + "  <wsp:PolicyAttachment>" + "    <wsp:AppliesTo>" + "      <wsp:URI>urn:uuid:c9bef600-0d7a-11de-abc1-0002a5d5c51b</wsp:URI>" + "    </wsp:AppliesTo>" + "    <wsp:Policy wsu:Id=\"binding-policy\">" + "      <foo:TopLevelAssertion_1 />" + "    </wsp:Policy>" + "  </wsp:PolicyAttachment>" + "  <wsp:PolicyAttachment>" + "    <wsp:AppliesTo>" + "      <wsp:URI>urn:uuid:62e66b60-0d7b-11de-a1a2-0002a5d5c51b</wsp:URI>" + "    </wsp:AppliesTo>" + "    <wsp:Policy wsu:Id=\"operation-policy\">" + "      <foo:TopLevelAssertion_2 />" + "    </wsp:Policy>" + "  </wsp:PolicyAttachment>" + "  <wsp:PolicyAttachment>" + "    <wsp:AppliesTo>" + "      <wsp:URI>urn:uuid:730d8d20-0d7b-11de-84e9-0002a5d5c51b</wsp:URI>" + "    </wsp:AppliesTo>" + "    <wsp:Policy wsu:Id=\"input-policy\">" + "      <foo:TopLevelAssertion_3>" + "        <foo:TopLevelAssertion_3_Parameter1/>" + "        <foo:TopLevelAssertion_3_Parameter2>" + "          <foo:TopLevelAssertion_3_Parameter2_1/>" + "          <foo:TopLevelAssertion_3_Parameter2_2/>" + "        </foo:TopLevelAssertion_3_Parameter2>" + "        <wsp:Policy>" + "          <wsp:ExactlyOne>" + "              <foo:NestedAssertion_1/>" + "              <foo:NestedAssertion_2/>" + "          </wsp:ExactlyOne>" + "        </wsp:Policy>" + "      </foo:TopLevelAssertion_3>" + "    </wsp:Policy>" + "  </wsp:PolicyAttachment>" + "  <wsp:PolicyAttachment>" + "    <wsp:AppliesTo>" + "      <wsp:URI>urn:uuid:85b0f980-0d7b-11de-8e9d-0002a5d5c51b</wsp:URI>" + "    </wsp:AppliesTo>" + "    <wsp:Policy wsu:Id=\"output-policy\">" + "      <foo:TopLevelAssertion_4/>" + "    </wsp:Policy>" + "  </wsp:PolicyAttachment>" + "  <wsp:PolicyAttachment>" + "    <wsp:AppliesTo>" + "      <wsp:URI>urn:uuid:917cb060-0d7b-11de-9e80-0002a5d5c51b</wsp:URI>" + "    </wsp:AppliesTo>" + "    <wsp:Policy wsu:Id=\"fault-policy\">" + "      <foo:TopLevelAssertion_5/>" + "    </wsp:Policy>" + "  </wsp:PolicyAttachment>" + "</sunman:Policies>";
    final Map<URI, Policy> expResult = new HashMap<URI, Policy>();
    final AssertionData assertionData1 = AssertionData.createAssertionData(new QName("http://schemas.example.net/", "TopLevelAssertion_1"));
    final PolicyAssertion assertion1 = new PolicyAssertion(assertionData1, null) {
    };
    final LinkedList<PolicyAssertion> assertionList1 = new LinkedList<PolicyAssertion>();
    assertionList1.add(assertion1);
    final AssertionSet assertions1 = AssertionSet.createAssertionSet(assertionList1);
    final LinkedList<AssertionSet> alternatives1 = new LinkedList<AssertionSet>();
    alternatives1.add(assertions1);
    final Policy bindingPolicy = Policy.createPolicy(NamespaceVersion.v1_5, null, "binding-policy", alternatives1);
    expResult.put(new URI("urn:uuid:c9bef600-0d7a-11de-abc1-0002a5d5c51b"), bindingPolicy);
    final AssertionData assertionData2 = AssertionData.createAssertionData(new QName("http://schemas.example.net/", "TopLevelAssertion_2"));
    final PolicyAssertion assertion2 = new PolicyAssertion(assertionData2, null) {
    };
    final LinkedList<PolicyAssertion> assertionList2 = new LinkedList<PolicyAssertion>();
    assertionList2.add(assertion2);
    final AssertionSet assertions2 = AssertionSet.createAssertionSet(assertionList2);
    final LinkedList<AssertionSet> alternatives2 = new LinkedList<AssertionSet>();
    alternatives2.add(assertions2);
    final Policy operationPolicy = Policy.createPolicy(NamespaceVersion.v1_5, null, "operation-policy", alternatives2);
    expResult.put(new URI("urn:uuid:62e66b60-0d7b-11de-a1a2-0002a5d5c51b"), operationPolicy);
    final AssertionData assertionData31 = AssertionData.createAssertionData(new QName("http://schemas.example.net/", "TopLevelAssertion_3_Parameter1"));
    final PolicyAssertion assertion31 = new PolicyAssertion(assertionData31, null) {
    };
    final AssertionData assertionData321 = AssertionData.createAssertionData(new QName("http://schemas.example.net/", "TopLevelAssertion_3_Parameter2_1"));
    final PolicyAssertion assertion321 = new PolicyAssertion(assertionData321, null) {
    };
    final AssertionData assertionData322 = AssertionData.createAssertionData(new QName("http://schemas.example.net/", "TopLevelAssertion_3_Parameter2_2"));
    final PolicyAssertion assertion322 = new PolicyAssertion(assertionData322, null) {
    };
    final AssertionData assertionData32 = AssertionData.createAssertionData(new QName("http://schemas.example.net/", "TopLevelAssertion_3_Parameter2"));
    final LinkedList<PolicyAssertion> parameters32 = new LinkedList<PolicyAssertion>();
    parameters32.add(assertion321);
    parameters32.add(assertion322);
    final PolicyAssertion assertion32 = new PolicyAssertion(assertionData32, parameters32) {
    };
    final LinkedList<PolicyAssertion> parameters3 = new LinkedList<PolicyAssertion>();
    parameters3.add(assertion31);
    parameters3.add(assertion32);
    final AssertionData nestedAssertionData1 = AssertionData.createAssertionData(new QName("http://schemas.example.net/", "NestedAssertion_1"));
    final PolicyAssertion nestedAssertion1 = new PolicyAssertion(nestedAssertionData1, null) {
    };
    final LinkedList<PolicyAssertion> nestedAssertionList1 = new LinkedList<PolicyAssertion>();
    nestedAssertionList1.add(nestedAssertion1);
    final AssertionSet nestedAlternative1 = AssertionSet.createAssertionSet(nestedAssertionList1);
    final AssertionData assertionData3 = AssertionData.createAssertionData(new QName("http://schemas.example.net/", "TopLevelAssertion_3"));
    final PolicyAssertion assertion3Alt1 = new PolicyAssertion(assertionData3, parameters3, nestedAlternative1) {
    };
    final LinkedList<PolicyAssertion> assertionList31 = new LinkedList<PolicyAssertion>();
    assertionList31.add(assertion3Alt1);
    final AssertionSet assertions31 = AssertionSet.createAssertionSet(assertionList31);
    final LinkedList<AssertionSet> alternatives3 = new LinkedList<AssertionSet>();
    alternatives3.add(assertions31);
    final AssertionData nestedAssertionData2 = AssertionData.createAssertionData(new QName("http://schemas.example.net/", "NestedAssertion_2"));
    final PolicyAssertion nestedAssertion2 = new PolicyAssertion(nestedAssertionData2, null) {
    };
    final LinkedList<PolicyAssertion> nestedAssertionList2 = new LinkedList<PolicyAssertion>();
    nestedAssertionList2.add(nestedAssertion2);
    final AssertionSet nestedAlternative2 = AssertionSet.createAssertionSet(nestedAssertionList2);
    final PolicyAssertion assertion3Alt2 = new PolicyAssertion(assertionData3, parameters3, nestedAlternative2) {
    };
    final LinkedList<PolicyAssertion> assertionList32 = new LinkedList<PolicyAssertion>();
    assertionList32.add(assertion3Alt2);
    final AssertionSet assertions32 = AssertionSet.createAssertionSet(assertionList32);
    alternatives3.add(assertions32);
    final Policy inputPolicy = Policy.createPolicy(NamespaceVersion.v1_5, null, "input-policy", alternatives3);
    expResult.put(new URI("urn:uuid:730d8d20-0d7b-11de-84e9-0002a5d5c51b"), inputPolicy);
    final AssertionData assertionData4 = AssertionData.createAssertionData(new QName("http://schemas.example.net/", "TopLevelAssertion_4"));
    final PolicyAssertion assertion4 = new PolicyAssertion(assertionData4, null) {
    };
    final LinkedList<PolicyAssertion> assertionList4 = new LinkedList<PolicyAssertion>();
    assertionList4.add(assertion4);
    final AssertionSet assertions4 = AssertionSet.createAssertionSet(assertionList4);
    final LinkedList<AssertionSet> alternatives4 = new LinkedList<AssertionSet>();
    alternatives4.add(assertions4);
    final Policy outputPolicy = Policy.createPolicy(NamespaceVersion.v1_5, null, "output-policy", alternatives4);
    expResult.put(new URI("urn:uuid:85b0f980-0d7b-11de-8e9d-0002a5d5c51b"), outputPolicy);
    final AssertionData assertionData5 = AssertionData.createAssertionData(new QName("http://schemas.example.net/", "TopLevelAssertion_5"));
    final PolicyAssertion assertion5 = new PolicyAssertion(assertionData5, null) {
    };
    final LinkedList<PolicyAssertion> assertionList5 = new LinkedList<PolicyAssertion>();
    assertionList5.add(assertion5);
    final AssertionSet assertions5 = AssertionSet.createAssertionSet(assertionList5);
    final LinkedList<AssertionSet> alternatives5 = new LinkedList<AssertionSet>();
    alternatives5.add(assertions5);
    final Policy faultPolicy = Policy.createPolicy(NamespaceVersion.v1_5, null, "fault-policy", alternatives5);
    expResult.put(new URI("urn:uuid:917cb060-0d7b-11de-9e80-0002a5d5c51b"), faultPolicy);
    final StringReader reader = new StringReader(policies);
    final Map<URI, Policy> result = ExternalAttachmentsUnmarshaller.unmarshal(reader);
    assertEquals(expResult, result);
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) AssertionSet(com.sun.xml.ws.policy.AssertionSet) URI(java.net.URI) LinkedList(java.util.LinkedList) StringReader(java.io.StringReader) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData)

Example 27 with AssertionData

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

the class EffectiveAlternativeSelectorTest method setUp.

@Override
protected void setUp() throws PolicyException {
    final PolicySourceModel model = PolicySourceModel.createPolicySourceModel(NamespaceVersion.v1_5, "id", null);
    final ModelNode root = model.getRootNode();
    final ModelNode alternatives = root.createChildExactlyOneNode();
    final ModelNode alternative1 = alternatives.createChildAllNode();
    final ModelNode alternative2 = alternatives.createChildAllNode();
    final AssertionData assertion1 = AssertionData.createAssertionData(assertion1Name);
    alternative1.createChildAssertionNode(assertion1);
    final AssertionData assertion2 = AssertionData.createAssertionData(assertion2Name);
    alternative2.createChildAssertionNode(assertion2);
    final PolicyModelTranslator translator = PolicyModelTranslator.getTranslator();
    this.multipleAlternativesPolicy = translator.translate(model);
}
Also used : PolicySourceModel(com.sun.xml.ws.policy.sourcemodel.PolicySourceModel) 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 28 with AssertionData

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

the class PolicyAssertionTest method testIsOptional.

public void testIsOptional() {
    assertFalse(a1.isOptional());
    assertFalse(a2.isOptional());
    assertFalse(a3.isOptional());
    assertFalse(a4.isOptional());
    assertFalse(a5.isOptional());
    AssertionData assertionData = AssertionData.createAssertionData(assertionName, "test", attributes, true, false);
    PolicyAssertion assertion = new PolicyAssertion(assertionData, null) {
    };
    assertTrue(assertion.isOptional());
    assertionData = AssertionData.createAssertionData(assertionName, "test", attributes, false, false);
    assertionData.setOptionalAttribute(true);
    assertion = new PolicyAssertion(assertionData, null) {
    };
    assertTrue(assertion.isOptional());
}
Also used : AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData)

Example 29 with AssertionData

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

the class PolicyAssertionTest method testIsIgnorable.

public void testIsIgnorable() {
    assertFalse(a1.isIgnorable());
    assertFalse(a2.isIgnorable());
    assertFalse(a3.isIgnorable());
    assertFalse(a4.isIgnorable());
    assertFalse(a5.isIgnorable());
    AssertionData assertionData = AssertionData.createAssertionData(assertionName, "test", attributes, false, true);
    PolicyAssertion assertion = new PolicyAssertion(assertionData, null) {
    };
    assertTrue(assertion.isIgnorable());
    assertionData = AssertionData.createAssertionData(assertionName, "test", attributes, false, false);
    assertionData.setIgnorableAttribute(true);
    assertion = new PolicyAssertion(assertionData, null) {
    };
    assertTrue(assertion.isIgnorable());
}
Also used : AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData)

Example 30 with AssertionData

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

the class AssertionCreationExceptionTest method testGetAssertionData.

/**
 * Test of getAssertionData method, of class AssertionCreationException.
 */
public void testGetAssertionData() {
    AssertionData expResult = AssertionData.createAssertionData(new QName("test1", "test2"));
    AssertionCreationException instance = new AssertionCreationException(expResult, "testing an exception");
    AssertionData result = instance.getAssertionData();
    assertSame(expResult, result);
}
Also used : QName(javax.xml.namespace.QName) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData)

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