Search in sources :

Example 1 with PolicyModelTranslator

use of com.sun.xml.ws.policy.sourcemodel.PolicyModelTranslator 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 2 with PolicyModelTranslator

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

the class ExternalAttachmentsUnmarshaller method readPolicy.

private void readPolicy(final XMLEventReader reader) throws PolicyException {
    final PolicySourceModel policyModel = POLICY_UNMARSHALLER.unmarshalModel(reader);
    final PolicyModelTranslator translator = PolicyModelTranslator.getTranslator();
    final Policy policy = translator.translate(policyModel);
    if (this.currentUri != null) {
        map.put(this.currentUri, policy);
        this.currentUri = null;
        this.currentPolicy = null;
    } else {
        this.currentPolicy = policy;
    }
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicySourceModel(com.sun.xml.ws.policy.sourcemodel.PolicySourceModel) PolicyModelTranslator(com.sun.xml.ws.policy.sourcemodel.PolicyModelTranslator)

Example 3 with PolicyModelTranslator

use of com.sun.xml.ws.policy.sourcemodel.PolicyModelTranslator 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)

Aggregations

PolicyModelTranslator (com.sun.xml.ws.policy.sourcemodel.PolicyModelTranslator)3 PolicySourceModel (com.sun.xml.ws.policy.sourcemodel.PolicySourceModel)3 AssertionData (com.sun.xml.ws.policy.sourcemodel.AssertionData)2 ModelNode (com.sun.xml.ws.policy.sourcemodel.ModelNode)2 Policy (com.sun.xml.ws.policy.Policy)1 QName (javax.xml.namespace.QName)1