Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #440 from ghillert/INT-2560

* INT-2560:
  INT-2560 - Fix tests in JpaPollingChannelAdapterTests For reference see: https://jira.springsource.org/browse/INT-2560
  • Loading branch information...
commit 2061c37608ca1a78397c961561ef5fc2a5a093ba 2 parents 2486f0c + df80458
Oleg Zhurakousky authored
View
63 ...org/springframework/integration/jpa/inbound/BaseJpaPollingChannelAdapterTests-context.xml
@@ -1,60 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:task="http://www.springframework.org/schema/task"
- xmlns:jdbc="http://www.springframework.org/schema/jdbc"
- xmlns:int="http://www.springframework.org/schema/integration"
- xmlns:util="http://www.springframework.org/schema/util"
- xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:task="http://www.springframework.org/schema/task"
+ xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:int="http://www.springframework.org/schema/integration"
+ xmlns:util="http://www.springframework.org/schema/util" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
- http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.2.xsd
+ http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
- <jdbc:embedded-database id="dataSource" type="H2"/>
+ <jdbc:embedded-database id="dataSource" type="H2" />
- <tx:annotation-driven transaction-manager="transactionManager"/>
+ <tx:annotation-driven transaction-manager="transactionManager" />
- <jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS" >
- <jdbc:script location="classpath:H2-DropTables.sql" />
- <jdbc:script location="classpath:H2-CreateTables.sql" />
- <jdbc:script location="classpath:H2-PopulateData.sql" />
- </jdbc:initialize-database>
+ <jdbc:initialize-database data-source="dataSource"
+ ignore-failures="DROPS">
+ <jdbc:script location="classpath:H2-DropTables.sql" />
+ <jdbc:script location="classpath:H2-CreateTables.sql" />
+ <jdbc:script location="classpath:H2-PopulateData.sql" />
+ </jdbc:initialize-database>
<bean id="lc"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
- <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" >
- <property name="showSql" value="true"/>
- </bean>
- </property>
+ <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
+ <property name="showSql" value="true" />
+ </bean>
+ </property>
</bean>
<bean id="em"
- class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
- <property name="entityManagerFactory" ref="lc" />
- </bean>
-
+ class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
+ <property name="entityManagerFactory" ref="lc" />
+ </bean>
<!-- Define the JPA transaction mgr -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<constructor-arg ref="lc" />
</bean>
-<!-- -->
+ <task:executor id="taskExecutor" pool-size="5" queue-capacity="10" />
+ <int:channel id="outputChannel">
+ <int:dispatcher task-executor="taskExecutor" />
+ </int:channel>
- <int:service-activator id="consumerEndpoint" input-channel="outputChannel" ref="consumer" method="receive" />
+ <int:service-activator id="consumerEndpoint"
+ input-channel="outputChannel" ref="consumer" method="receive" />
- <bean id="consumer" class="org.springframework.integration.jpa.test.Consumer" />
+ <bean id="consumer" class="org.springframework.integration.jpa.test.Consumer" />
- <bean id="testtrigger" class="org.springframework.integration.jpa.test.TestTrigger" />
+ <bean id="testtrigger" class="org.springframework.integration.jpa.test.TestTrigger" />
- <int:poller id="defaultPoller" default="true" fixed-rate="10000" />
+ <int:poller id="defaultPoller" default="true" fixed-rate="10000" />
- <int:poller id="jpaPoller" trigger="testtrigger">
- <int:transactional transaction-manager="transactionManager"/>
- </int:poller>
-</beans>
+ <int:poller id="jpaPoller" trigger="testtrigger">
+ <int:transactional transaction-manager="transactionManager" />
+ </int:poller>
+</beans>
View
23 .../test/java/org/springframework/integration/jpa/inbound/JpaPollingChannelAdapterTests.java
@@ -45,7 +45,6 @@
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 void testWithJpaQueryOneResultOnly() throws Exception {
*/
@Test
@DirtiesContext
- @Transactional
public void testWithJpaQueryAndDelete() throws Exception {
testTrigger.reset();
@@ -307,7 +305,6 @@ public void testWithJpaQueryAndDelete() throws Exception {
@Test
@DirtiesContext
- @Transactional
public void testWithJpaQueryButNoResultsAndDelete() throws Exception {
testTrigger.reset();
@@ -322,15 +319,14 @@ public void testWithJpaQueryButNoResultsAndDelete() throws Exception {
jpaPollingChannelAdapter, this.outputChannel, this.poller, this.context, this.getClass().getClassLoader());
adapter.start();
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- final List<Message<Collection<?>>> received = new ArrayList<Message<Collection<?>>>();
+ Thread.sleep(1000);
final Consumer consumer = new Consumer();
+ final List<Message<Collection<?>>> received = new ArrayList<Message<Collection<?>>>();
received.add(consumer.poll(5000));
- Message<Collection<?>> message = received.get(0);
+ final Message<Collection<?>> message = received.get(0);
adapter.stop();
@@ -362,27 +358,26 @@ public void testWithJpaQueryAndDeletePerRow() throws Exception {
jpaPollingChannelAdapter, this.outputChannel, this.poller, this.context, this.getClass().getClassLoader());
adapter.start();
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- final List<Message<Collection<?>>> received = new ArrayList<Message<Collection<?>>>();
+ Thread.sleep(1000);
final Consumer consumer = new Consumer();
+ final List<Message<Collection<?>>> received = new ArrayList<Message<Collection<?>>>();
received.add(consumer.poll(5000));
- Message<Collection<?>> message = received.get(0);
+ final Message<Collection<?>> 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);
Please sign in to comment.
Something went wrong with that request. Please try again.