001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.mina.example.chat; 021 022import static org.junit.Assert.assertFalse; 023import static org.junit.Assert.assertTrue; 024 025import org.apache.mina.core.service.IoService; 026import org.junit.Before; 027import org.junit.Test; 028import org.springframework.context.ConfigurableApplicationContext; 029 030/** 031 * TODO Add documentation 032 * 033 * @author <a href="http://mina.apache.org">Apache MINA Project</a> 034 */ 035public class SpringMainTest { 036 037 private ConfigurableApplicationContext appContext; 038 039 @Before 040 public void tearDown() throws Exception { 041 if (appContext != null) { 042 appContext.close(); 043 } 044 } 045 046 @Test 047 public void testContext() { 048 appContext = SpringMain.getApplicationContext(); 049 IoService service = (IoService) appContext.getBean("ioAcceptor"); 050 IoService ioAcceptorWithSSL = (IoService) appContext.getBean("ioAcceptorWithSSL"); 051 assertTrue(service.isActive()); 052 assertTrue(ioAcceptorWithSSL.isActive()); 053 appContext.close(); 054 assertFalse(service.isActive()); 055 assertFalse(ioAcceptorWithSSL.isActive()); 056 } 057}