Skip to content

Commit 6a41eda

Browse files
committed
Upgrade Derby dependency and some tests polishing
https://build.spring.io/browse/INT-AT42SIO-590/ # Conflicts: # build.gradle Fix JDBC tests to close embedded DB https://build.spring.io/browse/INT-MJATS41-1030 (cherry picked from commit 171d169) # Conflicts: # spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/JdbcOutboundGatewayTests.java # spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcJavaConfigTests.java
1 parent 86634d2 commit 6a41eda

8 files changed

+31
-59
lines changed

build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ subprojects { subproject ->
9090
commonsIoVersion = '2.4'
9191
commonsNetVersion = '3.3'
9292
curatorVersion = '2.8.0'
93-
derbyVersion = '10.11.1.1'
93+
derbyVersion = '10.13.1.1'
9494
eclipseLinkVersion = '2.4.2'
9595
ftpServerVersion = '1.0.6'
9696
groovyVersion = '2.4.4'
@@ -458,8 +458,6 @@ project('spring-integration-jpa') {
458458
testCompile "org.springframework.data:spring-data-jpa:$springDataJpaVersion"
459459

460460
testCompile "com.h2database:h2:$h2Version"
461-
testCompile "org.hsqldb:hsqldb:$hsqldbVersion"
462-
testCompile "org.apache.derby:derby:$derbyVersion"
463461

464462
testCompile "org.hibernate:hibernate-entitymanager:$hibernateVersion"
465463

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
99
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
1010

11-
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
12-
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
13-
<property name="url" value="jdbc:derby:memory:myDB;create=true" />
14-
<property name="username" value="sa" />
15-
<property name="password" value="sa" />
16-
</bean>
11+
<jdbc:embedded-database id="dataSource" type="DERBY" />
1712

1813
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
1914
<jdbc:script location="${int.drop.script}" />
Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -16,29 +16,28 @@
1616
import static org.junit.Assert.fail;
1717
import static org.mockito.Mockito.mock;
1818

19-
import javax.sql.DataSource;
20-
2119
import org.junit.Assert;
2220
import org.junit.Test;
2321

2422
import org.springframework.beans.factory.BeanFactory;
2523
import org.springframework.jdbc.core.JdbcOperations;
24+
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
2625
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
2726

2827
/**
2928
*
3029
* @author Gunnar Hillert
3130
* @author Gary Russell
31+
* @author Artem Bilan
32+
*
3233
* @since 2.1
3334
*
3435
*/
3536
public class JdbcOutboundGatewayTests {
3637

3738
@Test
3839
public void testSetMaxRowsPerPollWithoutSelectQuery() {
39-
40-
41-
DataSource dataSource = new EmbeddedDatabaseBuilder().build();
40+
EmbeddedDatabase dataSource = new EmbeddedDatabaseBuilder().build();
4241

4342
JdbcOutboundGateway jdbcOutboundGateway = new JdbcOutboundGateway(dataSource, "update something");
4443

@@ -47,17 +46,17 @@ public void testSetMaxRowsPerPollWithoutSelectQuery() {
4746
jdbcOutboundGateway.setBeanFactory(mock(BeanFactory.class));
4847
jdbcOutboundGateway.afterPropertiesSet();
4948

50-
} catch (IllegalArgumentException e) {
49+
fail("Expected an IllegalArgumentException to be thrown.");
50+
}
51+
catch (IllegalArgumentException e) {
5152
assertEquals("If you want to set 'maxRowsPerPoll', then you must provide a 'selectQuery'.", e.getMessage());
52-
return;
5353
}
5454

55-
fail("Expected an IllegalArgumentException to be thrown.");
56-
55+
dataSource.shutdown();
5756
}
5857

5958
@Test
60-
public void testConstructorWithNulljdbcOperations() {
59+
public void testConstructorWithNullJdbcOperations() {
6160

6261
JdbcOperations jdbcOperations = null;
6362

@@ -74,43 +73,39 @@ public void testConstructorWithNulljdbcOperations() {
7473

7574
@Test
7675
public void testConstructorWithEmptyAndNullQueries() {
77-
78-
final DataSource dataSource = new EmbeddedDatabaseBuilder().build();
76+
EmbeddedDatabase dataSource = new EmbeddedDatabaseBuilder().build();
7977

8078
final String selectQuery = " ";
8179
final String updateQuery = null;
8280

8381
try {
8482
new JdbcOutboundGateway(dataSource, updateQuery, selectQuery);
83+
84+
fail("Expected an IllegalArgumentException to be thrown.");
8585
}
8686
catch (IllegalArgumentException e) {
8787
Assert.assertEquals("The 'updateQuery' and the 'selectQuery' must not both be null or empty.", e.getMessage());
88-
return;
8988
}
9089

91-
fail("Expected an IllegalArgumentException to be thrown.");
90+
dataSource.shutdown();
9291
}
9392

94-
/**
95-
* Test method for
96-
* {@link org.springframework.integration.jdbc.JdbcOutboundGateway#setMaxRowsPerPoll(Integer)}.
97-
*/
9893
@Test
9994
public void testSetMaxRowsPerPoll() {
100-
101-
102-
DataSource dataSource = new EmbeddedDatabaseBuilder().build();
95+
EmbeddedDatabase dataSource = new EmbeddedDatabaseBuilder().build();
10396

10497
JdbcOutboundGateway jdbcOutboundGateway = new JdbcOutboundGateway(dataSource, "select * from DOES_NOT_EXIST");
10598

10699
try {
107100
jdbcOutboundGateway.setMaxRowsPerPoll(null);
108-
} catch (IllegalArgumentException e) {
101+
102+
fail("Expected an IllegalArgumentException to be thrown.");
103+
}
104+
catch (IllegalArgumentException e) {
109105
assertEquals("MaxRowsPerPoll must not be null.", e.getMessage());
110-
return;
111106
}
112107

113-
fail("Expected an IllegalArgumentException to be thrown.");
114-
108+
dataSource.shutdown();
115109
}
110+
116111
}

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/StoredProcJavaConfigTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2017 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.
@@ -61,6 +61,8 @@
6161
* Equivalent to {@link StoredProcPollingChannelAdapterWithNamespaceIntegrationTests}.
6262
*
6363
* @author Gary Russell
64+
* @author Artem Bilan
65+
*
6466
* @since 4.2
6567
*
6668
*/
@@ -130,7 +132,7 @@ public StoredProcExecutor storedProcExecutor() {
130132
return executor;
131133
}
132134

133-
@Bean
135+
@Bean(destroyMethod = "shutdown")
134136
public DataSource dataSource() {
135137
return new EmbeddedDatabaseBuilder()
136138
.setType(EmbeddedDatabaseType.H2)

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
<beans xmlns="http://www.springframework.org/schema/beans"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns:int="http://www.springframework.org/schema/integration"
5-
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
65
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
7-
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
8-
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
6+
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
97
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
108
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
119

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22
<beans xmlns="http://www.springframework.org/schema/beans"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns:int="http://www.springframework.org/schema/integration"
5-
xmlns:tx="http://www.springframework.org/schema/tx"
6-
xmlns:util="http://www.springframework.org/schema/util"
75
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
86
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
97
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
108
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
119
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
12-
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
13-
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
14-
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
10+
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
1511

1612
<jdbc:embedded-database id="dataSource" type="H2">
1713
<jdbc:script location="classpath:h2-stored-procedures.sql"/>

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/channel/DataSource-derby-context.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,7 @@
88

99
<import resource="classpath:org/springframework/integration/jdbc/store/channel/DataSource-common-context.xml" />
1010

11-
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
12-
destroy-method="close">
13-
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
14-
<property name="initialSize" value="10" />
15-
<property name="url" value="jdbc:derby:memory:integration;create=true" />
16-
<property name="username" value="int" />
17-
<property name="password" value="int" />
18-
</bean>
11+
<jdbc:embedded-database id="dataSource" type="DERBY" />
1912

2013
<!-- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
2114
destroy-method="close"> <property name="driverClassName" value="org.apache.derby.jdbc.ClientDriver"/>

spring-integration-jdbc/src/test/resources/derby-stored-procedures-setup-context.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
66
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
77

8-
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
9-
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
10-
<property name="url" value="jdbc:derby:memory:myDB;create=true" />
11-
<property name="username" value="sa" />
12-
<property name="password" value="sa" />
13-
</bean>
8+
<jdbc:embedded-database id="dataSource" type="DERBY" />
149

1510
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS" >
1611
<jdbc:script location="classpath:derby-stored-procedures-drops.sql"/>

0 commit comments

Comments
 (0)