@@ -59,6 +59,7 @@ import org.springframework.messaging.support.GenericMessage;
|
|||||||
import org.springframework.messaging.support.MessageBuilder;
|
import org.springframework.messaging.support.MessageBuilder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.MimeType;
|
import org.springframework.util.MimeType;
|
||||||
|
import org.springframework.util.MimeTypeUtils;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
import static java.util.Collections.singletonList;
|
import static java.util.Collections.singletonList;
|
||||||
@@ -531,6 +532,13 @@ public class BeanFactoryAwareFunctionRegistryTests {
|
|||||||
assertThat(((Person) config.consumerInputRef.get()).getName()).isEqualTo("Ricky");
|
assertThat(((Person) config.consumerInputRef.get()).getName()).isEqualTo("Ricky");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGH_611() {
|
||||||
|
FunctionCatalog catalog = this.configureCatalog(NegotiatingMessageConverterConfiguration.class);
|
||||||
|
Supplier<Message<Integer>> f = catalog.lookup("supplier", "text/*");
|
||||||
|
assertThat(f.get().getHeaders().get(MessageHeaders.CONTENT_TYPE)).isEqualTo(MimeTypeUtils.parseMimeType("text/*"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGH_609() {
|
public void testGH_609() {
|
||||||
FunctionCatalog catalog = this.configureCatalog(SampleFunctionConfiguration.class);
|
FunctionCatalog catalog = this.configureCatalog(SampleFunctionConfiguration.class);
|
||||||
@@ -605,6 +613,11 @@ public class BeanFactoryAwareFunctionRegistryTests {
|
|||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
public static class NegotiatingMessageConverterConfiguration {
|
public static class NegotiatingMessageConverterConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Supplier<Integer> supplier() {
|
||||||
|
return () -> 123;
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Function<String, String> echo() {
|
public Function<String, String> echo() {
|
||||||
return v -> v;
|
return v -> v;
|
||||||
@@ -620,6 +633,38 @@ public class BeanFactoryAwareFunctionRegistryTests {
|
|||||||
return new ConverterB();
|
return new ConverterB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public MessageConverter messageConverterC() {
|
||||||
|
return new ConverterC();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ConverterC extends ConverterA {
|
||||||
|
ConverterC() {
|
||||||
|
super("text/*");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object convertFromInternal(
|
||||||
|
Message<?> message, Class<?> targetClass, @Nullable Object conversionHint) {
|
||||||
|
return message.getPayload().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object convertToInternal(Object rawPayload, MessageHeaders headers, Object conversionHint) {
|
||||||
|
return rawPayload;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canConvertFrom(Message<?> message, @Nullable Class<?> targetClass) {
|
||||||
|
return supportsMimeType(message.getHeaders()) && Integer.class.isAssignableFrom(targetClass)
|
||||||
|
&& message.getPayload() instanceof Integer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean canConvertTo(Object payload, @Nullable MessageHeaders headers) {
|
||||||
|
return payload instanceof Integer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class ConverterB extends ConverterA {
|
public static class ConverterB extends ConverterA {
|
||||||
ConverterB() {
|
ConverterB() {
|
||||||
|
|||||||
Reference in New Issue
Block a user