1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.mina.example.chat;
21
22 import junit.framework.TestCase;
23 import org.springframework.context.ConfigurableApplicationContext;
24 import org.apache.mina.core.service.IoService;
25
26
27
28
29
30
31
32 public class SpringMainTest extends TestCase {
33
34 private ConfigurableApplicationContext appContext;
35
36 @Override
37 protected void tearDown() throws Exception {
38 super.tearDown();
39 if (appContext != null) {
40 appContext.close();
41 }
42 }
43
44 public void testContext() {
45 appContext = SpringMain.getApplicationContext();
46 IoService service = (IoService) appContext.getBean("ioAcceptor");
47 IoService ioAcceptorWithSSL = (IoService) appContext.getBean("ioAcceptorWithSSL");
48 assertTrue(service.isActive());
49 assertTrue(ioAcceptorWithSSL.isActive());
50 appContext.close();
51 assertFalse(service.isActive());
52 assertFalse(ioAcceptorWithSSL.isActive());
53 }
54 }