From df804588d8b12d9f0496641828b83aa3e4f75bd1 Mon Sep 17 00:00:00 2001 From: Gunnar Hillert Date: Tue, 15 May 2012 11:47:33 -0400 Subject: [PATCH] INT-2560 - Fix tests in JpaPollingChannelAdapterTests For reference see: https://jira.springsource.org/browse/INT-2560 --- ...eJpaPollingChannelAdapterTests-context.xml | 63 ++++++++++--------- .../JpaPollingChannelAdapterTests.java | 23 +++---- 2 files changed, 41 insertions(+), 45 deletions(-) diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/inbound/BaseJpaPollingChannelAdapterTests-context.xml b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/inbound/BaseJpaPollingChannelAdapterTests-context.xml index b7ffe26af3..a38a34e83b 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/inbound/BaseJpaPollingChannelAdapterTests-context.xml +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/inbound/BaseJpaPollingChannelAdapterTests-context.xml @@ -1,60 +1,61 @@ - + - + - - - - - + + + + + - - - - + + + + - - - + class="org.springframework.orm.jpa.support.SharedEntityManagerBean"> + + - + + + + - + - + - + - + - - - - \ No newline at end of file + + + + diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/inbound/JpaPollingChannelAdapterTests.java b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/inbound/JpaPollingChannelAdapterTests.java index c947c5cfb2..b88da471a1 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/inbound/JpaPollingChannelAdapterTests.java +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/inbound/JpaPollingChannelAdapterTests.java @@ -45,7 +45,6 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.transaction.TransactionConfiguration; -import org.springframework.transaction.annotation.Transactional; /** * Integration tests for the Jpa Polling Channel Adapter {@link JpaPollingChannelAdapter}. @@ -264,7 +263,6 @@ public class JpaPollingChannelAdapterTests { */ @Test @DirtiesContext - @Transactional public void testWithJpaQueryAndDelete() throws Exception { testTrigger.reset(); @@ -307,7 +305,6 @@ public class JpaPollingChannelAdapterTests { @Test @DirtiesContext - @Transactional public void testWithJpaQueryButNoResultsAndDelete() throws Exception { testTrigger.reset(); @@ -322,15 +319,14 @@ public class JpaPollingChannelAdapterTests { jpaPollingChannelAdapter, this.outputChannel, this.poller, this.context, this.getClass().getClassLoader()); adapter.start(); - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - final List>> received = new ArrayList>>(); + Thread.sleep(1000); final Consumer consumer = new Consumer(); + final List>> received = new ArrayList>>(); received.add(consumer.poll(5000)); - Message> message = received.get(0); + final Message> message = received.get(0); adapter.stop(); @@ -362,27 +358,26 @@ public class JpaPollingChannelAdapterTests { jpaPollingChannelAdapter, this.outputChannel, this.poller, this.context, this.getClass().getClassLoader()); adapter.start(); - //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - final List>> received = new ArrayList>>(); + Thread.sleep(1000); final Consumer consumer = new Consumer(); + final List>> received = new ArrayList>>(); received.add(consumer.poll(5000)); - Message> message = received.get(0); + final Message> message = received.get(0); - //adapter.stop(); + adapter.stop(); assertNotNull("Message is null.", message); assertNotNull(message.getPayload()); assertTrue(message.getPayload() instanceof Collection); - Collection students = message.getPayload(); + final Collection students = message.getPayload(); assertTrue(students.size() == 3); - Long studentCount = entityManager.createQuery("select count(*) from Student", Long.class).getSingleResult(); + final Long studentCount = entityManager.createQuery("select count(*) from Student", Long.class).getSingleResult(); assertEquals(Long.valueOf(0), studentCount);