use of org.apache.cxf.ws.rm.manager.DestinationPolicyType in project cxf by apache.
the class RMInInterceptorTest method testProcessInvalidMessageOnFault.
@Test
public void testProcessInvalidMessageOnFault() throws SequenceFault, RMException {
interceptor = new RMInInterceptor();
manager = control.createMock(RMManager.class);
interceptor.setManager(manager);
Message message = control.createMock(Message.class);
Exchange exchange = control.createMock(Exchange.class);
EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
control.replay();
try {
interceptor.handleFault(message);
} catch (Exception e) {
fail("unexpected exception thrown from handleFault: " + e);
}
control.reset();
EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
EasyMock.expect(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY)).andReturn(true).anyTimes();
control.replay();
try {
interceptor.handleFault(message);
} catch (Exception e) {
fail("unexpected exception thrown from handleFault: " + e);
}
control.reset();
org.apache.cxf.transport.Destination td = control.createMock(org.apache.cxf.transport.Destination.class);
EasyMock.expect(exchange.getDestination()).andReturn(td).anyTimes();
EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
EasyMock.expect(message.get(RMMessageConstants.RM_PROTOCOL_VARIATION)).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
EasyMock.expect(message.getContent(Exception.class)).andReturn(new SequenceFault("no sequence")).anyTimes();
DestinationPolicyType dp = new DestinationPolicyType();
RetryPolicyType rp = new RetryPolicyType();
dp.setRetryPolicy(rp);
EasyMock.expect(manager.getDestinationPolicy()).andReturn(dp).anyTimes();
RedeliveryQueue rq = control.createMock(RedeliveryQueue.class);
EasyMock.expect(manager.getRedeliveryQueue()).andReturn(rq).anyTimes();
rq.addUndelivered(message);
EasyMock.expectLastCall().andThrow(new RuntimeException("shouldn't be queued")).anyTimes();
control.replay();
try {
interceptor.handleFault(message);
} catch (Exception e) {
fail("unexpected exception thrown from handleFault: " + e);
}
}
use of org.apache.cxf.ws.rm.manager.DestinationPolicyType in project cxf by apache.
the class RMManagerTest method testInitialisation.
@Test
public void testInitialisation() {
manager = new RMManager();
assertNull("sourcePolicy is set.", manager.getSourcePolicy());
assertNull("destinationPolicy is set.", manager.getDestinationPolicy());
manager.initialise();
RMConfiguration cfg = manager.getConfiguration();
assertNotNull("RMConfiguration is not set.", cfg);
assertNotNull("sourcePolicy is not set.", manager.getSourcePolicy());
assertNotNull("destinationPolicy is not set.", manager.getDestinationPolicy());
assertNotNull("deliveryAssirance is not set.", cfg.getDeliveryAssurance());
assertTrue(cfg.isExponentialBackoff());
assertEquals(3000L, cfg.getBaseRetransmissionInterval().longValue());
assertNull(cfg.getAcknowledgementInterval());
assertNull(cfg.getInactivityTimeout());
SourcePolicyType sp = manager.getSourcePolicy();
assertEquals(0L, sp.getSequenceExpiration().getTimeInMillis(new Date()));
assertEquals(0L, sp.getOfferedSequenceExpiration().getTimeInMillis(new Date()));
assertNull(sp.getAcksTo());
assertTrue(sp.isIncludeOffer());
SequenceTerminationPolicyType stp = sp.getSequenceTerminationPolicy();
assertEquals(0, stp.getMaxRanges());
assertEquals(0, stp.getMaxUnacknowledged());
assertTrue(stp.isTerminateOnShutdown());
assertEquals(0, stp.getMaxLength());
DestinationPolicyType dp = manager.getDestinationPolicy();
assertNotNull(dp.getAcksPolicy());
assertEquals(dp.getAcksPolicy().getIntraMessageThreshold(), 10);
}
use of org.apache.cxf.ws.rm.manager.DestinationPolicyType in project cxf by apache.
the class ServantTest method verifyCreateSequenceExpiresSetAtDestination.
private void verifyCreateSequenceExpiresSetAtDestination(Servant servant, RMManager manager) throws SequenceFault {
DestinationPolicyType dp = RMMANGER_FACTORY.createDestinationPolicyType();
AcksPolicyType ap = RMMANGER_FACTORY.createAcksPolicyType();
dp.setAcksPolicy(ap);
dp.setSequenceExpiration(DURATION_SHORT);
manager.setDestinationPolicy(dp);
Expires expires = new Expires();
expires.setValue(DURATION_DEFAULT);
Message message = createTestCreateSequenceMessage(expires, null);
CreateSequenceResponseType csr = (CreateSequenceResponseType) servant.createSequence(message);
Expires expires2 = csr.getExpires();
assertNotNull(expires2);
assertEquals(DURATION_SHORT, expires2.getValue());
}
use of org.apache.cxf.ws.rm.manager.DestinationPolicyType in project cxf by apache.
the class ServantTest method verifyCreateSequenceDefault.
private void verifyCreateSequenceDefault(Servant servant, RMManager manager) throws SequenceFault {
DestinationPolicyType dp = RMMANGER_FACTORY.createDestinationPolicyType();
AcksPolicyType ap = RMMANGER_FACTORY.createAcksPolicyType();
dp.setAcksPolicy(ap);
manager.setDestinationPolicy(dp);
Expires expires = new Expires();
expires.setValue(DatatypeFactory.createDuration("P0Y0M0DT0H0M0.0S"));
Message message = createTestCreateSequenceMessage(expires, null);
CreateSequenceResponseType csr = (CreateSequenceResponseType) servant.createSequence(message);
Expires expires2 = csr.getExpires();
assertNotNull(expires2);
assertEquals(DatatypeFactory.PT0S, expires2.getValue());
}
use of org.apache.cxf.ws.rm.manager.DestinationPolicyType in project cxf by apache.
the class RMManager method initialise.
@PostConstruct
void initialise() {
if (configuration == null) {
getConfiguration().setExponentialBackoff(true);
}
DeliveryAssurance da = configuration.getDeliveryAssurance();
if (da == null) {
configuration.setDeliveryAssurance(DeliveryAssurance.AT_LEAST_ONCE);
}
if (null == sourcePolicy) {
setSourcePolicy(null);
}
if (null == destinationPolicy) {
DestinationPolicyType dp = new DestinationPolicyType();
dp.setAcksPolicy(new AcksPolicyType());
setDestinationPolicy(dp);
}
if (null == retransmissionQueue) {
retransmissionQueue = new RetransmissionQueueImpl(this);
}
if (null == redeliveryQueue) {
redeliveryQueue = new RedeliveryQueueImpl(this);
}
if (null == idGenerator) {
idGenerator = new DefaultSequenceIdentifierGenerator();
}
if (null != bus) {
managedManager = new ManagedRMManager(this);
instrumentationManager = bus.getExtension(InstrumentationManager.class);
if (instrumentationManager != null) {
try {
instrumentationManager.register(managedManager);
} catch (JMException jmex) {
LOG.log(Level.WARNING, "Registering ManagedRMManager failed.", jmex);
}
}
}
}
Aggregations