use of org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion in project cxf by apache.
the class HTTPClientAssertionBuilderTest method testBuildAssertion.
@Test
public void testBuildAssertion() throws Exception {
HTTPClientAssertionBuilder ab = new HTTPClientAssertionBuilder();
Assertion a = ab.buildAssertion();
assertTrue(a instanceof JaxbAssertion);
assertTrue(a instanceof HTTPClientAssertionBuilder.HTTPClientPolicyAssertion);
assertEquals(new ClientPolicyCalculator().getDataClassName(), a.getName());
assertTrue(!a.isOptional());
}
use of org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion in project cxf by apache.
the class RMPolicyUtilities method getRMConfiguration.
/**
* Returns an RMAssertion that is compatible with the default value and all RMAssertions pertaining to the
* message (can never be null).
*
* @param rma the default value (non-<code>null</code>)
* @param message the message
* @return the compatible RMAssertion
*/
public static RMConfiguration getRMConfiguration(RMConfiguration defaultValue, Message message) {
RMConfiguration compatible = defaultValue;
Collection<AssertionInfo> ais = collectRMAssertions(message.get(AssertionInfoMap.class));
for (AssertionInfo ai : ais) {
if (ai.getAssertion() instanceof JaxbAssertion<?>) {
RMAssertion rma = (RMAssertion) ((JaxbAssertion<?>) ai.getAssertion()).getData();
compatible = intersect(rma, compatible);
} else if (ai.getAssertion() instanceof PrimitiveAssertion) {
PrimitiveAssertion assertion = (PrimitiveAssertion) ai.getAssertion();
if (RM11Constants.WSRMP_NAMESPACE_URI.equals(assertion.getName().getNamespaceURI())) {
compatible = intersect(assertion, compatible);
}
}
}
return compatible;
}
use of org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion in project cxf by apache.
the class PolicyUtilsTest method testGetRMConfiguration.
@Test
public void testGetRMConfiguration() {
RMConfiguration cfg = new RMConfiguration();
cfg.setBaseRetransmissionInterval(new Long(3000));
cfg.setExponentialBackoff(true);
Message message = control.createMock(Message.class);
EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
control.replay();
assertSame(cfg, RMPolicyUtilities.getRMConfiguration(cfg, message));
control.verify();
control.reset();
AssertionInfoMap aim = control.createMock(AssertionInfoMap.class);
EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
Collection<AssertionInfo> ais = new ArrayList<>();
EasyMock.expect(aim.get(RM10Constants.RMASSERTION_QNAME)).andReturn(ais);
control.replay();
assertSame(cfg, RMPolicyUtilities.getRMConfiguration(cfg, message));
control.verify();
control.reset();
RMAssertion b = new RMAssertion();
BaseRetransmissionInterval bbri = new RMAssertion.BaseRetransmissionInterval();
bbri.setMilliseconds(new Long(2000));
b.setBaseRetransmissionInterval(bbri);
JaxbAssertion<RMAssertion> assertion = new JaxbAssertion<RMAssertion>();
assertion.setName(RM10Constants.RMASSERTION_QNAME);
assertion.setData(b);
AssertionInfo ai = new AssertionInfo(assertion);
ais.add(ai);
EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
EasyMock.expect(aim.get(RM10Constants.RMASSERTION_QNAME)).andReturn(ais);
control.replay();
RMConfiguration cfg1 = RMPolicyUtilities.getRMConfiguration(cfg, message);
assertNull(cfg1.getAcknowledgementInterval());
assertNull(cfg1.getInactivityTimeout());
assertEquals(2000L, cfg1.getBaseRetransmissionInterval().longValue());
assertTrue(cfg1.isExponentialBackoff());
control.verify();
}
use of org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion in project cxf by apache.
the class HTTPServerAssertionBuilderTest method testBuildAssertion.
@Test
public void testBuildAssertion() throws Exception {
HTTPServerAssertionBuilder ab = new HTTPServerAssertionBuilder();
Assertion a = ab.buildAssertion();
assertTrue(a instanceof JaxbAssertion);
assertTrue(a instanceof HTTPServerAssertionBuilder.HTTPServerPolicyAssertion);
assertEquals(new ServerPolicyCalculator().getDataClassName(), a.getName());
assertTrue(!a.isOptional());
}
Aggregations