Search in sources :

Example 6 with SourcePolicyType

use of org.apache.cxf.ws.rm.manager.SourcePolicyType in project cxf by apache.

the class RMManager method setSourcePolicy.

/**
 * @param sp The sourcePolicy to set.
 */
public void setSourcePolicy(SourcePolicyType sp) {
    if (null == sp) {
        sp = new SourcePolicyType();
    }
    if (sp.getSequenceTerminationPolicy() == null) {
        SequenceTerminationPolicyType term = new SequenceTerminationPolicyType();
        term.setTerminateOnShutdown(true);
        sp.setSequenceTerminationPolicy(term);
    }
    sourcePolicy = sp;
}
Also used : SequenceTerminationPolicyType(org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType)

Example 7 with SourcePolicyType

use of org.apache.cxf.ws.rm.manager.SourcePolicyType in project cxf by apache.

the class ProxyTest method testCreateSequence.

@SuppressWarnings("unchecked")
private void testCreateSequence(boolean isServer) throws NoSuchMethodException, RMException {
    Method m = Proxy.class.getDeclaredMethod("invoke", new Class[] { OperationInfo.class, ProtocolVariation.class, Object[].class, Map.class, Exchange.class });
    Proxy proxy = EasyMock.createMockBuilder(Proxy.class).addMockedMethod(m).createMock(control);
    proxy.setReliableEndpoint(rme);
    RMManager manager = control.createMock(RMManager.class);
    EasyMock.expect(rme.getManager()).andReturn(manager).anyTimes();
    SourcePolicyType sp = control.createMock(SourcePolicyType.class);
    EasyMock.expect(manager.getSourcePolicy()).andReturn(sp).anyTimes();
    EasyMock.expect(sp.getAcksTo()).andReturn(null).anyTimes();
    Duration d = DatatypeFactory.createDuration("PT12H");
    EasyMock.expect(sp.getSequenceExpiration()).andReturn(d).anyTimes();
    EasyMock.expect(sp.isIncludeOffer()).andReturn(Boolean.TRUE).anyTimes();
    Duration dOffered = DatatypeFactory.createDuration("PT24H");
    EasyMock.expect(sp.getOfferedSequenceExpiration()).andReturn(dOffered).anyTimes();
    Source source = control.createMock(Source.class);
    EasyMock.expect(rme.getSource()).andReturn(source).anyTimes();
    Identifier offeredId = control.createMock(Identifier.class);
    EasyMock.expect(source.generateSequenceIdentifier()).andReturn(offeredId).anyTimes();
    Endpoint endpoint = control.createMock(Endpoint.class);
    EasyMock.expect(rme.getEndpoint(ProtocolVariation.RM10WSA200408)).andReturn(endpoint).anyTimes();
    EndpointInfo epi = control.createMock(EndpointInfo.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(epi).anyTimes();
    ServiceInfo si = control.createMock(ServiceInfo.class);
    EasyMock.expect(epi.getService()).andReturn(si).anyTimes();
    InterfaceInfo ii = control.createMock(InterfaceInfo.class);
    EasyMock.expect(si.getInterface()).andReturn(ii).anyTimes();
    OperationInfo oi = control.createMock(OperationInfo.class);
    org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType csr = null;
    if (isServer) {
        EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_ONEWAY_QNAME)).andReturn(oi).anyTimes();
        Endpoint ae = control.createMock(Endpoint.class);
        EasyMock.expect(rme.getApplicationEndpoint()).andReturn(ae).anyTimes();
        EasyMock.expect(ae.getExecutor()).andReturn(SynchronousExecutor.getInstance()).anyTimes();
    } else {
        EasyMock.expect(ii.getOperation(RM10Constants.CREATE_SEQUENCE_QNAME)).andReturn(oi).anyTimes();
        csr = new org.apache.cxf.ws.rm.v200502.CreateSequenceResponseType();
    }
    ExchangeImpl exchange = new ExchangeImpl();
    EasyMock.expect(proxy.invoke(EasyMock.same(oi), EasyMock.isA(ProtocolVariation.class), EasyMock.isA(Object[].class), EasyMock.isA(Map.class), EasyMock.isA(Exchange.class))).andReturn(csr).anyTimes();
    EndpointReferenceType defaultAcksTo = control.createMock(EndpointReferenceType.class);
    AttributedURIType aut = control.createMock(AttributedURIType.class);
    EasyMock.expect(aut.getValue()).andReturn("here").anyTimes();
    EasyMock.expect(defaultAcksTo.getAddress()).andReturn(aut).anyTimes();
    RelatesToType relatesTo = control.createMock(RelatesToType.class);
    control.replay();
    Map<String, Object> context = new HashMap<>();
    if (isServer) {
        assertNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, ProtocolVariation.RM10WSA200408, exchange, context));
    } else {
        assertNotNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer, ProtocolVariation.RM10WSA200408, exchange, context));
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) HashMap(java.util.HashMap) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Duration(javax.xml.datatype.Duration) Method(java.lang.reflect.Method) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) RelatesToType(org.apache.cxf.ws.addressing.RelatesToType) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Endpoint(org.apache.cxf.endpoint.Endpoint) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 8 with SourcePolicyType

