Search in sources :

Example 1 with DestinationPolicyType

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);
    }
}
Also used : Message(org.apache.cxf.message.Message) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Exchange(org.apache.cxf.message.Exchange) RetryPolicyType(org.apache.cxf.ws.rm.manager.RetryPolicyType) Test(org.junit.Test)

Example 2 with DestinationPolicyType

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);
}
Also used : SequenceTerminationPolicyType(org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Date(java.util.Date) Test(org.junit.Test)

Example 3 with DestinationPolicyType

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());
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) Message(org.apache.cxf.message.Message) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Expires(org.apache.cxf.ws.rm.v200502.Expires) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)

Example 4 with DestinationPolicyType

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());
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) Message(org.apache.cxf.message.Message) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Expires(org.apache.cxf.ws.rm.v200502.Expires) CreateSequenceResponseType(org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)

Example 5 with DestinationPolicyType

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);
            }
        }
    }
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) RedeliveryQueueImpl(org.apache.cxf.ws.rm.soap.RedeliveryQueueImpl) RetransmissionQueueImpl(org.apache.cxf.ws.rm.soap.RetransmissionQueueImpl) DeliveryAssurance(org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance) JMException(javax.management.JMException) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) PostConstruct(javax.annotation.PostConstruct)

Aggregations

DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)11 Message (org.apache.cxf.message.Message)7 AcksPolicyType (org.apache.cxf.ws.rm.manager.AcksPolicyType)7 CreateSequenceResponseType (org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType)4 Expires (org.apache.cxf.ws.rm.v200502.Expires)4 Test (org.junit.Test)3 Date (java.util.Date)2 SequenceTerminationPolicyType (org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType)2 SourcePolicyType (org.apache.cxf.ws.rm.manager.SourcePolicyType)2 PostConstruct (javax.annotation.PostConstruct)1 JMException (javax.management.JMException)1 Duration (javax.xml.datatype.Duration)1 Bus (org.apache.cxf.Bus)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)1 Exchange (org.apache.cxf.message.Exchange)1 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)1 DeliveryAssurance (org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance)1 RMFeature (org.apache.cxf.ws.rm.feature.RMFeature)1 RetryPolicyType (org.apache.cxf.ws.rm.manager.RetryPolicyType)1