use of org.talend.esb.policy.compression.impl.CompressionOutInterceptor 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.CompressionOutInterceptor in project tesb-rt-se by Talend.
the class CompressionOutInterceptorTest method testCompressionOutInterceptor.
@Test
public void testCompressionOutInterceptor() {
CompressionOutInterceptor coi = new CompressionOutInterceptor(1000);
assertEquals(coi.getThreshold(), 1000);
}
use of org.talend.esb.policy.compression.impl.CompressionOutInterceptor in project tesb-rt-se by Talend.
the class CompressionOutInterceptorTest method handleRuntimeException1.
@Test
public void handleRuntimeException1() throws Exception {
CompressionOutInterceptor c = new CompressionOutInterceptor() {
public void wrapOriginalOutputStream(Message message) throws Fault {
throw new RuntimeException();
}
};
try {
c.handleMessage(CompressionCommonTest.getMessageStub(null, null));
} catch (RuntimeException ex) {
return;
}
fail("No exception is not expected");
}
use of org.talend.esb.policy.compression.impl.CompressionOutInterceptor 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.CompressionOutInterceptor in project tesb-rt-se by Talend.
the class CompressionOutInterceptorTest method handleEmptyMessage.
@Test
public void handleEmptyMessage() throws Exception {
CompressionOutInterceptor c = new CompressionOutInterceptor();
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