From 3244e0a644f37820546d17780e586d0505efe2de Mon Sep 17 00:00:00 2001 From: Micha Kiener Date: Tue, 12 Apr 2011 18:11:18 +0000 Subject: [PATCH] SPR-6416, adding repository timeout setting tests --- .../ConversationRepositoryTest.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/org.springframework.context/src/test/java/org/springframework/conversation/ConversationRepositoryTest.java b/org.springframework.context/src/test/java/org/springframework/conversation/ConversationRepositoryTest.java index 1087ddf961..c47b15e842 100644 --- a/org.springframework.context/src/test/java/org/springframework/conversation/ConversationRepositoryTest.java +++ b/org.springframework.context/src/test/java/org/springframework/conversation/ConversationRepositoryTest.java @@ -176,6 +176,61 @@ public class ConversationRepositoryTest { repository.getConversation(rootConversationId)); } + @Test + public void testRepositoryDefaultTimeout() { + LocalTransientConversationRepository repository = new LocalTransientConversationRepository(); + repository.setDefaultConversationTimeout(100); + + MutableConversation conversation = repository.createNewConversation(); + assertEquals("default timeout of repository has to be set on newly created conversations", 100, + conversation.getTimeout()); + + MutableConversation conversation2 = repository.createNewConversation(); + conversation2.setTimeout(50); + assertEquals("setting a timeout on a conversation must not change the default one", 100, + conversation.getTimeout()); + } + + @Test + public void testRepositoryTimeoutInheritance() { + LocalTransientConversationRepository repository = new LocalTransientConversationRepository(); + repository.setDefaultConversationTimeout(100); + + MutableConversation conversation = repository.createNewConversation(); + conversation.setTimeout(50); + MutableConversation childConversation = repository.createNewChildConversation(conversation, false); + + assertEquals("timeout of a child conversation must be inherited from its parent", 50, + childConversation.getTimeout()); + } + + @Test + public void testRepositoryCustomTimeoutChildParentPropagation() { + LocalTransientConversationRepository repository = new LocalTransientConversationRepository(); + repository.setDefaultConversationTimeout(100); + + MutableConversation conversation = repository.createNewConversation(); + conversation.setTimeout(50); + MutableConversation childConversation = repository.createNewChildConversation(conversation, false); + childConversation.setTimeout(70); + + assertEquals("the custom timeout being set on a child conversation must be propagated to its parent", 70, + conversation.getTimeout()); + } + + @Test + public void testRepositoryCustomTimeoutParentChildPropagation() { + LocalTransientConversationRepository repository = new LocalTransientConversationRepository(); + repository.setDefaultConversationTimeout(100); + + MutableConversation conversation = repository.createNewConversation(); + MutableConversation childConversation = repository.createNewChildConversation(conversation, false); + conversation.setTimeout(50); + + assertEquals("the custom timeout being set on a parent conversation must be propagated to its children", 50, + childConversation.getTimeout()); + } + protected ConversationRepository createRepository() { return new LocalTransientConversationRepository(); }