Search in sources :

Example 1 with GZIPFeature

use of org.apache.cxf.transport.common.gzip.GZIPFeature in project jbossws-cxf by jbossws.

the class Helper method testGZIPUsingFeatureOnBus.

public boolean testGZIPUsingFeatureOnBus() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        GZIPFeature gzipFeature = new GZIPFeature();
        gzipFeature.setThreshold(0);
        gzipFeature.initialize(bus);
        HelloWorld port = getPort();
        return ("foo".equals(port.echo("foo")));
    } finally {
        bus.shutdown(true);
    }
}
Also used : GZIPFeature(org.apache.cxf.transport.common.gzip.GZIPFeature) Bus(org.apache.cxf.Bus)

Example 2 with GZIPFeature

use of org.apache.cxf.transport.common.gzip.GZIPFeature in project jbossws-cxf by jbossws.

the class Helper method testGZIPUsingFeatureOnClient.

public boolean testGZIPUsingFeatureOnClient() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        // CXF way
        BusFactory.setThreadDefaultBus(bus);
        HelloWorld port = getPort();
        Client client = ClientProxy.getClient(port);
        GZIPFeature gzipFeature = new GZIPFeature();
        gzipFeature.setThreshold(0);
        // bus parameter not actually used
        gzipFeature.initialize(client, null);
        if (!"foo".equals(port.echo("foo"))) {
            return false;
        }
    } finally {
        bus.shutdown(true);
    }
    bus = BusFactory.newInstance().createBus();
    try {
        // JAX-WS way
        BusFactory.setThreadDefaultBus(bus);
        GZIPFeature gzipFeature = new GZIPFeature();
        gzipFeature.setThreshold(0);
        HelloWorld port = getPort(gzipFeature);
        if (!"foo".equals(port.echo("foo"))) {
            return false;
        }
    } finally {
        bus.shutdown(true);
    }
    return true;
}
Also used : GZIPFeature(org.apache.cxf.transport.common.gzip.GZIPFeature) Bus(org.apache.cxf.Bus) Client(org.apache.cxf.endpoint.Client)

Example 3 with GZIPFeature

use of org.apache.cxf.transport.common.gzip.GZIPFeature in project cxf by apache.

the class AnnotationsFactoryBeanListener method addGZipSupport.

private void addGZipSupport(Endpoint ep, Bus bus, GZIP annotation) {
    if (annotation != null) {
        try {
            GZIPFeature feature = new GZIPFeature();
            feature.setThreshold(annotation.threshold());
            feature.setForce(annotation.force());
            feature.initialize(ep, bus);
        } catch (Exception e) {
        // ignore - just assume it's an unsupported/unknown annotation
        }
    }
}
Also used : GZIPFeature(org.apache.cxf.transport.common.gzip.GZIPFeature)

Example 4 with GZIPFeature

use of org.apache.cxf.transport.common.gzip.GZIPFeature in project cxf by apache.

the class SoapJmsSpecTest method startServers.

@BeforeClass
public static void startServers() throws Exception {
    startBusAndJMS(SoapJmsSpecTest.class);
    publish("jms:queue:test.cxf.jmstransport.queue2", new GreeterSpecImpl());
    publish("jms:queue:test.cxf.jmstransport.queue5", new GreeterSpecWithPortError());
    EndpointImpl ep = (EndpointImpl) Endpoint.create(null, new GreeterSpecImpl());
    ep.setBus(bus);
    ep.getFeatures().add(new GZIPFeature());
    ep.getFeatures().add(cff);
    ep.publish("jms:queue:test.cxf.jmstransport.queue6");
}
Also used : GZIPFeature(org.apache.cxf.transport.common.gzip.GZIPFeature) GreeterSpecImpl(org.apache.cxf.jms.testsuite.services.GreeterSpecImpl) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) GreeterSpecWithPortError(org.apache.cxf.jms.testsuite.services.GreeterSpecWithPortError) BeforeClass(org.junit.BeforeClass)

Example 5 with GZIPFeature

use of org.apache.cxf.transport.common.gzip.GZIPFeature in project cxf by apache.

the class SoapJmsSpecTest method testGzip.

@Test
public void testGzip() throws Exception {
    URL wsdl = getWSDLURL(WSDL);
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setBus(bus);
    factory.setServiceClass(JMSGreeterPortType.class);
    factory.setWsdlURL(wsdl.toExternalForm());
    factory.getFeatures().add(cff);
    factory.getFeatures().add(new GZIPFeature());
    factory.setAddress("jms:queue:test.cxf.jmstransport.queue6");
    JMSGreeterPortType greeter = (JMSGreeterPortType) markForClose(factory.create());
    for (int idx = 0; idx < 5; idx++) {
        greeter.greetMeOneWay("test String");
        String greeting = greeter.greetMe("Milestone-" + idx);
        Assert.assertEquals("Hello Milestone-" + idx, greeting);
        String reply = greeter.sayHi();
        Assert.assertEquals("Bonjour", reply);
    }
}
Also used : GZIPFeature(org.apache.cxf.transport.common.gzip.GZIPFeature) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) JMSGreeterPortType(org.apache.cxf.jms_greeter.JMSGreeterPortType) URL(java.net.URL) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test) AbstractVmJMSTest(org.apache.cxf.systest.jms.AbstractVmJMSTest)

Aggregations

GZIPFeature (org.apache.cxf.transport.common.gzip.GZIPFeature)5 Bus (org.apache.cxf.Bus)2 URL (java.net.URL)1 Endpoint (javax.xml.ws.Endpoint)1 Client (org.apache.cxf.endpoint.Client)1 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)1 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)1 GreeterSpecImpl (org.apache.cxf.jms.testsuite.services.GreeterSpecImpl)1 GreeterSpecWithPortError (org.apache.cxf.jms.testsuite.services.GreeterSpecWithPortError)1 JMSGreeterPortType (org.apache.cxf.jms_greeter.JMSGreeterPortType)1 AbstractVmJMSTest (org.apache.cxf.systest.jms.AbstractVmJMSTest)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1