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
This commit is contained in:
Artem Bilan
2017-06-23 09:10:32 -04:00
parent 86634d237a
commit 6a41eda048
8 changed files with 31 additions and 59 deletions

View File

@@ -90,7 +90,7 @@ subprojects { subproject ->
commonsIoVersion = '2.4'
commonsNetVersion = '3.3'
curatorVersion = '2.8.0'
derbyVersion = '10.11.1.1'
derbyVersion = '10.13.1.1'
eclipseLinkVersion = '2.4.2'
ftpServerVersion = '1.0.6'
groovyVersion = '2.4.4'
@@ -458,8 +458,6 @@ project('spring-integration-jpa') {
testCompile "org.springframework.data:spring-data-jpa:$springDataJpaVersion"
testCompile "com.h2database:h2:$h2Version"
testCompile "org.hsqldb:hsqldb:$hsqldbVersion"
testCompile "org.apache.derby:derby:$derbyVersion"
testCompile "org.hibernate:hibernate-entitymanager:$hibernateVersion"

View File

@@ -8,12 +8,7 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="url" value="jdbc:derby:memory:myDB;create=true" />
<property name="username" value="sa" />
<property name="password" value="sa" />
</bean>
<jdbc:embedded-database id="dataSource" type="DERBY" />
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS">
<jdbc:script location="${int.drop.script}" />

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 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. You may obtain a copy of the License at
@@ -16,19 +16,20 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import javax.sql.DataSource;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
/**
*
* @author Gunnar Hillert
* @author Gary Russell
* @author Artem Bilan
*
* @since 2.1
*
*/
@@ -36,9 +37,7 @@ public class JdbcOutboundGatewayTests {
@Test
public void testSetMaxRowsPerPollWithoutSelectQuery() {
DataSource dataSource = new EmbeddedDatabaseBuilder().build();
EmbeddedDatabase dataSource = new EmbeddedDatabaseBuilder().build();
JdbcOutboundGateway jdbcOutboundGateway = new JdbcOutboundGateway(dataSource, "update something");
@@ -47,17 +46,17 @@ public class JdbcOutboundGatewayTests {
jdbcOutboundGateway.setBeanFactory(mock(BeanFactory.class));
jdbcOutboundGateway.afterPropertiesSet();
} catch (IllegalArgumentException e) {
fail("Expected an IllegalArgumentException to be thrown.");
}
catch (IllegalArgumentException e) {
assertEquals("If you want to set 'maxRowsPerPoll', then you must provide a 'selectQuery'.", e.getMessage());
return;
}
fail("Expected an IllegalArgumentException to be thrown.");
dataSource.shutdown();
}
@Test
public void testConstructorWithNulljdbcOperations() {
public void testConstructorWithNullJdbcOperations() {
JdbcOperations jdbcOperations = null;
@@ -74,43 +73,39 @@ public class JdbcOutboundGatewayTests {
@Test
public void testConstructorWithEmptyAndNullQueries() {
final DataSource dataSource = new EmbeddedDatabaseBuilder().build();
EmbeddedDatabase dataSource = new EmbeddedDatabaseBuilder().build();
final String selectQuery = " ";
final String updateQuery = null;
try {
new JdbcOutboundGateway(dataSource, updateQuery, selectQuery);
fail("Expected an IllegalArgumentException to be thrown.");
}
catch (IllegalArgumentException e) {
Assert.assertEquals("The 'updateQuery' and the 'selectQuery' must not both be null or empty.", e.getMessage());
return;
}
fail("Expected an IllegalArgumentException to be thrown.");
dataSource.shutdown();
}
/**
* Test method for
* {@link org.springframework.integration.jdbc.JdbcOutboundGateway#setMaxRowsPerPoll(Integer)}.
*/
@Test
public void testSetMaxRowsPerPoll() {
DataSource dataSource = new EmbeddedDatabaseBuilder().build();
EmbeddedDatabase dataSource = new EmbeddedDatabaseBuilder().build();
JdbcOutboundGateway jdbcOutboundGateway = new JdbcOutboundGateway(dataSource, "select * from DOES_NOT_EXIST");
try {
jdbcOutboundGateway.setMaxRowsPerPoll(null);
} catch (IllegalArgumentException e) {
fail("Expected an IllegalArgumentException to be thrown.");
}
catch (IllegalArgumentException e) {
assertEquals("MaxRowsPerPoll must not be null.", e.getMessage());
return;
}
fail("Expected an IllegalArgumentException to be thrown.");
dataSource.shutdown();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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.
@@ -61,6 +61,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* Equivalent to {@link StoredProcPollingChannelAdapterWithNamespaceIntegrationTests}.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 4.2
*
*/
@@ -130,7 +132,7 @@ public class StoredProcJavaConfigTests {
return executor;
}
@Bean
@Bean(destroyMethod = "shutdown")
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder()
.setType(EmbeddedDatabaseType.H2)

View File

@@ -2,10 +2,8 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
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.xsd
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

View File

@@ -2,16 +2,12 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
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.xsd
http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.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">
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<jdbc:embedded-database id="dataSource" type="H2">
<jdbc:script location="classpath:h2-stored-procedures.sql"/>

View File

@@ -8,14 +8,7 @@
<import resource="classpath:org/springframework/integration/jdbc/store/channel/DataSource-common-context.xml" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="initialSize" value="10" />
<property name="url" value="jdbc:derby:memory:integration;create=true" />
<property name="username" value="int" />
<property name="password" value="int" />
</bean>
<jdbc:embedded-database id="dataSource" type="DERBY" />
<!-- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"> <property name="driverClassName" value="org.apache.derby.jdbc.ClientDriver"/>

View File

@@ -5,12 +5,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="url" value="jdbc:derby:memory:myDB;create=true" />
<property name="username" value="sa" />
<property name="password" value="sa" />
</bean>
<jdbc:embedded-database id="dataSource" type="DERBY" />
<jdbc:initialize-database data-source="dataSource" ignore-failures="DROPS" >
<jdbc:script location="classpath:derby-stored-procedures-drops.sql"/>