Search in sources :

Example 1 with ConstantDataInputParameter

use of com.adaptris.core.common.ConstantDataInputParameter in project interlok by adaptris.

the class SymmetricKeyCryptographyServiceTest method testDoServiceEncrypt.

@Test
public void testDoServiceEncrypt() throws Exception {
    SymmetricKeyCryptographyService service = new SymmetricKeyCryptographyService();
    service.setAlgorithm(ALGORITHM);
    service.setCipherTransformation(CIPHER);
    service.setOperationMode(SymmetricKeyCryptographyService.OpMode.ENCRYPT);
    service.setKey(new ConstantDataInputParameter(Conversion.byteArrayToBase64String(key)));
    service.setInitialVector(new ConstantDataInputParameter(Conversion.byteArrayToBase64String(iv)));
    AdaptrisMessage message = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD);
    ServiceCase.execute(service, message);
    assertTrue(Arrays.equals(encryptedPayload, message.getPayload()));
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) Test(org.junit.Test)

Example 2 with ConstantDataInputParameter

use of com.adaptris.core.common.ConstantDataInputParameter in project interlok by adaptris.

the class SymmetricKeyCryptographyServiceTest method testDoServiceEncrypt_WithSourceTarget.

@Test
public void testDoServiceEncrypt_WithSourceTarget() throws Exception {
    SymmetricKeyCryptographyService service = new SymmetricKeyCryptographyService();
    service.setAlgorithm(ALGORITHM);
    service.setCipherTransformation(CIPHER);
    service.setOperationMode(SymmetricKeyCryptographyService.OpMode.ENCRYPT);
    service.setKey(new ConstantDataInputParameter(Conversion.byteArrayToBase64String(key)));
    service.setInitialVector(new ConstantDataInputParameter(Conversion.byteArrayToBase64String(iv)));
    service.setSource(new PayloadInputStreamWrapper());
    service.setTarget(new PayloadOutputStreamWrapper());
    AdaptrisMessage message = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD);
    ServiceCase.execute(service, message);
    assertTrue(Arrays.equals(encryptedPayload, message.getPayload()));
}
Also used : PayloadOutputStreamWrapper(com.adaptris.core.common.PayloadOutputStreamWrapper) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) PayloadInputStreamWrapper(com.adaptris.core.common.PayloadInputStreamWrapper) Test(org.junit.Test)

Example 3 with ConstantDataInputParameter

use of com.adaptris.core.common.ConstantDataInputParameter in project interlok by adaptris.

the class RegexpServiceTest method createService.

private RegexpService createService() {
    RegexpService s = new RegexpService();
    s.getExecutions().add(new Execution(new ConstantDataInputParameter(POSTCODE_REGEXP), new MetadataDataOutputParameter(TARGET_METADATA_KEY)));
    return s;
}
Also used : Execution(com.adaptris.core.common.Execution) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) MetadataDataOutputParameter(com.adaptris.core.common.MetadataDataOutputParameter)

Example 4 with ConstantDataInputParameter

use of com.adaptris.core.common.ConstantDataInputParameter in project interlok by adaptris.

the class XPathServiceTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    MetadataDataOutputParameter metadataDataDestination1 = new MetadataDataOutputParameter("targetMetadataKey");
    MetadataDataInputParameter metadataDataDestination2 = new MetadataDataInputParameter("sourceXpathMetadataKey");
    ConstantDataInputParameter constantDataDestination = new ConstantDataInputParameter("//my/xpath/expression");
    constantDataDestination.setValue("//my/xpath/expression");
    Execution execution1 = new Execution();
    execution1.setSource(constantDataDestination);
    execution1.setTarget(metadataDataDestination1);
    Execution execution2 = new Execution();
    execution2.setSource(metadataDataDestination2);
    execution2.setTarget(new MetadataDataOutputParameter("targetMetadataKey2"));
    List<Execution> executions = new ArrayList<Execution>();
    executions.add(execution1);
    executions.add(execution2);
    KeyValuePairSet namespaceMappings = new KeyValuePairSet();
    namespaceMappings.addKeyValuePair(new KeyValuePair("some", "http://adaptris.com/xml/some"));
    namespaceMappings.addKeyValuePair(new KeyValuePair("n1", "http://adaptris.com/xml/n1"));
    namespaceMappings.addKeyValuePair(new KeyValuePair("n2", "http://adaptris.com/xml/n2"));
    namespaceMappings.addKeyValuePair(new KeyValuePair("n3", "http://adaptris.com/xml/n3"));
    service.setNamespaceContext(namespaceMappings);
    service.setXmlSource(new StringPayloadDataInputParameter());
    service.setExecutions(executions);
    return service;
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) MetadataDataInputParameter(com.adaptris.core.common.MetadataDataInputParameter) KeyValuePair(com.adaptris.util.KeyValuePair) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) ArrayList(java.util.ArrayList) MetadataDataOutputParameter(com.adaptris.core.common.MetadataDataOutputParameter) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 5 with ConstantDataInputParameter

use of com.adaptris.core.common.ConstantDataInputParameter in project interlok by adaptris.

the class XPathServiceTest method testPayloadSimpleValueXPathIntoMetadata.

@Test
public void testPayloadSimpleValueXPathIntoMetadata() throws Exception {
    message.setContent(sampleXml, message.getContentEncoding());
    MetadataDataOutputParameter metadataDataDestination1 = new MetadataDataOutputParameter("targetMetadataKey");
    ConstantDataInputParameter constantDataDestination = new ConstantDataInputParameter("//some/random/xml/node1/text()");
    Execution execution = new Execution(constantDataDestination, metadataDataDestination1);
    List<Execution> executions = new ArrayList<>();
    executions.add(execution);
    service.setXmlSource(new StringPayloadDataInputParameter());
    service.setExecutions(executions);
    execute(service, message);
    assertEquals("value1", message.getMetadataValue("targetMetadataKey"));
}
Also used : StringPayloadDataInputParameter(com.adaptris.core.common.StringPayloadDataInputParameter) Execution(com.adaptris.core.common.Execution) ConstantDataInputParameter(com.adaptris.core.common.ConstantDataInputParameter) ArrayList(java.util.ArrayList) MetadataDataOutputParameter(com.adaptris.core.common.MetadataDataOutputParameter) 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