01: package org.apache.mina.example.chat;
02:
03: import junit.framework.TestCase;
04: import org.springframework.context.ConfigurableApplicationContext;
05: import org.apache.mina.common.IoService;
06:
07: /**
08: */
09: public class SpringMainTest extends TestCase {
10:
11: private ConfigurableApplicationContext appContext;
12:
13: @Override
14: protected void tearDown() throws Exception {
15: super .tearDown();
16: if (appContext != null) {
17: appContext.close();
18: }
19: }
20:
21: public void testContext() {
22: appContext = SpringMain.getApplicationContext();
23: IoService service = (IoService) appContext
24: .getBean("ioAcceptor");
25: IoService ioAcceptorWithSSL = (IoService) appContext
26: .getBean("ioAcceptorWithSSL");
27: assertTrue(service.isActive());
28: assertTrue(ioAcceptorWithSSL.isActive());
29: appContext.close();
30: assertFalse(service.isActive());
31: assertFalse(ioAcceptorWithSSL.isActive());
32: }
33: }
|