Don't treat byte[] or collections in a special way.

This commit is contained in:
Eric Bottard
2020-03-17 13:25:13 +01:00
committed by Oleg Zhurakousky
parent 0acff2b1d3
commit b1d9890e0c
2 changed files with 42 additions and 18 deletions

View File

@@ -336,6 +336,14 @@ public class BeanFactoryAwareFunctionRegistryTests {
assertThat(composed).isFalse();
}
@Test
public void byteArrayNoSpecialHandling() throws Exception {
FunctionCatalog catalog = this.configureCatalog(ByteArrayFunction.class);
FunctionInvocationWrapper function = catalog.lookup("beanFactoryAwareFunctionRegistryTests.ByteArrayFunction", "application/json");
assertThat(function).isNotNull();
Message<byte[]> result = (Message<byte[]>) function.apply(MessageBuilder.withPayload("hello".getBytes()).setHeader(MessageHeaders.CONTENT_TYPE, "application/octet-stream").build());
assertThat(result.getPayload()).isEqualTo("\"b2xsZWg=\"".getBytes());
}
@SuppressWarnings("unchecked")
@Test
@@ -689,4 +697,19 @@ public class BeanFactoryAwareFunctionRegistryTests {
}
}
@EnableAutoConfiguration
@Configuration
@Component
public static class ByteArrayFunction implements Function<byte[], byte[]> {
@Override
public byte[] apply(byte[] bytes) {
byte[] result = new byte[bytes.length];
for (int i = 0; i < bytes.length; i++) {
result[i] = bytes[bytes.length - i - 1];
}
return result;
}
}
}