Skip to content

Commit cb0d43d

Browse files
artembilangaryrussell
authored andcommitted
Fix JDBC tests and some upgrades
https://build.spring.io/browse/INT-FATS5IC-430 Looks like there is a race condition when our polling rate around data base is too fast and we have access to the DB files even during application context close. * Stop polling channel adapter in the tests explicitly after test methods * Increase some tests performance decreasing timeouts to wait * Upgrade to Reactor-3.1.5, AssertJ-3.9.1, Derby-10.14.1.0 and some Gradle plugins * Upgrade to `reactor-netty-0.7.5` * Remove workaround from the `StompServerIntegrationTests` * Upgrade to Spring Data Kay SR5 * Upgrade to Spring Security 5.0.3 * Increase timeouts and performance in the `StreamTransformerParserTests`
1 parent b55a5bd commit cb0d43d

File tree

8 files changed

+103
-75
lines changed

8 files changed

+103
-75
lines changed

build.gradle

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ buildscript {
33
maven { url 'https://repo.spring.io/plugins-release' }
44
}
55
dependencies {
6-
classpath 'io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE'
6+
classpath 'io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE'
77
classpath 'io.spring.gradle:spring-io-plugin:0.0.8.RELEASE'
88
classpath 'io.spring.gradle:docbook-reference-plugin:0.3.1'
99
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.0'
1010
}
1111
}
1212

1313
plugins {
14-
id 'org.sonarqube' version '2.5'
14+
id 'org.sonarqube' version '2.6.1'
1515
}
1616

