Search in sources :

Example 16 with AbstractMessageChannel

use of org.springframework.integration.channel.AbstractMessageChannel in project spring-integration by spring-projects.

the class JpaOutboundGatewayParserTests method testUpdatingJpaOutboundGatewayParser.

@Test
public void testUpdatingJpaOutboundGatewayParser() throws Exception {
    setUp("JpaOutboundGatewayParserTests.xml", getClass(), "updatingJpaOutboundGateway");
    final AbstractMessageChannel inputChannel = TestUtils.getPropertyValue(this.consumer, "inputChannel", AbstractMessageChannel.class);
    assertEquals("in", inputChannel.getComponentName());
    final JpaOutboundGateway jpaOutboundGateway = TestUtils.getPropertyValue(this.consumer, "handler", JpaOutboundGateway.class);
    final OutboundGatewayType gatewayType = TestUtils.getPropertyValue(jpaOutboundGateway, "gatewayType", OutboundGatewayType.class);
    assertEquals(OutboundGatewayType.UPDATING, gatewayType);
    long sendTimeout = TestUtils.getPropertyValue(jpaOutboundGateway, "messagingTemplate.sendTimeout", Long.class);
    assertEquals(100, sendTimeout);
    assertFalse(TestUtils.getPropertyValue(jpaOutboundGateway, "requiresReply", Boolean.class));
    final JpaExecutor jpaExecutor = TestUtils.getPropertyValue(this.consumer, "handler.jpaExecutor", JpaExecutor.class);
    assertNotNull(jpaExecutor);
    final Class<?> entityClass = TestUtils.getPropertyValue(jpaExecutor, "entityClass", Class.class);
    assertEquals("org.springframework.integration.jpa.test.entity.StudentDomain", entityClass.getName());
    final JpaOperations jpaOperations = TestUtils.getPropertyValue(jpaExecutor, "jpaOperations", JpaOperations.class);
    assertNotNull(jpaOperations);
    final Boolean usePayloadAsParameterSource = TestUtils.getPropertyValue(jpaExecutor, "usePayloadAsParameterSource", Boolean.class);
    assertTrue(usePayloadAsParameterSource);
    final Integer order = TestUtils.getPropertyValue(jpaOutboundGateway, "order", Integer.class);
    assertEquals(Integer.valueOf(2), order);
    final PersistMode persistMode = TestUtils.getPropertyValue(jpaExecutor, "persistMode", PersistMode.class);
    assertEquals(PersistMode.PERSIST, persistMode);
    assertEquals(Integer.valueOf(100), TestUtils.getPropertyValue(jpaExecutor, "flushSize", Integer.class));
    assertTrue(TestUtils.getPropertyValue(jpaExecutor, "clearOnFlush", Boolean.class));
}
Also used : PersistMode(org.springframework.integration.jpa.support.PersistMode) AbstractMessageChannel(org.springframework.integration.channel.AbstractMessageChannel) JpaExecutor(org.springframework.integration.jpa.core.JpaExecutor) JpaOutboundGateway(org.springframework.integration.jpa.outbound.JpaOutboundGateway) OutboundGatewayType(org.springframework.integration.jpa.support.OutboundGatewayType) JpaOperations(org.springframework.integration.jpa.core.JpaOperations) Test(org.junit.Test)

Example 17 with AbstractMessageChannel

use of org.springframework.integration.channel.AbstractMessageChannel in project spring-integration by spring-projects.

the class JpaMessageHandlerParserTests method testJpaMessageHandlerParserWithEntityManagerFactory.

@Test
public void testJpaMessageHandlerParserWithEntityManagerFactory() throws Exception {
    setUp("JpaMessageHandlerParserTestsWithEmFactory.xml", getClass());
    final AbstractMessageChannel inputChannel = TestUtils.getPropertyValue(this.consumer, "inputChannel", AbstractMessageChannel.class);
    assertEquals("target", inputChannel.getComponentName());
    final JpaExecutor jpaExecutor = TestUtils.getPropertyValue(this.consumer, "handler.jpaExecutor", JpaExecutor.class);
    assertNotNull(jpaExecutor);
    final String query = TestUtils.getPropertyValue(jpaExecutor, "jpaQuery", String.class);
    assertEquals("select student from Student student", query);
    final JpaOperations jpaOperations = TestUtils.getPropertyValue(jpaExecutor, "jpaOperations", JpaOperations.class);
    assertNotNull(jpaOperations);
    final PersistMode persistMode = TestUtils.getPropertyValue(jpaExecutor, "persistMode", PersistMode.class);
    assertEquals(PersistMode.PERSIST, persistMode);
    @SuppressWarnings("unchecked") List<JpaParameter> jpaParameters = TestUtils.getPropertyValue(jpaExecutor, "jpaParameters", List.class);
    assertNotNull(jpaParameters);
    assertTrue(jpaParameters.size() == 3);
}
Also used : PersistMode(org.springframework.integration.jpa.support.PersistMode) JpaParameter(org.springframework.integration.jpa.support.JpaParameter) AbstractMessageChannel(org.springframework.integration.channel.AbstractMessageChannel) JpaExecutor(org.springframework.integration.jpa.core.JpaExecutor) JpaOperations(org.springframework.integration.jpa.core.JpaOperations) Test(org.junit.Test)

