org.apache.cxf.BusFactory Java Examples

The following examples show how to use org.apache.cxf.BusFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RetransmissionQueueTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void run()  {
    SpringBusFactory bf = new SpringBusFactory();
    Bus 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.getOutFaultInterceptors().add(out);

    GreeterImpl implementor = new GreeterImpl();
    String address = "http://localhost:" + PORT + "/SoapContext/GreeterPort";

    Endpoint ep = Endpoint.create(implementor);
    ep.publish(address);

    LOG.info("Published greeter endpoint.");
}
 
Example #2
Source File: JMSTransactionTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static void startBusAndJMS(String brokerURI) {
    try {
        transactionManager = new GeronimoTransactionManager();
    } catch (XAException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
    bus = BusFactory.getDefaultBus();
    registerTransactionManager();
    ActiveMQXAConnectionFactory cf1 = new ActiveMQXAConnectionFactory(brokerURI);
    cf1.setRedeliveryPolicy(redeliveryPolicy());
    JcaPooledConnectionFactory pcf = new JcaPooledConnectionFactory();
    pcf.setTransactionManager(transactionManager);
    pcf.setConnectionFactory(cf1);
    cf = pcf;
    cff = new ConnectionFactoryFeature(pcf);
}
 
Example #3
Source File: BusExtensionLoadingTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Tests the ExtensionManagerBus can be built using a given classloader
 *
 * @throws Exception
 */
@Test
public void testBusConstructionWithoutTCCL() throws Exception {
    ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(new TestClassLoader());
        BusFactory factory = new CXFBusFactory() {
            public Bus createBus(Map<Class<?>, Object> e, Map<String, Object> properties) {
                return new ExtensionManagerBus(e, properties, this.getClass().getClassLoader());
            }
        };
        Bus bus = factory.createBus();
        assertNotNullExtensions(bus);
        bus.shutdown(true);
    } finally {
        Thread.currentThread().setContextClassLoader(origClassLoader);
    }
}
 
Example #4
Source File: STSClientTest.java    From steady with Apache License 2.0 6 votes vote down vote up
@Test
public void testConfigureViaEPR() throws Exception {

    final Set<Class<?>> addressingClasses = new HashSet<Class<?>>();
    addressingClasses.add(org.apache.cxf.ws.addressing.wsdl.ObjectFactory.class);
    addressingClasses.add(org.apache.cxf.ws.addressing.ObjectFactory.class);

    JAXBContext ctx = JAXBContextCache.getCachedContextAndSchemas(addressingClasses, null, null, null,
                                                                  true).getContext();
    Unmarshaller um = ctx.createUnmarshaller();
    InputStream inStream = getClass().getResourceAsStream("epr.xml");
    JAXBElement<?> el = (JAXBElement<?>)um.unmarshal(inStream);
    EndpointReferenceType ref = (EndpointReferenceType)el.getValue();

    Bus bus = BusFactory.getThreadDefaultBus();
    STSClient client = new STSClient(bus);
    client.configureViaEPR(ref, false);

    assertEquals("http://localhost:8080/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl",
                 client.getWsdlLocation());
    assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService"),
                 client.getServiceQName());
    assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port"),
                 client.getEndpointQName());
}
 
Example #5
Source File: STSClientTest.java    From steady with Apache License 2.0 6 votes vote down vote up
@Test
public void testConfigureViaEPR() throws Exception {

    final Set<Class<?>> addressingClasses = new HashSet<Class<?>>();
    addressingClasses.add(org.apache.cxf.ws.addressing.wsdl.ObjectFactory.class);
    addressingClasses.add(org.apache.cxf.ws.addressing.ObjectFactory.class);

    JAXBContext ctx = JAXBContextCache.getCachedContextAndSchemas(addressingClasses, null, null, null,
                                                                  true).getContext();
    Unmarshaller um = ctx.createUnmarshaller();
    InputStream inStream = getClass().getResourceAsStream("epr.xml");
    JAXBElement<?> el = (JAXBElement<?>)um.unmarshal(inStream);
    EndpointReferenceType ref = (EndpointReferenceType)el.getValue();

    Bus bus = BusFactory.getThreadDefaultBus();
    STSClient client = new STSClient(bus);
    client.configureViaEPR(ref, false);

    assertEquals("http://localhost:8080/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl",
                 client.getWsdlLocation());
    assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService"),
                 client.getServiceQName());
    assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port"),
                 client.getEndpointQName());
}
 
