Skip to content

Commit

Permalink
Fix JDBC tests and some upgrades
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
artembilan authored and garyrussell committed Feb 28, 2018
1 parent b55a5bd commit cb0d43d
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 75 deletions.
22 changes: 11 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ buildscript {
maven { url 'https://repo.spring.io/plugins-release' }
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE'
classpath 'io.spring.gradle:dependency-management-plugin:1.0.4.RELEASE'
classpath 'io.spring.gradle:spring-io-plugin:0.0.8.RELEASE'
classpath 'io.spring.gradle:docbook-reference-plugin:0.3.1'
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.0'
}
}

plugins {
id 'org.sonarqube' version '2.5'
id 'org.sonarqube' version '2.6.1'
}

description = 'Spring Integration'
Expand Down Expand Up @@ -90,13 +90,13 @@ subprojects { subproject ->
activeMqVersion = '5.15.2'
apacheSshdVersion = '1.6.0'
aspectjVersion = '1.8.13'
assertjVersion = '2.6.0'
assertjVersion = '3.9.1'
boonVersion = '0.34'
commonsDbcp2Version = '2.1.1'
commonsIoVersion = '2.4'
commonsNetVersion = '3.5'
curatorVersion = '2.11.1'
derbyVersion = '10.13.1.1'
derbyVersion = '10.14.1.0'
eclipseLinkVersion = '2.6.4'
ftpServerVersion = '1.1.1'
groovyVersion = '2.4.12'
Expand Down Expand Up @@ -125,17 +125,17 @@ subprojects { subproject ->
mysqlVersion = '6.0.6'
pahoMqttClientVersion = '1.2.0'
postgresVersion = '42.0.0'
reactorNettyVersion = '0.7.4.RELEASE'
reactorVersion = '3.1.4.RELEASE'
reactorNettyVersion = '0.7.5.RELEASE'
reactorVersion = '3.1.5.RELEASE'
romeToolsVersion = '1.8.0'
servletApiVersion = '4.0.0'
smackVersion = '4.2.2'
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.0.2.RELEASE'
springDataJpaVersion = '2.0.4.RELEASE'
springDataMongoVersion = '2.0.4.RELEASE'
springDataRedisVersion = '2.0.4.RELEASE'
springGemfireVersion = '2.0.4.RELEASE'
springSecurityVersion = '5.0.2.RELEASE'
springDataJpaVersion = '2.0.5.RELEASE'
springDataMongoVersion = '2.0.5.RELEASE'
springDataRedisVersion = '2.0.5.RELEASE'
springGemfireVersion = '2.0.5.RELEASE'
springSecurityVersion = '5.0.3.RELEASE'
springSocialTwitterVersion = '1.1.2.RELEASE'
springRetryVersion = '1.2.2.RELEASE'
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.0.4.RELEASE'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<stream-transformer input-channel="directInput" output-channel="output"/>

<stream-transformer input-channel="queueInput" output-channel="output">
<poller fixed-delay="10000"/>
<poller fixed-delay="1"/>
</stream-transformer>

<chain input-channel="charsetChannel" output-channel="output">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,6 +39,7 @@
/**
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
Expand All @@ -64,23 +65,23 @@ public class StreamTransformerParserTests {
@Test
public void directChannelWithStringMessage() {
this.directInput.send(new GenericMessage<InputStream>(new ByteArrayInputStream("foo".getBytes())));
Message<?> result = output.receive(0);
Message<?> result = output.receive(10000);
assertNotNull(result);
assertArrayEquals("foo".getBytes(), (byte[]) result.getPayload());
}

@Test
public void queueChannelWithStringMessage() {
this.queueInput.send(new GenericMessage<InputStream>(new ByteArrayInputStream("foo".getBytes())));
Message<?> result = output.receive(3000);
Message<?> result = output.receive(10000);
assertNotNull(result);
assertArrayEquals("foo".getBytes(), (byte[]) result.getPayload());
}

@Test
public void charset() {
this.charsetChannel.send(new GenericMessage<InputStream>(new ByteArrayInputStream("foo".getBytes())));
Message<?> result = output.receive(0);
Message<?> result = output.receive(10000);
assertNotNull(result);
assertEquals("foo", result.getPayload());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
<property name="defaultTimeout" value="10"/>
</bean>

<int:header-enricher input-channel="routingSlip" output-channel="input">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,6 +31,7 @@
import java.util.concurrent.TimeUnit;

import org.hamcrest.Matchers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -39,6 +40,7 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.serializer.support.SerializationFailedException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.store.MessageGroup;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageDeliveryException;
Expand Down Expand Up @@ -81,25 +83,36 @@ public class JdbcMessageStoreChannelIntegrationTests {
@Autowired
private MessageChannel routingSlip;

@Autowired
@Qualifier("service-activator")
private AbstractEndpoint serviceActivator;

@Before
public void clear() {
Service.reset(1);
for (MessageGroup group : messageStore) {
messageStore.removeMessageGroup(group.getGroupId());
}

this.serviceActivator.start();
}

@After
public void tearDown() {
this.serviceActivator.stop();
}

@Test
public void testSendAndActivate() throws Exception {
input.send(new GenericMessage<String>("foo"));
input.send(new GenericMessage<>("foo"));
Service.await(10000);
assertEquals(1, Service.messages.size());
}

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

synchronized (storeLock) {

boolean result1 = input.send(new GenericMessage<String>("foo"), 100L);
boolean result1 = input.send(new GenericMessage<>("foo"), 100L);
// This will time out because the transaction has not committed yet
try {
Service.await(300);
Service.await(100);
fail("Expected timeout");
}
catch (Exception e) {
Expand Down Expand Up @@ -174,7 +187,7 @@ protected void waitForMessage() throws InterruptedException {
}

@Test
public void testSameTransactionSendAndReceive() throws Exception {
public void testSameTransactionSendAndReceive() {

final StopWatch stopWatch = new StopWatch();
DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition();
Expand Down Expand Up @@ -225,7 +238,7 @@ public void testSameTransactionSendAndReceive() throws Exception {
@Test
public void testWithRoutingSlip() {
try {
this.routingSlip.send(new GenericMessage<String>("foo"));
this.routingSlip.send(new GenericMessage<>("foo"));
fail("MessageDeliveryException expected");
}
catch (Exception e) {
Expand All @@ -241,7 +254,7 @@ public static class Service {

private static boolean fail = false;

private static List<String> messages = new CopyOnWriteArrayList<String>();
private static List<String> messages = new CopyOnWriteArrayList<>();

private static CountDownLatch latch;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
<property name="defaultTimeout" value="10"/>
</bean>

</beans>
Loading

0 comments on commit cb0d43d

Please sign in to comment.