17
17
18
18
import static org .junit .Assert .*;
19
19
20
- import org .junit .Before ;
20
+ import org .junit .BeforeClass ;
21
21
import org .junit .Test ;
22
22
import org .springframework .context .ConfigurableApplicationContext ;
23
23
import org .springframework .context .support .GenericXmlApplicationContext ;
32
32
* @since 3.1
33
33
*/
34
34
public class BasicConversationTests {
35
- private ConfigurableApplicationContext ctx ;
36
- private ConversationManager manager ;
37
- private ConversationStore store ;
38
- private ConversationResolver resolver ;
35
+ private static ConfigurableApplicationContext context ;
36
+ private static ConversationManager manager ;
37
+ private static ConversationStore store ;
38
+ private static ConversationResolver resolver ;
39
39
40
- @ Before
41
- public void setUp () {
42
- ctx = loadContext (getContextLocation ());
43
- manager = ctx .getBean (ConversationManager .class );
44
- store = ctx .getBean (ConversationStore .class );
45
- resolver = ctx .getBean (ConversationResolver .class );
40
+ @ BeforeClass
41
+ public static void setUp () {
42
+ context = loadContext (getContextLocation ());
43
+ manager = context .getBean (ConversationManager .class );
44
+ store = context .getBean (ConversationStore .class );
45
+ resolver = context .getBean (ConversationResolver .class );
46
46
}
47
47
48
48
@ Test
49
49
public void testContext () {
50
- ConfigurableApplicationContext context = getContext ();
51
50
assertNotNull (context );
52
51
assertNotNull (manager );
53
52
}
54
53
55
54
@ Test
56
55
public void testTemporaryConversation () {
57
- ConversationalBean bean = (ConversationalBean ) getContext () .getBean ("testBean" );
56
+ ConversationalBean bean = (ConversationalBean ) context .getBean ("testBean" );
58
57
assertNotNull (bean );
59
58
assertNull (bean .getName ());
60
59
String id = resolver .getCurrentConversationId ();
@@ -71,16 +70,11 @@ public void testTemporaryConversation() {
71
70
assertNull (resolver .getCurrentConversationId ());
72
71
}
73
72
74
- protected String getContextLocation () {
73
+ protected static String getContextLocation () {
75
74
return "org/springframework/conversation/conversationTestContext.xml" ;
76
75
}
77
76
78
- protected ConfigurableApplicationContext loadContext (String configLocation ) {
79
- GenericXmlApplicationContext ctx = new GenericXmlApplicationContext (getContextLocation ());
80
- return ctx ;
81
- }
82
-
83
- protected ConfigurableApplicationContext getContext () {
84
- return ctx ;
77
+ protected static ConfigurableApplicationContext loadContext (String configLocation ) {
78
+ return new GenericXmlApplicationContext (getContextLocation ());
85
79
}
86
80
}
0 commit comments