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 public class SpringMainTest extends TestCase {
32
33 private ConfigurableApplicationContext appContext;
34
35 @Override
36 protected void tearDown() throws Exception {
37 super.tearDown();
38 if (appContext != null) {
39 appContext.close();
40 }
41 }
42
43 public void testContext() {
44 appContext = SpringMain.getApplicationContext();
45 IoService service = (IoService) appContext.getBean("ioAcceptor");
46 IoService ioAcceptorWithSSL = (IoService) appContext.getBean("ioAcceptorWithSSL");
47 assertTrue(service.isActive());
48 assertTrue(ioAcceptorWithSSL.isActive());
49 appContext.close();
50 assertFalse(service.isActive());
51 assertFalse(ioAcceptorWithSSL.isActive());
52 }
53 }