1717
description = 'Spring Integration'
@@ -90,13 +90,13 @@ subprojects { subproject ->
9090
activeMqVersion = '5.15.2'
9191
apacheSshdVersion = '1.6.0'
9292
aspectjVersion = '1.8.13'
93-
assertjVersion = '2.6.0'
93+
assertjVersion = '3.9.1'
9494
boonVersion = '0.34'
9595
commonsDbcp2Version = '2.1.1'
9696
commonsIoVersion = '2.4'
9797
commonsNetVersion = '3.5'
9898
curatorVersion = '2.11.1'
99-
derbyVersion = '10.13.1.1'
99+
derbyVersion = '10.14.1.0'
100100
eclipseLinkVersion = '2.6.4'
101101
ftpServerVersion = '1.1.1'
102102
groovyVersion = '2.4.12'
@@ -125,17 +125,17 @@ subprojects { subproject ->
125125
mysqlVersion = '6.0.6'
126126
pahoMqttClientVersion = '1.2.0'
127127
postgresVersion = '42.0.0'
128-
reactorNettyVersion = '0.7.4.RELEASE'
129-
reactorVersion = '3.1.4.RELEASE'
128+
reactorNettyVersion = '0.7.5.RELEASE'
129+
reactorVersion = '3.1.5.RELEASE'
130130
romeToolsVersion = '1.8.0'
131131
servletApiVersion = '4.0.0'
132132
smackVersion = '4.2.2'
133133
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.0.2.RELEASE'
134-
springDataJpaVersion = '2.0.4.RELEASE'
135-
springDataMongoVersion = '2.0.4.RELEASE'
136-
springDataRedisVersion = '2.0.4.RELEASE'
137-
springGemfireVersion = '2.0.4.RELEASE'
138-
springSecurityVersion = '5.0.2.RELEASE'
134+
springDataJpaVersion = '2.0.5.RELEASE'
135+
springDataMongoVersion = '2.0.5.RELEASE'
136+
springDataRedisVersion = '2.0.5.RELEASE'
137+
springGemfireVersion = '2.0.5.RELEASE'
138+
springSecurityVersion = '5.0.3.RELEASE'
139139
springSocialTwitterVersion = '1.1.2.RELEASE'
140140
springRetryVersion = '1.2.2.RELEASE'
141141
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.0.4.RELEASE'

spring-integration-core/src/test/java/org/springframework/integration/config/xml/StreamTransformerParserTests-context.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<stream-transformer input-channel="directInput" output-channel="output"/>
2121

2222
<stream-transformer input-channel="queueInput" output-channel="output">
23-
<poller fixed-delay="10000"/>
23+
<poller fixed-delay="1"/>
2424
</stream-transformer>
2525

2626
<chain input-channel="charsetChannel" output-channel="output">

spring-integration-core/src/test/java/org/springframework/integration/config/xml/StreamTransformerParserTests.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016 the original author or authors.
2+
* Copyright 2016-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,6 +39,7 @@
3939
/**
4040
* @author Mark Fisher
4141
* @author Gary Russell
42+
* @author Artem Bilan
4243
*/
4344
@ContextConfiguration
4445
@RunWith(SpringJUnit4ClassRunner.class)
@@ -64,23 +65,23 @@ public class StreamTransformerParserTests {
6465
@Test
6566
public void directChannelWithStringMessage() {
6667
this.directInput.send(new GenericMessage<InputStream>(new ByteArrayInputStream("foo".getBytes())));
67-
Message<?> result = output.receive(0);
68+
Message<?> result = output.receive(10000);
6869
assertNotNull(result);
6970
assertArrayEquals("foo".getBytes(), (byte[]) result.getPayload());
7071
}
7172

7273
@Test
7374
public void queueChannelWithStringMessage() {
7475
this.queueInput.send(new GenericMessage<InputStream>(new ByteArrayInputStream("foo".getBytes())));
75-
Message<?> result = output.receive(3000);
76+
Message<?> result = output.receive(10000);
7677
assertNotNull(result);
7778
assertArrayEquals("foo".getBytes(), (byte[]) result.getPayload());
7879
}
7980

8081
@Test
8182
public void charset() {
8283
this.charsetChannel.send(new GenericMessage<InputStream>(new ByteArrayInputStream("foo".getBytes())));
83-
Message<?> result = output.receive(0);
84+
Message<?> result = output.receive(10000);
8485
assertNotNull(result);
8586
assertEquals("foo", result.getPayload());
8687
}

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/JdbcMessageStoreChannelIntegrationTests-context.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<bean id="transactionManager"
6666
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
6767
<property name="dataSource" ref="dataSource"/>
68+
<property name="defaultTimeout" value="10"/>
6869
</bean>
6970

7071
<int:header-enricher input-channel="routingSlip" output-channel="input">

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/JdbcMessageStoreChannelIntegrationTests.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
import java.util.concurrent.TimeUnit;
3232

3333
import org.hamcrest.Matchers;
34+
import org.junit.After;
3435
import org.junit.Before;
3536
import org.junit.Test;
3637
import org.junit.runner.RunWith;
@@ -39,6 +40,7 @@
3940
import org.springframework.beans.factory.annotation.Qualifier;
4041
import org.springframework.core.serializer.support.SerializationFailedException;
4142
import org.springframework.integration.channel.QueueChannel;
43+
import org.springframework.integration.endpoint.AbstractEndpoint;
4244
import org.springframework.integration.store.MessageGroup;
4345
import org.springframework.messaging.MessageChannel;
4446
import org.springframework.messaging.MessageDeliveryException;
@@ -81,25 +83,36 @@ public class JdbcMessageStoreChannelIntegrationTests {
8183
@Autowired
8284
private MessageChannel routingSlip;
8385

86+
@Autowired
87+
@Qualifier("service-activator")
88+
private AbstractEndpoint serviceActivator;
89+
8490
@Before
8591
public void clear() {
8692
Service.reset(1);
8793
for (MessageGroup group : messageStore) {
8894
messageStore.removeMessageGroup(group.getGroupId());
8995
}
96+
97+
this.serviceActivator.start();
98+
}
99+
100+
@After
101+
public void tearDown() {
102+
this.serviceActivator.stop();
90103
}
91104

92105
@Test
93106
public void testSendAndActivate() throws Exception {
94-
input.send(new GenericMessage<String>("foo"));
107+
input.send(new GenericMessage<>("foo"));
95108
Service.await(10000);
96109
assertEquals(1, Service.messages.size());
97110
}
98111

99112
@Test
100113
public void testSendAndActivateWithRollback() throws Exception {
101114
Service.fail = true;
102-
input.send(new GenericMessage<String>("foo"));
115+
input.send(new GenericMessage<>("foo"));
103116
Service.await(10000);
104117
assertThat(Service.messages.size(), Matchers.greaterThanOrEqualTo(1));
105118
// After a rollback in the poller the message is still waiting to be delivered
@@ -126,10 +139,10 @@ public void testTransactionalSendAndReceive() throws Exception {
126139

127140
synchronized (storeLock) {
128141

129-
boolean result1 = input.send(new GenericMessage<String>("foo"), 100L);
142+
boolean result1 = input.send(new GenericMessage<>("foo"), 100L);
130143
// This will time out because the transaction has not committed yet
131144
try {
132-
Service.await(300);
145+
Service.await(100);
133146
fail("Expected timeout");
134147
}
135148
catch (Exception e) {
@@ -174,7 +187,7 @@ protected void waitForMessage() throws InterruptedException {
174187
}
175188

176189
@Test
177-
public void testSameTransactionSendAndReceive() throws Exception {
190+
public void testSameTransactionSendAndReceive() {
178191

179192
final StopWatch stopWatch = new StopWatch();
180193
DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition();
@@ -225,7 +238,7 @@ public void testSameTransactionSendAndReceive() throws Exception {
225238
@Test
226239
public void testWithRoutingSlip() {
227240
try {
228-
this.routingSlip.send(new GenericMessage<String>("foo"));
241+
this.routingSlip.send(new GenericMessage<>("foo"));
229242
fail("MessageDeliveryException expected");
230243
}
231244
catch (Exception e) {
@@ -241,7 +254,7 @@ public static class Service {
241254

242255
private static boolean fail = false;
243256

244-
private static List<String> messages = new CopyOnWriteArrayList<String>();
257+
private static List<String> messages = new CopyOnWriteArrayList<>();
245258

246259
private static CountDownLatch latch;
247260

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/JdbcMessageStoreChannelOnePollerIntegrationTests-context.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<bean id="transactionManager"
6060
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
6161
<property name="dataSource" ref="dataSource" />
62+
<property name="defaultTimeout" value="10"/>
6263
</bean>
6364

6465
</beans>

0 commit comments

Comments
 (0)