Search in sources :

Example 11 with BindingFaultInfo

use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.

the class PolicyAttachmentTest method testAppliesToFault.

@Test
public void testAppliesToFault() {
    BindingFaultInfo bfi1 = control.createMock(BindingFaultInfo.class);
    BindingFaultInfo bfi2 = control.createMock(BindingFaultInfo.class);
    DomainExpression de = control.createMock(DomainExpression.class);
    Collection<DomainExpression> des = Collections.singletonList(de);
    PolicyAttachment pa = new PolicyAttachment();
    pa.setDomainExpressions(des);
    EasyMock.expect(de.appliesTo(bfi1)).andReturn(false);
    EasyMock.expect(de.appliesTo(bfi2)).andReturn(true);
    control.replay();
    assertFalse(pa.appliesTo(bfi1));
    assertTrue(pa.appliesTo(bfi2));
    control.verify();
}
Also used : BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) Test(org.junit.Test)

Example 12 with BindingFaultInfo

use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.

the class ExternalAttachmentProviderTest method setUpAttachment.

void setUpAttachment(Object subject, boolean applies, ExternalAttachmentProvider eap) {
    attachments.clear();
    attachment = control.createMock(PolicyAttachment.class);
    attachments.add(attachment);
    policy = new Policy();
    assertion = new PrimitiveAssertion(TEST_ASSERTION_TYPE);
    policy.addAssertion(assertion);
    eap.setAttachments(attachments);
    if (subject instanceof ServiceInfo) {
        EasyMock.expect(attachment.appliesTo((ServiceInfo) subject)).andReturn(applies);
    } else if (subject instanceof EndpointInfo) {
        EasyMock.expect(attachment.appliesTo((EndpointInfo) subject)).andReturn(applies);
    } else if (subject instanceof BindingOperationInfo) {
        EasyMock.expect(attachment.appliesTo((BindingOperationInfo) subject)).andReturn(applies);
    } else if (subject instanceof BindingMessageInfo) {
        EasyMock.expect(attachment.appliesTo((BindingMessageInfo) subject)).andReturn(applies);
    } else if (subject instanceof BindingFaultInfo) {
        EasyMock.expect(attachment.appliesTo((BindingFaultInfo) subject)).andReturn(applies);
    } else {
        System.err.println("subject class: " + subject.getClass());
    }
    if (applies) {
        EasyMock.expect(attachment.getPolicy()).andReturn(policy);
    }
}
Also used : Policy(org.apache.neethi.Policy) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) PrimitiveAssertion(org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo)

Example 13 with BindingFaultInfo

use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.

the class ExternalAttachmentProviderTest method testGetEffectiveFaultPolicy.

@Test
public void testGetEffectiveFaultPolicy() {
    ExternalAttachmentProvider eap = new ExternalAttachmentProvider();
    BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);
    setUpAttachment(bfi, false, eap);
    control.replay();
    assertNull(eap.getEffectivePolicy(bfi, null));
    control.verify();
    control.reset();
    setUpAttachment(bfi, true, eap);
    control.replay();
    assertSame(assertion, eap.getEffectivePolicy(bfi, null).getAssertions().get(0));
    control.verify();
}
Also used : BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) Test(org.junit.Test)

Example 14 with BindingFaultInfo

use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.

the class PolicyEngineTest method testSetEffectiveClientFaultPolicy.

@Test
public void testSetEffectiveClientFaultPolicy() throws Exception {
    engine = new PolicyEngineImpl();
    EndpointInfo ei = createMockEndpointInfo();
    BindingFaultInfo bfi = new BindingFaultInfo(null, null);
    EffectivePolicy epi = control.createMock(EffectivePolicy.class);
    engine.setEffectiveClientFaultPolicy(ei, bfi, epi);
    assertSame(epi, engine.getEffectiveClientFaultPolicy(ei, null, bfi, msg));
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) Test(org.junit.Test)

Example 15 with BindingFaultInfo

use of org.apache.cxf.service.model.BindingFaultInfo in project cxf by apache.

the class PolicyEngineTest method testGetAggregatedFaultPolicy.

@Test
public void testGetAggregatedFaultPolicy() {
    engine = new PolicyEngineImpl();
    BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);
    control.replay();
    Policy p = engine.getAggregatedFaultPolicy(bfi, null);
    assertTrue(p.isEmpty());
    control.verify();
    control.reset();
    PolicyProvider provider1 = control.createMock(PolicyProvider.class);
    engine.getPolicyProviders().add(provider1);
    Policy p1 = control.createMock(Policy.class);
    EasyMock.expect(provider1.getEffectivePolicy(bfi, null)).andReturn(p1);
    control.replay();
    assertSame(p1, engine.getAggregatedFaultPolicy(bfi, null));
    control.verify();
    control.reset();
    PolicyProvider provider2 = control.createMock(PolicyProvider.class);
    engine.getPolicyProviders().add(provider2);
    Policy p2 = control.createMock(Policy.class);
    Policy p3 = control.createMock(Policy.class);
    EasyMock.expect(provider1.getEffectivePolicy(bfi, null)).andReturn(p1);
    EasyMock.expect(provider2.getEffectivePolicy(bfi, null)).andReturn(p2);
    EasyMock.expect(p1.merge(p2)).andReturn(p3);
    control.replay();
    assertSame(p3, engine.getAggregatedFaultPolicy(bfi, null));
    control.verify();
}
Also used : Policy(org.apache.neethi.Policy) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) Test(org.junit.Test)

Aggregations

BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)31 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)15 Test (org.junit.Test)13 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)9 QName (javax.xml.namespace.QName)6 BindingInfo (org.apache.cxf.service.model.BindingInfo)5 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)5 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)5 Method (java.lang.reflect.Method)4 Bus (org.apache.cxf.Bus)4 Message (org.apache.cxf.message.Message)4 FaultInfo (org.apache.cxf.service.model.FaultInfo)4 Policy (org.apache.neethi.Policy)4 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)3 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)3 ArrayList (java.util.ArrayList)2 BindingFault (javax.wsdl.BindingFault)2 UnknownExtensibilityElement (javax.wsdl.extensions.UnknownExtensibilityElement)2 Endpoint (org.apache.cxf.endpoint.Endpoint)2 Interceptor (org.apache.cxf.interceptor.Interceptor)2