Search in sources :

Example 11 with ConstantDataInputParameter

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);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) InputStream(java.io.InputStream) LogMessageService(com.adaptris.core.services.LogMessageService) Test(org.junit.Test)

Example 12 with ConstantDataInputParameter

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());
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) Test(org.junit.Test)

Example 13 with ConstantDataInputParameter

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) {
    }
}
Also used : CoreException(com.adaptris.core.CoreException) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) Test(org.junit.Test)

Aggregations

ConstantDataInputParameter (com.adaptris.core.common.ConstantDataInputParameter)13 Test (org.junit.Test)10 Execution (com.adaptris.core.common.Execution)7 MetadataDataOutputParameter (com.adaptris.core.common.MetadataDataOutputParameter)7 StringPayloadDataInputParameter (com.adaptris.core.common.StringPayloadDataInputParameter)6 ArrayList (java.util.ArrayList)6 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)5 ServiceException (com.adaptris.core.ServiceException)2 CoreException (com.adaptris.core.CoreException)1 ServiceList (com.adaptris.core.ServiceList)1 MetadataDataInputParameter (com.adaptris.core.common.MetadataDataInputParameter)1 PayloadInputStreamWrapper (com.adaptris.core.common.PayloadInputStreamWrapper)1 PayloadOutputStreamWrapper (com.adaptris.core.common.PayloadOutputStreamWrapper)1 LogMessageService (com.adaptris.core.services.LogMessageService)1 KeyValuePair (com.adaptris.util.KeyValuePair)1 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)1 InputStream (java.io.InputStream)1