Search in sources :

Example 6 with GreeterService

use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.

the class ClientServerGreeterBaseNoWsdlTest method testInvocation.

@Test
public void testInvocation() throws Exception {
    GreeterService service = new GreeterService();
    assertNotNull(service);
    try {
        Greeter greeter = service.getGreeterPort();
        updateAddressPort(greeter, PORT);
        String greeting = greeter.greetMe("Bonjour");
        assertNotNull("no response received from service", greeting);
        assertEquals("Hello Bonjour", greeting);
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : Greeter(org.apache.cxf.greeter_control.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) GreeterService(org.apache.cxf.greeter_control.GreeterService) Test(org.junit.Test)

Example 7 with GreeterService

use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.

the class ClientServerGreeterNoWsdlTest method testInvocation.

@Test
public void testInvocation() throws Exception {
    GreeterService service = new GreeterService();
    assertNotNull(service);
    try {
        Greeter greeter = service.getGreeterPort();
        updateAddressPort(greeter, PORT);
        String greeting = greeter.greetMe("Bonjour");
        assertNotNull("no response received from service", greeting);
        assertEquals("Hello Bonjour", greeting);
    } catch (UndeclaredThrowableException ex) {
        throw (Exception) ex.getCause();
    }
}
Also used : Greeter(org.apache.cxf.greeter_control.Greeter) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) GreeterService(org.apache.cxf.greeter_control.GreeterService) Test(org.junit.Test)

Example 8 with GreeterService

use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.

the class InterceptorFaultTest method setupGreeter.

private void setupGreeter(String cfgResource, boolean useDecoupledEndpoint) throws NumberFormatException, MalformedURLException {
    SpringBusFactory bf = new SpringBusFactory();
    controlBus = bf.createBus();
    BusFactory.setDefaultBus(controlBus);
    ControlService cs = new ControlService();
    control = cs.getControlPort();
    updateAddressPort(control, PORT);
    assertTrue("Failed to start greeter", control.startGreeter(cfgResource));
    greeterBus = bf.createBus(cfgResource);
    BusFactory.setDefaultBus(greeterBus);
    LOG.fine("Initialised greeter bus with configuration: " + cfgResource);
    if (null == comparator) {
        comparator = new PhaseComparator();
    }
    if (null == inPhases) {
        inPhases = new ArrayList<>();
        inPhases.addAll(greeterBus.getExtension(PhaseManager.class).getInPhases());
        Collections.sort(inPhases, comparator);
    }
    if (null == postUnMarshalPhase) {
        postUnMarshalPhase = getPhase(Phase.POST_UNMARSHAL);
    }
    GreeterService gs = new GreeterService();
    greeter = gs.getGreeterPort();
    updateAddressPort(greeter, PORT);
    LOG.fine("Created greeter client.");
    if (!useDecoupledEndpoint) {
        return;
    }
    // programatically configure decoupled endpoint that is guaranteed to
    // be unique across all test cases
    decoupledEndpointPort++;
    decoupledEndpoint = "http://localhost:" + allocatePort("decoupled-" + decoupledEndpointPort) + "/decoupled_endpoint";
    Client c = ClientProxy.getClient(greeter);
    HTTPConduit hc = (HTTPConduit) (c.getConduit());
    HTTPClientPolicy cp = hc.getClient();
    cp.setDecoupledEndpoint(decoupledEndpoint);
    LOG.fine("Using decoupled endpoint: " + cp.getDecoupledEndpoint());
}
Also used : PhaseComparator(org.apache.cxf.phase.PhaseComparator) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) ControlService(org.apache.cxf.greeter_control.ControlService) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) GreeterService(org.apache.cxf.greeter_control.GreeterService) Client(org.apache.cxf.endpoint.Client)

Example 9 with GreeterService

use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.

the class AbstractClientPersistenceTest method startClient.

void startClient() throws Exception {
    LOG.fine("Creating greeter client");
    System.setProperty("db.name", getPrefix() + "-client");
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus("/org/apache/cxf/systest/ws/rm/persistent.xml");
    BusFactory.setDefaultBus(bus);
    System.clearProperty("db.name");
    GreeterService gs = new GreeterService();
    greeter = gs.getGreeterPort();
    updateAddressPort(greeter, getPort());
    ((BindingProvider) greeter).getRequestContext().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.TRUE);
    out = new OutMessageRecorder();
    in = new InMessageRecorder();
    bus.getOutInterceptors().add(out);
    bus.getInInterceptors().add(in);
}
Also used : InMessageRecorder(org.apache.cxf.testutil.recorders.InMessageRecorder) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) OutMessageRecorder(org.apache.cxf.testutil.recorders.OutMessageRecorder) GreeterService(org.apache.cxf.greeter_control.GreeterService)