use of org.apache.cxf.ws.rm.manager.SourcePolicyType in project cxf by apache.

the class RMManagerTest method testCustom.

@Test
public void testCustom() {
    Bus bus = new SpringBusFactory().createBus("org/apache/cxf/ws/rm/custom-rmmanager.xml", false);
    manager = bus.getExtension(RMManager.class);
    assertNotNull("sourcePolicy is not set.", manager.getSourcePolicy());
    assertNotNull("destinationPolicy is not set.", manager.getDestinationPolicy());
    manager.initialise();
    RMConfiguration cfg = manager.getConfiguration();
    assertNotNull("RMConfiguration is not set.", cfg);
    assertNotNull("deliveryAssurance is not set.", cfg.getDeliveryAssurance());
    assertFalse(cfg.isExponentialBackoff());
    assertEquals(10000L, cfg.getBaseRetransmissionInterval().longValue());
    assertEquals(10000L, cfg.getAcknowledgementIntervalTime());
    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());
    assertFalse(stp.isTerminateOnShutdown());
    assertEquals(0, stp.getMaxLength());
    DestinationPolicyType dp = manager.getDestinationPolicy();
    assertNotNull(dp.getAcksPolicy());
    assertEquals(dp.getAcksPolicy().getIntraMessageThreshold(), 0);
}
Also used : Bus(org.apache.cxf.Bus) SequenceTerminationPolicyType(org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) 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 9 with SourcePolicyType

use of org.apache.cxf.ws.rm.manager.SourcePolicyType in project cxf by apache.

the class RetransmissionQueueTest method testOnewayFaultHandlingWithoutRetry.

@Test
public void testOnewayFaultHandlingWithoutRetry() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus("/org/apache/cxf/systest/ws/rm/message-loss.xml");
    BusFactory.setDefaultBus(bus);
    LoggingInInterceptor in = new LoggingInInterceptor();
    bus.getInInterceptors().add(in);
    bus.getInFaultInterceptors().add(in);
    LoggingOutInterceptor out = new LoggingOutInterceptor();
    bus.getOutInterceptors().add(out);
    bus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(4000));
    SourcePolicyType sourcePolicy = new SourcePolicyType();
    RetryPolicyType retryP = new RetryPolicyType();
    retryP.setMaxRetries(0);
    sourcePolicy.setRetryPolicy(retryP);
    bus.getExtension(RMManager.class).setSourcePolicy(sourcePolicy);
    // an interceptor to simulate a transmission error
    MessageLossSimulator loser = new MessageLossSimulator();
    bus.getOutInterceptors().add(loser);
    bus.getOutFaultInterceptors().add(out);
    GreeterService gs = new GreeterService();
    final Greeter greeter = gs.getGreeterPort();
    updateAddressPort(greeter, PORT);
    LOG.fine("Created greeter client.");
    ConnectionHelper.setKeepAliveConnection(greeter, true);
    loser.setMode(-1);
    loser.setThrowsException(true);
    try {
        greeter.greetMeOneWay("oneway");
        fail("no retransmission so catch an Exception");
    } catch (Exception e) {
        assertEquals("simulated transmission exception", e.getMessage());
    }
    Thread.sleep(6000);
    RMManager manager = bus.getExtension(RMManager.class);
    boolean empty = manager.getRetransmissionQueue().isEmpty();
    assertFalse("RetransmissionQueue is empty", empty);
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) RMManager(org.apache.cxf.ws.rm.RMManager) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) Greeter(org.apache.cxf.greeter_control.Greeter) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) GreeterService(org.apache.cxf.greeter_control.GreeterService) RetryPolicyType(org.apache.cxf.ws.rm.manager.RetryPolicyType) Test(org.junit.Test)

Aggregations

SourcePolicyType (org.apache.cxf.ws.rm.manager.SourcePolicyType)9 SequenceTerminationPolicyType (org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType)4 Test (org.junit.Test)3 Date (java.util.Date)2 Duration (javax.xml.datatype.Duration)2 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)2 OperationInfo (org.apache.cxf.service.model.OperationInfo)2 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)2 DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)2 RetryPolicyType (org.apache.cxf.ws.rm.manager.RetryPolicyType)2 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)2 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Executor (java.util.concurrent.Executor)1 Bus (org.apache.cxf.Bus)1 Endpoint (org.apache.cxf.endpoint.Endpoint)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)1