Drop H2 schema before JDBC tests
https://build.spring.io/browse/INT-MJATS41-1679/
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
http://www.springframework.org/schema/integration/jdbc https://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd">
|
||||
|
||||
<jdbc:embedded-database id="dataSource" type="H2">
|
||||
<jdbc:script location="org/springframework/integration/jdbc/schema-drop-h2.sql"/>
|
||||
<jdbc:script location="org/springframework/integration/jdbc/schema-h2.sql"/>
|
||||
</jdbc:embedded-database>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -18,8 +18,6 @@ package org.springframework.integration.jdbc;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -28,28 +26,32 @@ import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
||||
|
||||
/**
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class JdbcMessageStoreRegionTests {
|
||||
|
||||
private static EmbeddedDatabase dataSource;
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
private JdbcMessageStore messageStore1;
|
||||
|
||||
private JdbcMessageStore messageStore2;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupDatabase() {
|
||||
dataSource = new EmbeddedDatabaseBuilder()
|
||||
.setType(EmbeddedDatabaseType.H2)
|
||||
.addScript("classpath:/org/springframework/integration/jdbc/schema-drop-h2.sql")
|
||||
.addScript("classpath:/org/springframework/integration/jdbc/schema-h2.sql")
|
||||
.build();
|
||||
}
|
||||
@@ -77,7 +79,7 @@ public class JdbcMessageStoreRegionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVerifyMessageCount() throws Exception {
|
||||
public void testVerifyMessageCount() {
|
||||
|
||||
messageStore1.addMessage(MessageBuilder.withPayload("payload1").build());
|
||||
messageStore1.addMessage(MessageBuilder.withPayload("payload2").build());
|
||||
@@ -91,7 +93,7 @@ public class JdbcMessageStoreRegionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertNullRegion() throws Exception {
|
||||
public void testInsertNullRegion() {
|
||||
|
||||
try {
|
||||
messageStore1.setRegion(null);
|
||||
@@ -105,7 +107,7 @@ public class JdbcMessageStoreRegionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVerifyMessageGroupCount() throws Exception {
|
||||
public void testVerifyMessageGroupCount() {
|
||||
|
||||
messageStore1.addMessageToGroup("group1", MessageBuilder.withPayload("payload1").build());
|
||||
messageStore1.addMessageToGroup("group2", MessageBuilder.withPayload("payload2").build());
|
||||
@@ -124,30 +126,20 @@ public class JdbcMessageStoreRegionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionSetToMessageGroup() throws Exception {
|
||||
public void testRegionSetToMessageGroup() {
|
||||
|
||||
messageStore1.addMessageToGroup("group1", MessageBuilder.withPayload("payload1").build());
|
||||
|
||||
List<String> regions = jdbcTemplate.query("Select * from INT_MESSAGE_GROUP where REGION = 'region1'", new RowMapper<String>() {
|
||||
|
||||
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
return rs.getString("REGION");
|
||||
}
|
||||
|
||||
});
|
||||
List<String> regions = jdbcTemplate.query("Select * from INT_MESSAGE_GROUP where REGION = 'region1'",
|
||||
(rs, rowNum) -> rs.getString("REGION"));
|
||||
|
||||
assertEquals(1, regions.size());
|
||||
assertEquals("region1", regions.get(0));
|
||||
|
||||
messageStore2.addMessageToGroup("group1", MessageBuilder.withPayload("payload1").build());
|
||||
|
||||
List<String> regions2 = jdbcTemplate.query("Select * from INT_MESSAGE_GROUP where REGION = 'region2'", new RowMapper<String>() {
|
||||
|
||||
public String mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
return rs.getString("REGION");
|
||||
}
|
||||
|
||||
});
|
||||
List<String> regions2 = jdbcTemplate.query("Select * from INT_MESSAGE_GROUP where REGION = 'region2'",
|
||||
(rs, rowNum) -> rs.getString("REGION"));
|
||||
|
||||
assertEquals(1, regions2.size());
|
||||
assertEquals("region2", regions2.get(0));
|
||||
@@ -155,7 +147,7 @@ public class JdbcMessageStoreRegionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveMessageGroup() throws Exception {
|
||||
public void testRemoveMessageGroup() {
|
||||
|
||||
messageStore1.addMessageToGroup("group1", MessageBuilder.withPayload("payload1").build());
|
||||
messageStore1.addMessageToGroup("group2", MessageBuilder.withPayload("payload2").build());
|
||||
@@ -169,4 +161,5 @@ public class JdbcMessageStoreRegionTests {
|
||||
assertEquals(2, messageStore2.getMessageGroupCount());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public class JdbcLockRegistryLeaderInitiatorTests {
|
||||
public static void init() {
|
||||
dataSource = new EmbeddedDatabaseBuilder()
|
||||
.setType(EmbeddedDatabaseType.H2)
|
||||
.addScript("classpath:/org/springframework/integration/jdbc/schema-drop-h2.sql")
|
||||
.addScript("classpath:/org/springframework/integration/jdbc/schema-h2.sql")
|
||||
.build();
|
||||
}
|
||||
@@ -66,7 +67,7 @@ public class JdbcLockRegistryLeaderInitiatorTests {
|
||||
public void testDistributedLeaderElection() throws Exception {
|
||||
CountDownLatch granted = new CountDownLatch(1);
|
||||
CountingPublisher countingPublisher = new CountingPublisher(granted);
|
||||
List<LockRegistryLeaderInitiator> initiators = new ArrayList<LockRegistryLeaderInitiator>();
|
||||
List<LockRegistryLeaderInitiator> initiators = new ArrayList<>();
|
||||
for (int i = 0; i < 2; i++) {
|
||||
DefaultLockRepository lockRepository = new DefaultLockRepository(dataSource);
|
||||
lockRepository.afterPropertiesSet();
|
||||
|
||||
Reference in New Issue
Block a user