From c2b520c2185153521decd4890acbc4b891586a1b Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Sun, 17 Apr 2016 23:11:05 -0400 Subject: [PATCH] INT-3996: Fix JdbcChannelMessageStore Javadoc JIRA: https://jira.spring.io/browse/INT-3996 One of the query provider implementations was missing. To avoid a maintenance nightmare, simply reference the interface's javadoc which lists all known implementations. * Simple `JdbcChannelMessageStore` JavaDocs polishing * Add `LogAdjustingTestSupport` to the `StompIntegrationTests` to trace failures in the future. * Also change the test `Start/Stop` messages to the `WARN` level in the `LogAdjustingTestSupport`, because `DEBUG` doesn't work everywhere. Maybe some logging systems mix misconfiguration, like we have in the WebSocket modules with the Embedded Tomcat (cherry picked from commit 9e092d4) --- .../jdbc/store/JdbcChannelMessageStore.java | 29 +++++-------------- .../test/support/LogAdjustingTestSupport.java | 6 ++-- .../client/StompIntegrationTests.java | 24 ++++++++++----- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcChannelMessageStore.java b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcChannelMessageStore.java index a4b090d6c8..f1fcfe2683 100644 --- a/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcChannelMessageStore.java +++ b/spring-integration-jdbc/src/main/java/org/springframework/integration/jdbc/store/JdbcChannelMessageStore.java @@ -43,11 +43,8 @@ import org.springframework.core.serializer.support.SerializingConverter; import org.springframework.integration.IntegrationMessageHeaderAccessor; import org.springframework.integration.jdbc.JdbcMessageStore; import org.springframework.integration.jdbc.store.channel.ChannelMessageStoreQueryProvider; -import org.springframework.integration.jdbc.store.channel.DerbyChannelMessageStoreQueryProvider; import org.springframework.integration.jdbc.store.channel.MessageRowMapper; -import org.springframework.integration.jdbc.store.channel.MySqlChannelMessageStoreQueryProvider; import org.springframework.integration.jdbc.store.channel.OracleChannelMessageStoreQueryProvider; -import org.springframework.integration.jdbc.store.channel.PostgresChannelMessageStoreQueryProvider; import org.springframework.integration.store.MessageGroup; import org.springframework.integration.store.MessageGroupStore; import org.springframework.integration.store.MessageStore; @@ -246,27 +243,17 @@ public class JdbcChannelMessageStore implements PriorityCapableChannelMessageSto } /** - *

- * Sets the database specific {@link ChannelMessageStoreQueryProvider} to use. The {@link JdbcChannelMessageStore} - * provides the SQL queries to retrieve messages from the database. The - * following {@link ChannelMessageStoreQueryProvider} are provided: - *

- * - *

- * Beyond, you can provide your own query implementations, in case you need - * to support additional databases and/or need to fine-tune the queries for - * your requirements. - *

- * + * Sets the database specific {@link ChannelMessageStoreQueryProvider} to use. + * The {@link JdbcChannelMessageStore} provides the SQL queries to retrieve messages from + * the database. See the JavaDocs {@link ChannelMessageStoreQueryProvider} (all known + * implementing classes) to see those implementations provided by the framework. + *

