use of com.adaptris.core.common.ConstantDataInputParameter in project interlok by adaptris.
the class ServiceFromDataInputTest method testGetInputStream.
@Test
public void testGetInputStream() throws Exception {
String xml = DynamicServiceExecutorTest.createMessage(new ServiceList(new Service[] { new LogMessageService() })).getContent();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
ServiceFromDataInputParameter serviceExtractor = new ServiceFromDataInputParameter(new ConstantDataInputParameter(xml));
try {
LifecycleHelper.initAndStart(serviceExtractor);
try (InputStream in = serviceExtractor.getInputStream(msg)) {
assertNotNull(in);
assertEquals(ServiceList.class, DefaultMarshaller.getDefaultMarshaller().unmarshal(in).getClass());
}
} finally {
LifecycleHelper.stopAndClose(serviceExtractor);
}
}
use of com.adaptris.core.common.ConstantDataInputParameter in project interlok by adaptris.
the class SymmetricKeyCryptographyServiceTest method testDoService.
@Test
public void testDoService() throws Exception {
SymmetricKeyCryptographyService service = new SymmetricKeyCryptographyService();
service.setAlgorithm(ALGORITHM);
service.setCipherTransformation(CIPHER);
service.setKey(new ConstantDataInputParameter(Conversion.byteArrayToBase64String(key)));
service.setInitialVector(new ConstantDataInputParameter(Conversion.byteArrayToBase64String(iv)));
AdaptrisMessage message = AdaptrisMessageFactory.getDefaultInstance().newMessage(encryptedPayload);
ServiceCase.execute(service, message);
assertEquals(PAYLOAD, message.getContent());
}
use of com.adaptris.core.common.ConstantDataInputParameter in project interlok by adaptris.
the class SymmetricKeyCryptographyServiceTest method testDoService_BadConfig.
@Test
public void testDoService_BadConfig() throws Exception {
try {
LifecycleHelper.initAndStart(new SymmetricKeyCryptographyService());
fail();
} catch (CoreException expected) {
}
SymmetricKeyCryptographyService service = new SymmetricKeyCryptographyService().withAlgorithm("BLAH").withCipherTransformation("AES/Blah/Blah").withKey(new ConstantDataInputParameter("123")).withInitialVector(new ConstantDataInputParameter("123"));
AdaptrisMessage message = AdaptrisMessageFactory.getDefaultInstance().newMessage(encryptedPayload);
try {
ServiceCase.execute(service, message);
fail();
} catch (ServiceException expected) {
}
}
Aggregations