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