You can provide your own query implementations, if you need to support additional + * databases and/or need to fine-tune the queries for your requirements. * @param channelMessageStoreQueryProvider Must not be null. */ public void setChannelMessageStoreQueryProvider(ChannelMessageStoreQueryProvider channelMessageStoreQueryProvider) { - Assert.notNull(channelMessageStoreQueryProvider, "The provided channelMessageStoreQueryProvider must not be null."); + Assert.notNull(channelMessageStoreQueryProvider, + "The provided channelMessageStoreQueryProvider must not be null."); this.channelMessageStoreQueryProvider = channelMessageStoreQueryProvider; } diff --git a/spring-integration-test/src/main/java/org/springframework/integration/test/support/LogAdjustingTestSupport.java b/spring-integration-test/src/main/java/org/springframework/integration/test/support/LogAdjustingTestSupport.java index f86d88af4b..a8a76fccbc 100644 --- a/spring-integration-test/src/main/java/org/springframework/integration/test/support/LogAdjustingTestSupport.java +++ b/spring-integration-test/src/main/java/org/springframework/integration/test/support/LogAdjustingTestSupport.java @@ -33,8 +33,10 @@ import org.junit.rules.TestName; * Base class for module tests where logging is set to TRACE for the duration * of the test and reverted to the previous value. Also logs a start/end * message. Duplicated in s-i-core/src/test for use there, to avoid circular dep. + * * @author Artem Bilan * @author Gary Russell + * * @since 4.2.2 * */ @@ -70,12 +72,12 @@ public class LogAdjustingTestSupport { this.oldCategories.add(loggerToAdjust.getEffectiveLevel()); loggerToAdjust.setLevel(Level.TRACE); } - this.logger.debug("!!!! Starting test: " + this.testName.getMethodName() + " !!!!"); + this.logger.warn("!!!! Starting test: " + this.testName.getMethodName() + " !!!!"); } @After public void afterTest() { - logger.debug("!!!! Finished test: " + this.testName.getMethodName() + " !!!!"); + logger.warn("!!!! Finished test: " + this.testName.getMethodName() + " !!!!"); Iterator oldCategory = this.oldCategories.iterator(); for (Logger loggerToAdjust : this.loggersToAdjust) { loggerToAdjust.setLevel(oldCategory.next()); diff --git a/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/client/StompIntegrationTests.java b/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/client/StompIntegrationTests.java index d688413d38..9be482ff9c 100644 --- a/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/client/StompIntegrationTests.java +++ b/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/client/StompIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2015 the original author or authors. + * Copyright 2014-2016 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. @@ -28,10 +28,10 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.nio.ByteBuffer; import java.util.Collections; -import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -56,6 +56,7 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.core.MessageProducer; import org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer; +import org.springframework.integration.test.support.LogAdjustingTestSupport; import org.springframework.integration.test.util.TestUtils; import org.springframework.integration.transformer.ExpressionEvaluatingTransformer; import org.springframework.integration.websocket.ClientWebSocketContainer; @@ -71,7 +72,6 @@ import org.springframework.messaging.MessageHandler; import org.springframework.messaging.PollableChannel; import org.springframework.messaging.handler.annotation.MessageExceptionHandler; import org.springframework.messaging.handler.annotation.MessageMapping; -import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.messaging.simp.annotation.SendToUser; import org.springframework.messaging.simp.annotation.SubscribeMapping; import org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler; @@ -86,7 +86,6 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.util.MultiValueMap; -import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.client.WebSocketClient; import org.springframework.web.socket.client.standard.StandardWebSocketClient; import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer; @@ -110,7 +109,7 @@ import org.springframework.web.socket.sockjs.client.WebSocketTransport; @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) @DirtiesContext -public class StompIntegrationTests { +public class StompIntegrationTests extends LogAdjustingTestSupport { @Value("#{server.serverContext}") private ApplicationContext serverContext; @@ -128,7 +127,18 @@ public class StompIntegrationTests { @Autowired @Qualifier("webSocketEvents") - private PollableChannel webSocketEvents; + private QueueChannel webSocketEvents; + + public StompIntegrationTests() { + super("org.springframework", "org.springframework.integration"); + } + + @Before + public void setup() { + this.webSocketInputChannel.clear(); + this.webSocketEvents.clear(); + } + @Test public void sendMessageToController() throws Exception { @@ -438,7 +448,7 @@ public class StompIntegrationTests { @MessagingGateway @Controller - static interface WebSocketGateway { + interface WebSocketGateway { @MessageMapping("/greeting") @SendToUser("/queue/answer")