Example #6
Source File: ClientMtomXopWithJMSTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@BeforeClass
public static void startServers() throws Exception {
    Object implementor = new TestMtomJMSImpl();
    bus = BusFactory.getDefaultBus();

    ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
    PooledConnectionFactory cfp = new PooledConnectionFactory(cf);
    cff = new ConnectionFactoryFeature(cfp);

    EndpointImpl ep = (EndpointImpl)Endpoint.create(implementor);
    ep.getFeatures().add(cff);
    ep.getInInterceptors().add(new TestMultipartMessageInterceptor());
    ep.getOutInterceptors().add(new TestAttachmentOutInterceptor());
    //ep.getInInterceptors().add(new LoggingInInterceptor());
    //ep.getOutInterceptors().add(new LoggingOutInterceptor());
    SOAPBinding jaxWsSoapBinding = (SOAPBinding)ep.getBinding();
    jaxWsSoapBinding.setMTOMEnabled(true);
    ep.publish();
}
 
Example #7
Source File: UsernameTokenTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@org.junit.Test
public void testPlaintextWSDLOverHTTPS() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = UsernameTokenTest.class.getResource("client-remote-wsdl.xml");

    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);

    URL wsdl = new URL("https://localhost:" + PORT + "/DoubleItUTPlaintext?wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItPlaintextPort");
    DoubleItPortType utPort =
            service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(utPort, test.getPort());

    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(utPort);
    }

    assertEquals(50, utPort.doubleIt(25));

    ((java.io.Closeable)utPort).close();
    bus.shutdown(true);
}
 
Example #8
Source File: MTOMSecurityTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@org.junit.Test
public void testSignedMTOMAction() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = MTOMSecurityTest.class.getResource("client.xml");

    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);

    URL wsdl = MTOMSecurityTest.class.getResource("DoubleItMtom.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSignedMTOMActionPort");
    DoubleItMtomPortType port =
            service.getPort(portQName, DoubleItMtomPortType.class);
    updateAddressPort(port, PORT);

    DataSource source = new FileDataSource(new File("src/test/resources/java.jpg"));
    DoubleIt4 doubleIt = new DoubleIt4();
    doubleIt.setNumberToDouble(25);
    assertEquals(50, port.doubleIt4(25, new DataHandler(source)));

    ((java.io.Closeable)port).close();
    bus.shutdown(true);
}
 
Example #9
Source File: X509TokenTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@org.junit.Test
public void testAsymmetricEncryptBeforeSigningNoEnc() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = X509TokenTest.class.getResource("client.xml");

    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);

    URL wsdl = X509TokenTest.class.getResource("DoubleItX509.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricEncryptBeforeSigningNoEncPort");
    DoubleItPortType x509Port =
            service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(x509Port, test.getPort());

    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(x509Port);
    }

    assertEquals(50, x509Port.doubleIt(25));

    ((java.io.Closeable)x509Port).close();
    bus.shutdown(true);
}
 
Example #10
Source File: X509TokenTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@org.junit.Test
public void testSymmetricWithOptionalAddressing() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = X509TokenTest.class.getResource("client.xml");

    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);

    URL wsdl = X509TokenTest.class.getResource("DoubleItX509Addressing.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSymmetricAddressingPort");
    DoubleItPortType x509Port =
            service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(x509Port, test.getPort());

    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(x509Port);
    }

    assertEquals(50, x509Port.doubleIt(25));

    ((java.io.Closeable)x509Port).close();
    bus.shutdown(true);
}
 
Example #11
Source File: UsernameTokenTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@org.junit.Test
public void testSignedEncrypted() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = UsernameTokenTest.class.getResource("client.xml");

    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);

    URL wsdl = UsernameTokenTest.class.getResource("DoubleItUt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSignedEncryptedPort");
    DoubleItPortType utPort =
            service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(utPort, test.getPort());

    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(utPort);
    }

    assertEquals(50, utPort.doubleIt(25));

    ((java.io.Closeable)utPort).close();
    bus.shutdown(true);
}
 
Example #12
Source File: X509TokenTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@org.junit.Test
public void testKeyIdentifierEncryptBeforeSigning() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = X509TokenTest.class.getResource("client.xml");

    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);

    URL wsdl = X509TokenTest.class.getResource("DoubleItX509.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItKeyIdentifierEncryptBeforeSigningPort");
    DoubleItPortType x509Port =
            service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(x509Port, test.getPort());

    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(x509Port);
    }

    assertEquals(50, x509Port.doubleIt(25));

    ((java.io.Closeable)x509Port).close();
    bus.shutdown(true);
}
 
Example #13
Source File: ServiceInvocationAckBase.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void setupGreeter(String cfgResource) throws NumberFormatException, MalformedURLException {

        SpringBusFactory bf = new SpringBusFactory();

        controlBus = bf.createBus();
        BusFactory.setDefaultBus(controlBus);

        ControlService cs = new ControlService();
        control = cs.getControlPort();
        updateAddressPort(control, getPort());

        assertTrue("Failed to start greeter", control.startGreeter(cfgResource));

        System.setProperty("db.name", getPrefix());
        greeterBus = bf.createBus(cfgResource);
        BusFactory.setDefaultBus(greeterBus);
        System.clearProperty("db.name");
        LOG.fine("Initialised greeter bus with configuration: " + cfgResource);

        GreeterService gs = new GreeterService();

        greeter = gs.getGreeterPort();
        updateAddressPort(greeter, getPort());
        LOG.fine("Created greeter client.");

    }
 
