Search in sources :

Example 1 with PhaseComparator

use of org.apache.cxf.phase.PhaseComparator 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)

Aggregations

SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 Client (org.apache.cxf.endpoint.Client)1 ControlService (org.apache.cxf.greeter_control.ControlService)1 GreeterService (org.apache.cxf.greeter_control.GreeterService)1 PhaseComparator (org.apache.cxf.phase.PhaseComparator)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)1