Search in sources :

Example 26 with BindingFaultInfo

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

the class AbstractPolicyInterceptor method getBindingFaultInfo.

protected BindingFaultInfo getBindingFaultInfo(Message msg, Exception ex, BindingOperationInfo boi) {
    BindingFaultInfo bfi = msg.get(BindingFaultInfo.class);
    if (null == bfi && ex != null) {
        Throwable cause = ex.getCause();
        if (null == cause) {
            return null;
        }
        for (BindingFaultInfo b : boi.getFaults()) {
            Class<?> faultClass = b.getFaultInfo().getProperty(Class.class.getName(), Class.class);
            if (faultClass != null && faultClass.isAssignableFrom(cause.getClass())) {
                bfi = b;
                msg.put(BindingFaultInfo.class, bfi);
                break;
            }
        }
        if (null == bfi && null != boi.getWrappedOperation()) {
            for (BindingFaultInfo b : boi.getWrappedOperation().getFaults()) {
                Class<?> faultClass = b.getFaultInfo().getProperty(Class.class.getName(), Class.class);
                if (faultClass != null && faultClass.isAssignableFrom(cause.getClass())) {
                    bfi = b;
                    msg.put(BindingFaultInfo.class, bfi);
                    break;
                }
            }
        }
    }
    return bfi;
}
Also used : BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo)

Example 27 with BindingFaultInfo

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

the class PolicyEngineTest method testGetEffectiveClientFaultPolicy.

@Test
public void testGetEffectiveClientFaultPolicy() throws Exception {
    Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[] {});
    engine = EasyMock.createMockBuilder(PolicyEngineImpl.class).addMockedMethod(m).createMock(control);
    engine.init();
    EndpointInfo ei = createMockEndpointInfo();
    BindingFaultInfo bfi = new BindingFaultInfo(null, null);
    EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
    EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
    epi.initialisePolicy(ei, null, bfi, engine, msg);
    EasyMock.expectLastCall();
    control.replay();
    assertSame(epi, engine.getEffectiveClientFaultPolicy(ei, null, bfi, msg));
    assertSame(epi, engine.getEffectiveClientFaultPolicy(ei, null, bfi, msg));
    control.verify();
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Method(java.lang.reflect.Method) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) Test(org.junit.Test)

Example 28 with BindingFaultInfo

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

the class EffectivePolicyImplTest method testInitialiseServerFaultPolicy.

@Test
public void testInitialiseServerFaultPolicy() {
    Message m = new MessageImpl();
    EndpointInfo ei = control.createMock(EndpointInfo.class);
    BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);
    PolicyEngineImpl engine = control.createMock(PolicyEngineImpl.class);
    BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
    EasyMock.expect(bfi.getBindingOperation()).andReturn(boi).anyTimes();
    EndpointPolicy endpointPolicy = control.createMock(EndpointPolicy.class);
    EasyMock.expect(engine.getServerEndpointPolicy(ei, (Destination) null, m)).andReturn(endpointPolicy);
    Policy ep = control.createMock(Policy.class);
    EasyMock.expect(endpointPolicy.getPolicy()).andReturn(ep);
    Policy op = control.createMock(Policy.class);
    EasyMock.expect(engine.getAggregatedOperationPolicy(boi, m)).andReturn(op);
    Policy merged = control.createMock(Policy.class);
    EasyMock.expect(ep.merge(op)).andReturn(merged);
    Policy fp = control.createMock(Policy.class);
    EasyMock.expect(engine.getAggregatedFaultPolicy(bfi, m)).andReturn(fp);
    EasyMock.expect(merged.merge(fp)).andReturn(merged);
    EasyMock.expect(merged.normalize(null, true)).andReturn(merged);
    control.replay();
    EffectivePolicyImpl epi = new EffectivePolicyImpl();
    epi.initialisePolicy(ei, boi, bfi, engine, m);
    assertSame(merged, epi.getPolicy());
    control.verify();
}
Also used : Policy(org.apache.neethi.Policy) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) Test(org.junit.Test)

Example 29 with BindingFaultInfo

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

the class PolicyEngineTest method testSetEffectiveServerFaultPolicy.

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

Example 30 with BindingFaultInfo

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

the class PolicyEngineTest method testGetEffectiveServerFaultPolicy.

@Test
public void testGetEffectiveServerFaultPolicy() throws Exception {
    Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[] {});
    engine = EasyMock.createMockBuilder(PolicyEngineImpl.class).addMockedMethod(m).createMock(control);
    engine.init();
    EndpointInfo ei = createMockEndpointInfo();
    BindingFaultInfo bfi = new BindingFaultInfo(null, null);
    AssertingDestination destination = control.createMock(AssertingDestination.class);
    EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
    EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
    epi.initialise(ei, null, bfi, engine, destination, msg);
    EasyMock.expectLastCall();
    control.replay();
    assertSame(epi, engine.getEffectiveServerFaultPolicy(ei, null, bfi, destination, msg));
    assertSame(epi, engine.getEffectiveServerFaultPolicy(ei, null, bfi, destination, msg));
    control.verify();
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Method(java.lang.reflect.Method) 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