Example #14
Source File: AbstractResourceInfo.java    From cxf with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
public static void clearAllMaps() {
    Bus bus = BusFactory.getThreadDefaultBus(false);
    if (bus != null) {
        Object property = bus.getProperty(FIELD_PROXY_MAP);
        if (property != null) {
            ((Map)property).clear();
        }
        property = bus.getProperty(SETTER_PROXY_MAP);
        if (property != null) {
            ((Map)property).clear();
        }
        property = bus.getProperty(CONSTRUCTOR_PROXY_MAP);
        if (property != null) {
            ((Map)property).clear();
        }
    }
}
 
Example #15
Source File: RMPolicyWsdlTestBase.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void run()  {
    SpringBusFactory bf = new SpringBusFactory();
    Bus bus = bf.createBus(getConfigPath());
    BusFactory.setDefaultBus(bus);
    setBus(bus);

    ServerRegistry sr = bus.getExtension(ServerRegistry.class);
    PolicyEngine pe = bus.getExtension(PolicyEngine.class);

    List<PolicyAssertion> assertions1
        = getAssertions(pe, sr.getServers().get(0));
    assertEquals("2 assertions should be available", 2, assertions1.size());
    List<PolicyAssertion> assertions2 =
        getAssertions(pe, sr.getServers().get(1));
    assertEquals("1 assertion should be available", 1, assertions2.size());

    LOG.info("Published greeter endpoints.");
}
 
Example #16
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {
    setBus(BusFactory.getDefaultBus());
    Object implementor = new GreeterImpl();
    String address = "http://localhost:"
        + TestUtil.getPortNumber(DispatchXMLClientServerTest.class)
        + "/XMLService/XMLDispatchPort";
    ep = Endpoint.publish(address, implementor);
}
 
Example #17
Source File: BookServerJwtAuthnAuthz.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {
    SpringBusFactory bf = new SpringBusFactory();
    Bus springBus = bf.createBus(SERVER_CONFIG_FILE);
    BusFactory.setDefaultBus(springBus);
    setBus(springBus);

    try {
        new BookServerJwtAuthnAuthz();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #18
Source File: ClientAuthTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@org.junit.Test
public void testChainTrust() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = ClientAuthTest.class.getResource("client-auth-chain.xml");

    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);

    URL url = SOAPService.WSDL_LOCATION;
    SOAPService service = new SOAPService(url, SOAPService.SERVICE);
    assertNotNull("Service is null", service);
    final Greeter port = service.getHttpsPort();
    assertNotNull("Port is null", port);

    updateAddressPort(port, PORT2);

    // Enable Async
    if (async) {
        ((BindingProvider)port).getRequestContext().put("use.async.http.conduit", true);
    }

    assertEquals(port.greetMe("Kitty"), "Hello Kitty");

    ((java.io.Closeable)port).close();
    bus.shutdown(true);
}
 
Example #19
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {
    // set the configuration file
    SpringBusFactory factory = new SpringBusFactory();
    Bus bus = factory.createBus("org/apache/cxf/systest/source/cxf.xml");
    BusFactory.setDefaultBus(bus);
    setBus(bus);
    Endpoint.publish("http://localhost:" + PORT + "/SoapContext/SoapPort",
                     new GreeterImpl());

    Endpoint.publish("http://localhost:" + PORT + "/SOAPDocLitBareService/SoapPort",
                     new PutLastTradePriceImpl());
}
 
