Search in sources :

Example 1 with ControlService

use of org.apache.cxf.greeter_control.ControlService 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 2 with ControlService

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

the class FailoverAddressOverrideTest method startTarget.

protected void startTarget(String address) throws Exception {
    ControlService cs = new ControlService();
    control = cs.getControlPort();
    updateAddressPort(control, PORT_0);
    LOG.info("starting replicated target: " + address);
    assertTrue("Failed to start greeter", control.startGreeter(address));
    targets.add(address);
}
Also used : ControlService(org.apache.cxf.greeter_control.ControlService)

Example 3 with ControlService

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

the class SequenceTest method initControl.

private void initControl(SpringBusFactory bf, String cfgResource) {
    controlBus = bf.createBus();
    BusFactory.setDefaultBus(controlBus);
    ControlService cs = new ControlService();
    control = cs.getControlPort();
    try {
        updateAddressPort(control, PORT);
    } catch (Exception ex) {
    // ignore
    }
    assertTrue("Failed to start greeter", control.startGreeter(cfgResource));
}
Also used : ControlService(org.apache.cxf.greeter_control.ControlService) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) WebServiceException(javax.xml.ws.WebServiceException)

Example 4 with ControlService

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

the class WSRM12ServerCycleTest method runTest.

public void runTest(String cfg, boolean faultOnRestart) throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    ControlService cs = new ControlService();
    Control control = cs.getControlPort();
    ConnectionHelper.setKeepAliveConnection(control, false, true);
    updateAddressPort(control, PORT);
    assertTrue("Failed to start greeter", control.startGreeter(cfg));
    System.setProperty("db.name", getPrefix() + "-recovery");
    Bus greeterBus = new SpringBusFactory().createBus();
    System.clearProperty("db.name");
    BusFactory.setDefaultBus(greeterBus);
    // avoid early client resends
    greeterBus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(Long.valueOf(60000));
    GreeterService gs = new GreeterService();
    Greeter greeter = gs.getGreeterPort(new LoggingFeature(), new AddressingFeature(), wsrm());
    updateAddressPort(greeter, PORT);
    greeter.greetMe("one");
    greeter.greetMe("two");
    greeter.greetMe("three");
    control.stopGreeter(cfg);
    // make sure greeter is down
    Thread.sleep(1000);
    control.startGreeter(cfg);
    // CXF-7392
    if (faultOnRestart) {
        try {
            greeter.greetMe("four");
        } catch (SOAPFaultException ex) {
            assertTrue(ex.getMessage().contains("wsrm:Identifier"));
        // expected, sequence identifier doesn't exist on other side
        }
    } else {
        // this should work as the sequence should be recovered on the server side
        greeter.greetMe("four");
    }
    ((Closeable) greeter).close();
    greeterBus.shutdown(true);
    control.stopGreeter(cfg);
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) Control(org.apache.cxf.greeter_control.Control) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) AddressingFeature(javax.xml.ws.soap.AddressingFeature) ControlService(org.apache.cxf.greeter_control.ControlService) Greeter(org.apache.cxf.greeter_control.Greeter) LoggingFeature(org.apache.cxf.ext.logging.LoggingFeature) Closeable(java.io.Closeable) GreeterService(org.apache.cxf.greeter_control.GreeterService) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException)

Example 5 with ControlService

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

the class FailoverTest method startTarget.

protected void startTarget(String address) throws Exception {
    ControlService cs = new ControlService();
    control = cs.getControlPort();
    updateAddressPort(control, PORT_0);
    LOG.info("starting replicated target: " + address);
    assertTrue("Failed to start greeter", control.startGreeter(address));
    targets.add(address);
}
Also used : ControlService(org.apache.cxf.greeter_control.ControlService)

Aggregations

ControlService (org.apache.cxf.greeter_control.ControlService)8 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)4 GreeterService (org.apache.cxf.greeter_control.GreeterService)4 Client (org.apache.cxf.endpoint.Client)2 Control (org.apache.cxf.greeter_control.Control)2 Greeter (org.apache.cxf.greeter_control.Greeter)2 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)2 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)2 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 TransformerException (javax.xml.transform.TransformerException)1 Response (javax.xml.ws.Response)1 WebServiceException (javax.xml.ws.WebServiceException)1 AddressingFeature (javax.xml.ws.soap.AddressingFeature)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 Bus (org.apache.cxf.Bus)1 LoggingFeature (org.apache.cxf.ext.logging.LoggingFeature)1 GreetMeResponse (org.apache.cxf.greeter_control.types.GreetMeResponse)1 PhaseComparator (org.apache.cxf.phase.PhaseComparator)1 InMessageRecorder (org.apache.cxf.testutil.recorders.InMessageRecorder)1