use of org.springframework.beans.DirectFieldAccessor in project spring-integration by spring-projects.
the class RedisInboundChannelAdapterParserTests method validateConfiguration.
@Test
public void validateConfiguration() {
RedisInboundChannelAdapter adapter = context.getBean("adapter", RedisInboundChannelAdapter.class);
assertEquals("adapter", adapter.getComponentName());
assertEquals("redis:inbound-channel-adapter", adapter.getComponentType());
DirectFieldAccessor accessor = new DirectFieldAccessor(adapter);
Object errorChannelBean = context.getBean("testErrorChannel");
assertEquals(errorChannelBean, accessor.getPropertyValue("errorChannel"));
Object converterBean = context.getBean("testConverter");
assertEquals(converterBean, accessor.getPropertyValue("messageConverter"));
assertEquals(context.getBean("serializer"), accessor.getPropertyValue("serializer"));
Object container = accessor.getPropertyValue("container");
DirectFieldAccessor containerAccessor = new DirectFieldAccessor(container);
assertSame(this.executor, containerAccessor.getPropertyValue("taskExecutor"));
Object bean = context.getBean("withoutSerializer.adapter");
assertNotNull(bean);
assertNull(TestUtils.getPropertyValue(bean, "serializer"));
}
use of org.springframework.beans.DirectFieldAccessor in project spring-integration by spring-projects.
the class WebFluxOutboundChannelAdapterParserTests method reactiveMinimalConfig.
@Test
public void reactiveMinimalConfig() {
DirectFieldAccessor endpointAccessor = new DirectFieldAccessor(this.reactiveMinimalConfig);
WebClient webClient = TestUtils.getPropertyValue(this.reactiveMinimalConfig, "handler.webClient", WebClient.class);
assertNotSame(this.webClient, webClient);
Object handler = endpointAccessor.getPropertyValue("handler");
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
assertEquals(false, handlerAccessor.getPropertyValue("expectReply"));
assertEquals(this.applicationContext.getBean("requests"), endpointAccessor.getPropertyValue("inputChannel"));
assertNull(handlerAccessor.getPropertyValue("outputChannel"));
Expression uriExpression = (Expression) handlerAccessor.getPropertyValue("uriExpression");
assertEquals("http://localhost/test1", uriExpression.getValue());
assertEquals(HttpMethod.POST.name(), TestUtils.getPropertyValue(handler, "httpMethodExpression", Expression.class).getExpressionString());
assertEquals(Charset.forName("UTF-8"), handlerAccessor.getPropertyValue("charset"));
assertEquals(true, handlerAccessor.getPropertyValue("extractPayload"));
}
use of org.springframework.beans.DirectFieldAccessor in project spring-integration by spring-projects.
the class WebFluxDslTests method testHttpReactiveProxyFlow.
@Test
public void testHttpReactiveProxyFlow() throws Exception {
ClientHttpConnector httpConnector = new HttpHandlerConnector((request, response) -> {
response.setStatusCode(HttpStatus.OK);
response.getHeaders().setContentType(MediaType.TEXT_PLAIN);
return response.writeWith(Mono.just(response.bufferFactory().wrap("FOO".getBytes()))).then(Mono.defer(response::setComplete));
});
WebClient webClient = WebClient.builder().clientConnector(httpConnector).build();
new DirectFieldAccessor(this.httpReactiveProxyFlow).setPropertyValue("webClient", webClient);
this.mockMvc.perform(get("/service2").with(httpBasic("guest", "guest")).param("name", "foo")).andExpect(content().string("FOO"));
}
use of org.springframework.beans.DirectFieldAccessor in project spring-integration by spring-projects.
the class DownstreamExceptionTests method testNoErrorChannel.
@Test
public void testNoErrorChannel() throws Exception {
service.n = 0;
Log logger = spy(TestUtils.getPropertyValue(noErrorChannel, "logger", Log.class));
final CountDownLatch latch = new CountDownLatch(1);
doAnswer(invocation -> {
if (((String) invocation.getArgument(0)).contains("Unhandled")) {
latch.countDown();
}
return null;
}).when(logger).error(anyString(), any(Throwable.class));
new DirectFieldAccessor(noErrorChannel).setPropertyValue("logger", logger);
MqttPahoMessageHandler adapter = new MqttPahoMessageHandler("tcp://localhost:1883", "si-test-out");
adapter.setDefaultTopic("mqtt-fooEx1");
adapter.setBeanFactory(mock(BeanFactory.class));
adapter.afterPropertiesSet();
adapter.start();
adapter.handleMessage(new GenericMessage<String>("foo"));
service.barrier.await(10, TimeUnit.SECONDS);
service.barrier.reset();
adapter.handleMessage(new GenericMessage<String>("foo"));
service.barrier.await(10, TimeUnit.SECONDS);
assertTrue(latch.await(10, TimeUnit.SECONDS));
verify(logger).error(contains("Unhandled exception for"), any(Throwable.class));
service.barrier.reset();
adapter.stop();
}
use of org.springframework.beans.DirectFieldAccessor in project spring-integration by spring-projects.
the class FileLockingNamespaceTests method extractSources.
@Before
public void extractSources() {
nioLockingSource = (FileReadingMessageSource) new DirectFieldAccessor(nioAdapter).getPropertyValue("source");
customLockingSource = (FileReadingMessageSource) new DirectFieldAccessor(customAdapter).getPropertyValue("source");
}
Aggregations