Search in sources :

Example 1 with JpaOutboundGateway

use of org.springframework.integration.jpa.outbound.JpaOutboundGateway in project spring-integration by spring-projects.

the class JpaOutboundGatewayParserTests method testRetrievingJpaOutboundGatewayParserWithMaxResultExpression.

@Test
public void testRetrievingJpaOutboundGatewayParserWithMaxResultExpression() throws Exception {
    setUp("JpaOutboundGatewayParserTests.xml", getClass(), "retrievingJpaOutboundGatewayWithMaxResultExpression");
    final JpaOutboundGateway jpaOutboundGateway = TestUtils.getPropertyValue(this.consumer, "handler", JpaOutboundGateway.class);
    Expression maxNumberOfResultExpression = TestUtils.getPropertyValue(jpaOutboundGateway, "jpaExecutor.maxResultsExpression", Expression.class);
    assertNotNull(maxNumberOfResultExpression);
    assertEquals(SpelExpression.class, maxNumberOfResultExpression.getClass());
    assertEquals("header['maxResults']", TestUtils.getPropertyValue(maxNumberOfResultExpression, "expression", String.class));
}
Also used : LiteralExpression(org.springframework.expression.common.LiteralExpression) SpelExpression(org.springframework.expression.spel.standard.SpelExpression) Expression(org.springframework.expression.Expression) JpaOutboundGateway(org.springframework.integration.jpa.outbound.JpaOutboundGateway) Test(org.junit.Test)

Example 2 with JpaOutboundGateway

use of org.springframework.integration.jpa.outbound.JpaOutboundGateway in project spring-integration by spring-projects.

the class JpaOutboundGatewayParserTests method testRetrievingJpaOutboundGatewayParser.

@Test
public void testRetrievingJpaOutboundGatewayParser() throws Exception {
    setUp("JpaOutboundGatewayParserTests.xml", getClass(), "retrievingJpaOutboundGateway");
    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.RETRIEVING, 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);
    assertTrue(TestUtils.getPropertyValue(jpaExecutor, "expectSingleResult", Boolean.class));
    final LiteralExpression maxResultsExpression = TestUtils.getPropertyValue(jpaExecutor, "maxResultsExpression", LiteralExpression.class);
    assertNotNull(maxResultsExpression);
    assertEquals("55", TestUtils.getPropertyValue(maxResultsExpression, "literalValue"));
    assertTrue(TestUtils.getPropertyValue(jpaExecutor, "deleteAfterPoll", Boolean.class));
    assertTrue(TestUtils.getPropertyValue(jpaExecutor, "flush", Boolean.class));
}
Also used : 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) LiteralExpression(org.springframework.expression.common.LiteralExpression) Test(org.junit.Test)

Example 3 with JpaOutboundGateway

use of org.springframework.integration.jpa.outbound.JpaOutboundGateway in project spring-integration by spring-projects.

the class JpaOutboundGatewayParserTests method testRetrievingJpaOutboundGatewayParserWithFirstResult.

@Test
public void testRetrievingJpaOutboundGatewayParserWithFirstResult() throws Exception {
    setUp("JpaOutboundGatewayParserTests.xml", getClass(), "retrievingJpaOutboundGatewayWithFirstResult");
    final JpaOutboundGateway jpaOutboundGateway = TestUtils.getPropertyValue(this.consumer, "handler", JpaOutboundGateway.class);
    Expression firstResultExpression = TestUtils.getPropertyValue(jpaOutboundGateway, "jpaExecutor.firstResultExpression", Expression.class);
    assertNotNull(firstResultExpression);
    assertEquals(LiteralExpression.class, firstResultExpression.getClass());
    assertEquals("1", TestUtils.getPropertyValue(firstResultExpression, "literalValue", String.class));
}
Also used : LiteralExpression(org.springframework.expression.common.LiteralExpression) SpelExpression(org.springframework.expression.spel.standard.SpelExpression) Expression(org.springframework.expression.Expression) JpaOutboundGateway(org.springframework.integration.jpa.outbound.JpaOutboundGateway) Test(org.junit.Test)

Example 4 with JpaOutboundGateway

use of org.springframework.integration.jpa.outbound.JpaOutboundGateway in project spring-integration by spring-projects.

the class JpaOutboundGatewayParserTests method testRetrievingJpaOutboundGatewayParserWithFirstResultExpression.

@Test
public void testRetrievingJpaOutboundGatewayParserWithFirstResultExpression() throws Exception {
    setUp("JpaOutboundGatewayParserTests.xml", getClass(), "retrievingJpaOutboundGatewayWithFirstResultExpression");
    final JpaOutboundGateway jpaOutboundGateway = TestUtils.getPropertyValue(this.consumer, "handler", JpaOutboundGateway.class);
    Expression firstResultExpression = TestUtils.getPropertyValue(jpaOutboundGateway, "jpaExecutor.firstResultExpression", Expression.class);
    assertNotNull(firstResultExpression);
    assertEquals(SpelExpression.class, firstResultExpression.getClass());
    assertEquals("header['firstResult']", TestUtils.getPropertyValue(firstResultExpression, "expression", String.class));
}
Also used : LiteralExpression(org.springframework.expression.common.LiteralExpression) SpelExpression(org.springframework.expression.spel.standard.SpelExpression) Expression(org.springframework.expression.Expression) JpaOutboundGateway(org.springframework.integration.jpa.outbound.JpaOutboundGateway) Test(org.junit.Test)

Example 5 with JpaOutboundGateway

use of org.springframework.integration.jpa.outbound.JpaOutboundGateway 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)

Aggregations

Test (org.junit.Test)5 JpaOutboundGateway (org.springframework.integration.jpa.outbound.JpaOutboundGateway)5 LiteralExpression (org.springframework.expression.common.LiteralExpression)4 Expression (org.springframework.expression.Expression)3 SpelExpression (org.springframework.expression.spel.standard.SpelExpression)3 AbstractMessageChannel (org.springframework.integration.channel.AbstractMessageChannel)2 JpaExecutor (org.springframework.integration.jpa.core.JpaExecutor)2 JpaOperations (org.springframework.integration.jpa.core.JpaOperations)2 OutboundGatewayType (org.springframework.integration.jpa.support.OutboundGatewayType)2 PersistMode (org.springframework.integration.jpa.support.PersistMode)1