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);
}
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);
}
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");
}
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));
}
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);
}
Aggregations