From 0e3162408357f61a5bf065f839585ab1b8d18ae5 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 21 Jun 2012 23:54:40 +0300 Subject: [PATCH] INT-1132 Fix Failing Delyer Test INT-1132: Eliminate delayer's tests sensitive * There is no guarantee that a Message will be delayed after restart for exactly the remaining time; it may be delayed longer. * Remove assert around 'receive time' * Remove redundant LIFO test-case: now `DelayHandler` just uses simple iteration over `MessageGroup` JIRA: https://jira.springsource.org/browse/INT-1132 Build report: https://build.springsource.org/browse/INT-B22X-JOB1-91/test/case/110952529 --- .../handler/DelayHandlerTests.java | 3 -- ...ayerHandlerRescheduleIntegrationTests.java | 34 ------------------- 2 files changed, 37 deletions(-) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/DelayHandlerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/DelayHandlerTests.java index a13078ca7e..48c5fda0c8 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/DelayHandlerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/DelayHandlerTests.java @@ -393,10 +393,7 @@ public class DelayHandlerTests { this.delayHandler.setMessageStore(messageGroupStore); this.startDelayerHandler(); - long timeBeforeReceive = System.currentTimeMillis(); assertTrue(this.latch.await(10, TimeUnit.SECONDS)); - long timeAfterReceive = System.currentTimeMillis(); - assertThat(timeAfterReceive - timeBeforeReceive, Matchers.lessThanOrEqualTo(100L)); assertSame(message.getPayload(), this.resultHandler.lastMessage.getPayload()); assertNotSame(Thread.currentThread(), this.resultHandler.lastThread); diff --git a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java index 702d500908..9b23b7313d 100644 --- a/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java +++ b/spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/DelayerHandlerRescheduleIntegrationTests.java @@ -109,11 +109,8 @@ public class DelayerHandlerRescheduleIntegrationTests { PollableChannel output = context.getBean("output", PollableChannel.class); - long timeBeforeReceive = System.currentTimeMillis(); Message message = output.receive(10000); assertNotNull(message); - long timeAfterReceive = System.currentTimeMillis(); - assertThat(timeAfterReceive - timeBeforeReceive, Matchers.lessThanOrEqualTo(100L)); Object payload1 = message.getPayload(); @@ -129,42 +126,11 @@ public class DelayerHandlerRescheduleIntegrationTests { private static class TestJdbcMessageStore extends JdbcMessageStore { - private volatile LobHandler lobHandler = new DefaultLobHandler(); - - private volatile MessageMapper mapper = new MessageMapper(); - - private volatile DeserializingConverter deserializer = new DeserializingConverter(); - private TestJdbcMessageStore() { super(); this.setDataSource(dataSource); } - -// LIFO polling - @Override - protected Message doPollForMessage(String groupIdKey) { - List> messages = this.getJdbcOperations() - .query("SELECT INT_MESSAGE.MESSAGE_ID, INT_MESSAGE.MESSAGE_BYTES from INT_MESSAGE " + - "where INT_MESSAGE.MESSAGE_ID = " + - "(SELECT max(MESSAGE_ID) from INT_MESSAGE where CREATED_DATE = " + - "(SELECT max(CREATED_DATE) from INT_MESSAGE, INT_GROUP_TO_MESSAGE " + - "where INT_MESSAGE.MESSAGE_ID = INT_GROUP_TO_MESSAGE.MESSAGE_ID " + - "and INT_GROUP_TO_MESSAGE.GROUP_KEY = ?))", new Object[]{groupIdKey}, mapper); - if (messages.size() > 0) { - System.out.println(messages.get(0)); - return messages.get(0); - } - return null; - } - - private class MessageMapper implements RowMapper> { - - public Message mapRow(ResultSet rs, int rowNum) throws SQLException { - return (Message) deserializer.convert(lobHandler.getBlobAsBytes(rs, "MESSAGE_BYTES")); - } - } - } }