Example 10 with GreeterService

use of org.apache.cxf.greeter_control.GreeterService in project cxf by apache.

the class AbstractServerPersistenceTest method testRecovery.

@Test
public void testRecovery() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    LOG.fine("Created bus " + bus + " with default cfg");
    ControlService cs = new ControlService();
    Control control = cs.getControlPort();
    ConnectionHelper.setKeepAliveConnection(control, false, true);
    updateAddressPort(control, getPort());
    assertTrue("Failed to start greeter", control.startGreeter(SERVER_LOSS_CFG));
    LOG.fine("Started greeter server.");
    System.setProperty("db.name", getPrefix() + "-recovery");
    greeterBus = new SpringBusFactory().createBus(CFG);
    System.clearProperty("db.name");
    LOG.fine("Created bus " + greeterBus + " with cfg : " + CFG);
    BusFactory.setDefaultBus(greeterBus);
    // avoid early client resends
    greeterBus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(60000));
    GreeterService gs = new GreeterService();
    Greeter greeter = gs.getGreeterPort();
    updateAddressPort(greeter, getPort());
    LOG.fine("Created greeter client.");
    ConnectionHelper.setKeepAliveConnection(greeter, false, true);
    Client c = ClientProxy.getClient(greeter);
    HTTPConduit hc = (HTTPConduit) (c.getConduit());
    HTTPClientPolicy cp = hc.getClient();
    cp.setDecoupledEndpoint("http://localhost:" + getDecoupledPort() + "/decoupled_endpoint");
    out = new OutMessageRecorder();
    in = new InMessageRecorder();
    greeterBus.getOutInterceptors().add(out);
    greeterBus.getInInterceptors().add(in);
    LOG.fine("Configured greeter client.");
    Response<GreetMeResponse>[] responses = cast(new Response[4]);
    responses[0] = greeter.greetMeAsync("one");
    responses[1] = greeter.greetMeAsync("two");
    responses[2] = greeter.greetMeAsync("three");
    verifyMissingResponse(responses);
    control.stopGreeter(SERVER_LOSS_CFG);
    LOG.fine("Stopped greeter server");
    out.getOutboundMessages().clear();
    in.getInboundMessages().clear();
    control.startGreeter(CFG);
    String nl = System.getProperty("line.separator");
    LOG.fine("Restarted greeter server" + nl + nl);
    verifyServerRecovery(responses);
    responses[3] = greeter.greetMeAsync("four");
    verifyRetransmissionQueue();
    verifyAcknowledgementRange(1, 4);
    out.getOutboundMessages().clear();
    in.getInboundMessages().clear();
    greeterBus.shutdown(true);
    control.stopGreeter(CFG);
    bus.shutdown(true);
}
Also used : OutMessageRecorder(org.apache.cxf.testutil.recorders.OutMessageRecorder) GreeterService(org.apache.cxf.greeter_control.GreeterService) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) GreetMeResponse(org.apache.cxf.greeter_control.types.GreetMeResponse) Response(javax.xml.ws.Response) InMessageRecorder(org.apache.cxf.testutil.recorders.InMessageRecorder) Control(org.apache.cxf.greeter_control.Control) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) ControlService(org.apache.cxf.greeter_control.ControlService) Greeter(org.apache.cxf.greeter_control.Greeter) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test)

Aggregations

GreeterService (org.apache.cxf.greeter_control.GreeterService)42 Greeter (org.apache.cxf.greeter_control.Greeter)28 Test (org.junit.Test)28 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)15 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)10 BindingProvider (javax.xml.ws.BindingProvider)10 RMManager (org.apache.cxf.ws.rm.RMManager)10 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)7 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)7 ControlService (org.apache.cxf.greeter_control.ControlService)4 MBeanServer (javax.management.MBeanServer)3 ObjectName (javax.management.ObjectName)3 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)3 IOException (java.io.IOException)2 List (java.util.List)2 TransformerException (javax.xml.transform.TransformerException)2 DOMSource (javax.xml.transform.dom.DOMSource)2 WebServiceException (javax.xml.ws.WebServiceException)2 Bus (org.apache.cxf.Bus)2 Client (org.apache.cxf.endpoint.Client)2