Search in sources :

Example 21 with AssertionData

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

the class ManagedServiceAssertionTest method testIsManagementEnabledOff.

public void testIsManagementEnabledOff() throws AssertionCreationException {
    final HashMap<QName, String> attributes = new HashMap<QName, String>();
    attributes.put(ID_ATTRIBUTE_QNAME, "id1");
    attributes.put(MANAGEMENT_ATTRIBUTE_QNAME, "off");
    final AssertionData data = AssertionData.createAssertionData(ManagedServiceAssertion.MANAGED_SERVICE_QNAME, null, attributes, false, false);
    final ManagedServiceAssertion instance = new ManagedServiceAssertion(data, null);
    final boolean result = instance.isManagementEnabled();
    assertFalse(result);
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData)

Example 22 with AssertionData

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

the class ManagedServiceAssertionTest method testGetId.

/**
 * Test of getId method, of class ManagedServiceAssertion.
 */
public void testGetId() throws AssertionCreationException {
    final HashMap<QName, String> attributes = new HashMap<QName, String>();
    attributes.put(ID_ATTRIBUTE_QNAME, "id1");
    final AssertionData data = AssertionData.createAssertionData(ManagedServiceAssertion.MANAGED_SERVICE_QNAME, null, attributes, false, false);
    ManagedServiceAssertion instance = new ManagedServiceAssertion(data, null);
    String expResult = "id1";
    String result = instance.getId();
    assertEquals(expResult, result);
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData)

Example 23 with AssertionData

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

the class ManagedServiceAssertionTest method testMonitoringAttributeTrue.

public void testMonitoringAttributeTrue() throws AssertionCreationException {
    final HashMap<QName, String> attributes = new HashMap<QName, String>();
    attributes.put(ID_ATTRIBUTE_QNAME, "id1");
    attributes.put(MONITORING_ATTRIBUTE_QNAME, "true");
    final AssertionData data = AssertionData.createAssertionData(ManagedServiceAssertion.MANAGED_SERVICE_QNAME, null, attributes, false, false);
    final ManagedServiceAssertion instance = new ManagedServiceAssertion(data, null);
    final Setting result = instance.monitoringAttribute();
    assertSame(Setting.ON, result);
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Setting(com.sun.xml.ws.api.config.management.policy.ManagementAssertion.Setting) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData)

Example 24 with AssertionData

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

the class AlternativeSelectorTest 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 ModelTranslator translator = ModelTranslator.getTranslator();
    this.multipleAlternativesPolicy = translator.translate(model);
}
Also used : PolicySourceModel(com.sun.xml.ws.policy.sourcemodel.PolicySourceModel) ModelTranslator(com.sun.xml.ws.api.policy.ModelTranslator) ModelNode(com.sun.xml.ws.policy.sourcemodel.ModelNode) AssertionData(com.sun.xml.ws.policy.sourcemodel.AssertionData)

Example 25 with AssertionData

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

the class AddressingPolicyMapConfigurator method createWsamAddressingPolicy.

/**
 * Create a policy with an WSAM Addressing assertion.
 */
private Policy createWsamAddressingPolicy(final QName bindingName, AddressingFeature af) {
    final ArrayList<AssertionSet> assertionSets = new ArrayList<>(1);
    final ArrayList<PolicyAssertion> assertions = new ArrayList<>(1);
    final AssertionData addressingData = AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION);
    if (!af.isRequired()) {
        addressingData.setOptionalAttribute(true);
    }
    try {
        AddressingFeature.Responses responses = af.getResponses();
        if (responses == AddressingFeature.Responses.ANONYMOUS) {
            AssertionData nestedAsserData = AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION);
            PolicyAssertion nestedAsser = new AddressingAssertion(nestedAsserData, null);
            assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(Collections.singleton(nestedAsser))));
        } else if (responses == AddressingFeature.Responses.NON_ANONYMOUS) {
            final AssertionData nestedAsserData = AssertionData.createAssertionData(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION);
            PolicyAssertion nestedAsser = new AddressingAssertion(nestedAsserData, null);
            assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(Collections.singleton(nestedAsser))));
        } else {
            assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(null)));
        }
    } catch (NoSuchMethodError e) {
        // If JAX-WS 2.2 API is really required, it would been reported in @Addressing or wsam:Addressing processing
        // Don't add any nested assertion to mimic the 2.1 behavior
        assertions.add(new AddressingAssertion(addressingData, AssertionSet.createAssertionSet(null)));
    }
    assertionSets.add(AssertionSet.createAssertionSet(assertions));
    return Policy.createPolicy(null, bindingName.getLocalPart() + "_WSAM_Addressing_Policy", assertionSets);
}
Also used : PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) AddressingFeature(jakarta.xml.ws.soap.AddressingFeature) ArrayList(java.util.ArrayList) AssertionSet(com.sun.xml.ws.policy.AssertionSet) 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