Search in sources :

Example 6 with BusFactory

use of org.apache.cxf.BusFactory in project cxf by apache.

the class JettyDigestAuthTest method testGetWSDL.

@org.junit.Test
public void testGetWSDL() throws Exception {
    BusFactory bf = BusFactory.newInstance();
    Bus bus = bf.createBus();
    bus.getInInterceptors().add(new LoggingInInterceptor());
    bus.getOutInterceptors().add(new LoggingOutInterceptor());
    MyHTTPConduitConfigurer myHttpConduitConfig = new MyHTTPConduitConfigurer();
    bus.setExtension(myHttpConduitConfig, HTTPConduitConfigurer.class);
    JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance(bus);
    factory.createClient(ADDRESS + "?wsdl");
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) Bus(org.apache.cxf.Bus) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) BusFactory(org.apache.cxf.BusFactory) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Test(org.junit.Test)

Example 7 with BusFactory

use of org.apache.cxf.BusFactory in project jbossws-cxf by jbossws.

the class AbstractClient method testBusCreation.

public static void testBusCreation() throws BusTestException {
    Bus initialDefaultBus = BusFactory.getDefaultBus(false);
    Bus initialThreadBus = BusFactory.getThreadDefaultBus(false);
    BusFactory factory = BusFactory.newInstance();
    Bus bus = factory.createBus();
    assert (bus != null);
    if (// if the thread bus was not set before, it should now be
    initialThreadBus == null) {
        checkThreadBus(bus);
    }
    checkDefaultBus(initialDefaultBus);
    BusFactory.setThreadDefaultBus(initialThreadBus);
    checkThreadBus(initialThreadBus);
    checkDefaultBus(initialDefaultBus);
}
Also used : Bus(org.apache.cxf.Bus) BusFactory(org.apache.cxf.BusFactory)

Example 8 with BusFactory

use of org.apache.cxf.BusFactory in project jbossws-cxf by jbossws.

the class AbstractClient method testWebServiceRef.

public static void testWebServiceRef(Endpoint port) throws BusTestException {
    Bus initialDefaultBus = BusFactory.getDefaultBus(false);
    Bus threadBus = BusFactory.getThreadDefaultBus(false);
    // does not change anything to the bus, as the port is already created when injecting serviceref
    performInvocation(port);
    checkDefaultBus(initialDefaultBus);
    checkThreadBus(threadBus);
    try {
        BusFactory.setThreadDefaultBus(null);
        // does not change anything to the bus, as the port is already created when injecting serviceref
        performInvocation(port);
        checkDefaultBus(initialDefaultBus);
        checkThreadBus(null);
        BusFactory factory = BusFactory.newInstance();
        // internally sets the thread bus
        Bus bus = factory.createBus();
        // does not change anything to the bus, as the port is already created when injecting serviceref
        performInvocation(port);
        checkDefaultBus(initialDefaultBus);
        checkThreadBus(bus);
    } finally {
        BusFactory.setThreadDefaultBus(threadBus);
    }
}
Also used : Bus(org.apache.cxf.Bus) BusFactory(org.apache.cxf.BusFactory)

Example 9 with BusFactory

use of org.apache.cxf.BusFactory in project jbossws-cxf by jbossws.

the class Helper method verifyCXF.

public static void verifyCXF() {
    // check BusFactory customization; this is required by the JBWS-CXF Configurer integration (HTTPConduit customization, JAXBIntros, ...)
    BusFactory factory = BusFactory.newInstance();
    if (!(factory instanceof JBossWSBusFactory))
        throw new RuntimeException("Expected " + JBossWSBusFactory.class + " but got " + (factory == null ? null : factory.getClass()));
    // check the Apache CXF JAXWS implementation is actually used
    Object obj = getImplementationObject();
    if (!obj.getClass().getName().contains("cxf"))
        throw new RuntimeException("JAXWS implementation is not properly selected or endorsed!");
}
Also used : JBossWSBusFactory(org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory) BusFactory(org.apache.cxf.BusFactory) JBossWSBusFactory(org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory)

Example 10 with BusFactory

use of org.apache.cxf.BusFactory in project jbossws-cxf by jbossws.

the class Helper method testJBossWSCXFBus.

/**
 * Verify the BusFactory.newInstance() still return the JBossWS-CXF version of BusFactory
 * (the web app has a dependency on jbossws-cxf-client) and that still create a plain bus
 * version, without being fooled by the Spring availability in the TCCL when Spring is not
 * installed in the AS.
 *
 * @return
 */
public boolean testJBossWSCXFBus() {
    BusFactory factory = BusFactory.newInstance();
    if (!(factory instanceof JBossWSBusFactory)) {
        throw new RuntimeException("Expected JBossWSBusFactory");
    }
    Bus bus = null;
    try {
        // set Configurer.USER_CFG_FILE_PROPERTY_NAME so that if the SpringBusFactory is
        // internally erroneously used, that won't fallback delegating to the non Spring
        // one, which would shade the issue
        final String prop = System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME);
        try {
            System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME, "unexistentfile.xml");
            bus = factory.createBus();
            // the created bus should not be a SpringBus, as the classloader for CXF has no visibility over the deployment spring jars
            return !isSpringBus(bus);
        } finally {
            if (prop == null) {
                System.clearProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME);
            } else {
                System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME, prop);
            }
        }
    } finally {
        if (bus != null) {
            bus.shutdown(true);
        }
    }
}
Also used : Bus(org.apache.cxf.Bus) JBossWSBusFactory(org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory) BusFactory(org.apache.cxf.BusFactory) JBossWSBusFactory(org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory)

Aggregations

BusFactory (org.apache.cxf.BusFactory)20 Bus (org.apache.cxf.Bus)14 Test (org.junit.Test)5 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)4 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)4 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)4 JaxWsDynamicClientFactory (org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory)4 CXFBusFactory (org.apache.cxf.bus.CXFBusFactory)3 JBossWSBusFactory (org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory)3 Subject (javax.security.auth.Subject)2 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)2 Before (org.junit.Before)2 IOException (java.io.IOException)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ResourceException (javax.resource.ResourceException)1 ManagedConnection (javax.resource.spi.ManagedConnection)1 QName (javax.xml.namespace.QName)1 PooledConnectionFactory (org.apache.activemq.pool.PooledConnectionFactory)1