Example 18 with AbstractMessageChannel

use of org.springframework.integration.channel.AbstractMessageChannel in project spring-integration by spring-projects.

the class JpaMessageHandlerParserTests method advisedAndTransactional.

/*
	 * Tests that an already advised handler (tx) gets the request handler advice added to its chain.
	 */
@Test
public void advisedAndTransactional() throws Exception {
    setUp("JpaMessageHandlerParserTests.xml", getClass());
    EventDrivenConsumer consumer = this.context.getBean("advisedAndTransactional", EventDrivenConsumer.class);
    final AbstractMessageChannel inputChannel = TestUtils.getPropertyValue(consumer, "inputChannel", AbstractMessageChannel.class);
    assertEquals("target", inputChannel.getComponentName());
    final MessageHandler handler = TestUtils.getPropertyValue(consumer, "handler", MessageHandler.class);
    adviceCalled = 0;
    handler.handleMessage(new GenericMessage<String>("foo"));
    assertEquals(1, adviceCalled);
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) AbstractMessageChannel(org.springframework.integration.channel.AbstractMessageChannel) AbstractReplyProducingMessageHandler(org.springframework.integration.handler.AbstractReplyProducingMessageHandler) MessageHandler(org.springframework.messaging.MessageHandler) Test(org.junit.Test)

Example 19 with AbstractMessageChannel

use of org.springframework.integration.channel.AbstractMessageChannel in project spring-integration by spring-projects.

the class JpaMessageHandlerParserTests method advised.

@Test
public void advised() throws Exception {
    setUp("JpaMessageHandlerParserTests.xml", getClass());
    EventDrivenConsumer consumer = this.context.getBean("advised", EventDrivenConsumer.class);
    final AbstractMessageChannel inputChannel = TestUtils.getPropertyValue(consumer, "inputChannel", AbstractMessageChannel.class);
    assertEquals("target", inputChannel.getComponentName());
    final MessageHandler handler = TestUtils.getPropertyValue(consumer, "handler", MessageHandler.class);
    adviceCalled = 0;
    handler.handleMessage(new GenericMessage<String>("foo"));
    assertEquals(1, adviceCalled);
}
Also used : EventDrivenConsumer(org.springframework.integration.endpoint.EventDrivenConsumer) AbstractMessageChannel(org.springframework.integration.channel.AbstractMessageChannel) AbstractReplyProducingMessageHandler(org.springframework.integration.handler.AbstractReplyProducingMessageHandler) MessageHandler(org.springframework.messaging.MessageHandler) Test(org.junit.Test)

Aggregations

AbstractMessageChannel (org.springframework.integration.channel.AbstractMessageChannel)19 Test (org.junit.Test)16 JpaExecutor (org.springframework.integration.jpa.core.JpaExecutor)7 JpaOperations (org.springframework.integration.jpa.core.JpaOperations)7 MessageHandler (org.springframework.messaging.MessageHandler)4 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 DirectChannel (org.springframework.integration.channel.DirectChannel)3 PersistMode (org.springframework.integration.jpa.support.PersistMode)3 LiteralExpression (org.springframework.expression.common.LiteralExpression)2 GlobalChannelInterceptor (org.springframework.integration.config.GlobalChannelInterceptor)2 EventDrivenConsumer (org.springframework.integration.endpoint.EventDrivenConsumer)2 AbstractReplyProducingMessageHandler (org.springframework.integration.handler.AbstractReplyProducingMessageHandler)2 JpaOutboundGateway (org.springframework.integration.jpa.outbound.JpaOutboundGateway)2 JpaParameter (org.springframework.integration.jpa.support.JpaParameter)2 OutboundGatewayType (org.springframework.integration.jpa.support.OutboundGatewayType)2 Message (org.springframework.messaging.Message)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1