Search in sources :

Example 1 with CompressionInInterceptor

use of org.talend.esb.policy.compression.impl.CompressionInInterceptor in project tesb-rt-se by Talend.

the class CompressionFeature method initializeProvider.

@Override
protected void initializeProvider(InterceptorProvider provider, Bus bus) {
    CompressionOutInterceptor out = new CompressionOutInterceptor();
    CompressionInInterceptor in = new CompressionInInterceptor();
    out.setThreshold(getThreshold());
    remove(provider.getOutInterceptors());
    remove(provider.getOutFaultInterceptors());
    provider.getOutInterceptors().add(out);
    provider.getOutFaultInterceptors().add(out);
    provider.getInInterceptors().add(in);
}
Also used : CompressionOutInterceptor(org.talend.esb.policy.compression.impl.CompressionOutInterceptor) CompressionInInterceptor(org.talend.esb.policy.compression.impl.CompressionInInterceptor)

Example 2 with CompressionInInterceptor

use of org.talend.esb.policy.compression.impl.CompressionInInterceptor in project tesb-rt-se by Talend.

the class CompressionFeatureTest method removeInterceptors.

@Test
public void removeInterceptors() {
    final List<Interceptor<? extends Message>> outInterceptors = new ArrayList<Interceptor<? extends Message>>();
    outInterceptors.add(new CompressionOutInterceptor());
    outInterceptors.add(new CompressionOutInterceptor());
    final List<Interceptor<? extends Message>> outFaultInterceptors = new ArrayList<Interceptor<? extends Message>>();
    outFaultInterceptors.add(new CompressionOutInterceptor());
    outFaultInterceptors.add(new CompressionOutInterceptor());
    final List<Interceptor<? extends Message>> inInterceptors = new ArrayList<Interceptor<? extends Message>>();
    inInterceptors.add(new CompressionInInterceptor());
    final List<Interceptor<? extends Message>> inFaultInterceptors = new ArrayList<Interceptor<? extends Message>>();
    inFaultInterceptors.add(new CompressionInInterceptor());
    InterceptorProvider interceptorProvider = new InterceptorProvider() {

        @Override
        public List<Interceptor<? extends Message>> getOutInterceptors() {
            return outInterceptors;
        }

        @Override
        public List<Interceptor<? extends Message>> getOutFaultInterceptors() {
            return outFaultInterceptors;
        }

        @Override
        public List<Interceptor<? extends Message>> getInInterceptors() {
            return inInterceptors;
        }

        @Override
        public List<Interceptor<? extends Message>> getInFaultInterceptors() {
            return inFaultInterceptors;
        }
    };
    CompressionFeature f = new CompressionFeature();
    f.initialize(interceptorProvider, null);
    assertTrue(outInterceptors.size() == 1);
    assertTrue(outFaultInterceptors.size() == 1);
    assertTrue(inInterceptors.size() == 2);
    assertTrue(inFaultInterceptors.size() == 1);
}
Also used : Message(org.apache.cxf.message.Message) CompressionOutInterceptor(org.talend.esb.policy.compression.impl.CompressionOutInterceptor) CompressionFeature(org.talend.esb.policy.compression.feature.CompressionFeature) ArrayList(java.util.ArrayList) InterceptorProvider(org.apache.cxf.interceptor.InterceptorProvider) Interceptor(org.apache.cxf.interceptor.Interceptor) CompressionOutInterceptor(org.talend.esb.policy.compression.impl.CompressionOutInterceptor) CompressionInInterceptor(org.talend.esb.policy.compression.impl.CompressionInInterceptor) CompressionInInterceptor(org.talend.esb.policy.compression.impl.CompressionInInterceptor) Test(org.junit.Test)

Example 3 with CompressionInInterceptor

use of org.talend.esb.policy.compression.impl.CompressionInInterceptor in project tesb-rt-se by Talend.

the class CompressionInInterceptorTest method handleRuntimeException.

@Test
public void handleRuntimeException() throws Exception {
    CompressionInInterceptor c = new CompressionInInterceptor() {

        public void decompressMessage(Message message) throws org.apache.cxf.interceptor.Fault {
            throw new RuntimeException();
        }
    };
    try {
        c.handleMessage(null);
    } catch (RuntimeException ex) {
        return;
    }
    fail("No exception is not expected");
}
Also used : Message(org.apache.cxf.message.Message) CompressionInInterceptor(org.talend.esb.policy.compression.impl.CompressionInInterceptor) Test(org.junit.Test)

Example 4 with CompressionInInterceptor

use of org.talend.esb.policy.compression.impl.CompressionInInterceptor in project tesb-rt-se by Talend.

the class CompressionInInterceptorTest method handleNullMessage.

@Test
public void handleNullMessage() {
    CompressionInInterceptor c = new CompressionInInterceptor();
    c.handleMessage(CompressionCommonTest.getMessageStub(null, null));
}
Also used : CompressionInInterceptor(org.talend.esb.policy.compression.impl.CompressionInInterceptor) Test(org.junit.Test)

Example 5 with CompressionInInterceptor

use of org.talend.esb.policy.compression.impl.CompressionInInterceptor in project tesb-rt-se by Talend.

the class CompressionInInterceptorTest method handleEmptyMessage.

@Test
public void handleEmptyMessage() throws Exception {
    CompressionInInterceptor c = new CompressionInInterceptor();
    Map<String, Object> map = new HashMap<String, Object>();
    XMLInputFactory inputFactory = XMLInputFactory.newInstance();
    byte[] buff = new byte[1024];
    XMLStreamReader reader = inputFactory.createXMLStreamReader(new ByteArrayInputStream(buff));
    map.put(XMLStreamReader.class.getName(), reader);
    map.put(InputStream.class.getName(), new ByteArrayInputStream(buff));
    Message message = CompressionCommonTest.getMessageStub(null, map);
    c.handleMessage(message);
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) Message(org.apache.cxf.message.Message) HashMap(java.util.HashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) XMLInputFactory(javax.xml.stream.XMLInputFactory) CompressionInInterceptor(org.talend.esb.policy.compression.impl.CompressionInInterceptor) Test(org.junit.Test)

Aggregations

CompressionInInterceptor (org.talend.esb.policy.compression.impl.CompressionInInterceptor)6 Test (org.junit.Test)5 Message (org.apache.cxf.message.Message)4 HashMap (java.util.HashMap)2 CompressionOutInterceptor (org.talend.esb.policy.compression.impl.CompressionOutInterceptor)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 XMLInputFactory (javax.xml.stream.XMLInputFactory)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 Interceptor (org.apache.cxf.interceptor.Interceptor)1 InterceptorProvider (org.apache.cxf.interceptor.InterceptorProvider)1 CompressionFeature (org.talend.esb.policy.compression.feature.CompressionFeature)1