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;
}
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();
}
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();
}
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));
}
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();
}
Aggregations