Example #20
Source File: BSTServer.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run()  {
    URL busFile = BSTServer.class.getResource("bst-server.xml");
    Bus busLocal = new SpringBusFactory().createBus(busFile);
    BusFactory.setDefaultBus(busLocal);
    setBus(busLocal);

    try {
        new BSTServer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #21
Source File: AbstractVmJMSTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static void startBusAndJMS(String brokerURI) {
    bus = BusFactory.getDefaultBus();
    ActiveMQConnectionFactory cf1 = new ActiveMQConnectionFactory(brokerURI);
    RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
    redeliveryPolicy.setMaximumRedeliveries(1);
    redeliveryPolicy.setInitialRedeliveryDelay(1000);
    cf1.setRedeliveryPolicy(redeliveryPolicy());
    cf = new PooledConnectionFactory(cf1);
    cff = new ConnectionFactoryFeature(cf);
}
 
Example #22
Source File: STSServer.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run()  {
    URL busFile = STSServer.class.getResource("cxf-issuer-sts-transport.xml");
    Bus busLocal = new SpringBusFactory().createBus(busFile);
    BusFactory.setDefaultBus(busLocal);
    setBus(busLocal);

    try {
        new STSServer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #23
Source File: ServerDerived.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run()  {
    URL busFile = ServerDerived.class.getResource("server-derived.xml");
    Bus busLocal = new SpringBusFactory().createBus(busFile);
    BusFactory.setDefaultBus(busLocal);
    setBus(busLocal);

    try {
        new ServerDerived();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #24
Source File: IntrospectionServiceTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run() {
    SpringBusFactory bf = new SpringBusFactory();
    Bus springBus = bf.createBus(SERVER_CONFIG_FILE);
    BusFactory.setDefaultBus(springBus);
    setBus(springBus);

    try {
        new BookServerOAuth2IntrospectionJPA();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #25
Source File: STSTokenOutInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBasicTransportBinding() throws Exception {
    // Setup HttpsURLConnection to get STS WSDL
    configureDefaultHttpsConnection();

    Bus bus = BusFactory.getThreadDefaultBus();
    STSAuthParams authParams = new STSAuthParams(
               AuthMode.UT_TRANSPORT,
               "alice",
               "org.apache.cxf.systest.sts.common.CommonCallbackHandler",
               null,
               null);

    STSTokenOutInterceptor interceptor = new STSTokenOutInterceptor(
                authParams,
                "https://localhost:" + STSPORT + STS_TRANSPORT_WSDL_LOCATION_RELATIVE,
                bus);

    interceptor.getSTSClient().setTlsClientParameters(TLSClientParametersUtils.getTLSClientParameters());

    MessageImpl message = prepareMessage(bus, null, SERVICE_ENDPOINT_TRANSPORT);

    interceptor.handleMessage(message);

    SecurityToken token = (SecurityToken)message.getExchange().get(SecurityConstants.TOKEN);
    validateSecurityToken(token);
}
 
Example #26
Source File: ResourceUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static ClassResourceInfo createClassResourceInfo(final Class<?> rClass,
                                                        final Class<?> sClass,
                                                        boolean root,
                                                        boolean enableStatic) {
    return createClassResourceInfo(rClass, sClass, root, enableStatic, BusFactory.getThreadDefaultBus());

}
 
Example #27
Source File: StaxEndorsingServer.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run()  {
    URL busFile = StaxEndorsingServer.class.getResource("stax-endorsing-server.xml");
    Bus busLocal = new SpringBusFactory().createBus(busFile);
    BusFactory.setDefaultBus(busLocal);
    setBus(busLocal);

    try {
        new StaxEndorsingServer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #28
Source File: StaxServer.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected void run()  {
    URL busFile = StaxServer.class.getResource("stax-cxf-service.xml");
    Bus busLocal = new SpringBusFactory().createBus(busFile);
    BusFactory.setDefaultBus(busLocal);
    setBus(busLocal);

    try {
        new StaxServer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #29
Source File: KerberosTokenTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void runKerberosSTSTest(String portName, boolean streaming, String portNumber,
                                String stsPortNumber) throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = KerberosTokenTest.class.getResource("sts-client.xml");

    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);

    URL wsdl = KerberosTokenTest.class.getResource("DoubleItKerberos.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, portName);
    DoubleItPortType kerberosPort =
            service.getPort(portQName, DoubleItPortType.class);

    TestUtil.updateAddressPort(kerberosPort, portNumber);

    SecurityTestUtil.updateSTSPort((BindingProvider)kerberosPort, stsPortNumber);

    if (streaming) {
        SecurityTestUtil.enableStreaming(kerberosPort);
    }

    Assert.assertEquals(50, kerberosPort.doubleIt(25));

    ((java.io.Closeable)kerberosPort).close();
    bus.shutdown(true);
}
 
Example #30
Source File: SecureConversationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * 2.4.1 (WSS 1.0) Secure Conversation bootstrapped by Mutual
 * Authentication with X.509 Certificates
 */
@org.junit.Test
public void testSecureConversation() throws Exception {

    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = SecureConversationTest.class.getResource("client.xml");

    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);

    URL wsdl = SecureConversationTest.class.getResource("DoubleItSecConv.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    QName portQName = new QName(NAMESPACE, "DoubleItSecureConversationPort");
    DoubleItPortType samlPort =
            service.getPort(portQName, DoubleItPortType.class);
    updateAddressPort(samlPort, test.getPort());

    if (test.isStreaming()) {
        SecurityTestUtil.enableStreaming(samlPort);
    }

    samlPort.doubleIt(25);

    ((java.io.Closeable)samlPort).close();
    bus.shutdown(true);
}