//
// This file is part of the OpenNMS(R) Application.
//
// OpenNMS(R) is Copyright (C) 2006 The OpenNMS Group, Inc.  All rights reserved.
// OpenNMS(R) is a derivative work, containing both original code, included code and modified
// code that was published under the GNU General Public License. Copyrights for modified 
// and included code are below.
//
// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
//
// Modifications:
//
// 2008 Feb 10: Created a separate test case for JMX tests using default configs. - dj@opennms.org
// 2007 Aug 25: Use AbstractTransactionalTemporaryDatabaseSpringContextTests
//              and new Spring context files. - dj@opennms.org
// 2007 Jun 24: Organize imports. - dj@opennms.org
//
// Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// For more information contact:
// OpenNMS Licensing       <license@opennms.org>
//     http://www.opennms.org/
//     http://www.opennms.com/
//
package org.opennms.netmgt.importer;

import org.opennms.netmgt.dao.db.AbstractTransactionalTemporaryDatabaseSpringContextTests;
import org.opennms.netmgt.importer.jmx.ImporterService;
import org.opennms.netmgt.importer.jmx.ImporterServiceMBean;
import org.opennms.test.DaoTestConfigBean;
import org.opennms.test.mock.MockLogAppender;

public class ImporterServiceJmxTest extends AbstractTransactionalTemporaryDatabaseSpringContextTests {
    public ImporterServiceJmxTest() {
        DaoTestConfigBean bean = new DaoTestConfigBean();
        bean.afterPropertiesSet();
    }

    @Override
    protected void onSetUpInTransactionIfEnabled() throws Exception {
        super.onSetUpInTransactionIfEnabled();
        
        MockLogAppender.setupLogging();
    }

    public void testStartStop() throws Exception {
        ImporterServiceMBean mbean = new ImporterService();
        mbean.init();
        mbean.start();
        
        Thread.sleep(3000);
        
        mbean.stop();
    }
}

@@ -1737,86 +1737,136 @@
 org.
-opennms.netmgt.dao.db.AbstractTransactionalTemporaryDatabaseSpringContextTests
+junit.Before;%0Aimport org.junit.Test;%0Aimport org.opennms.core.utils.BeanUtils;%0Aimport org.opennms.netmgt.config.DataSourceFactory
 ;%0Aim
@@ -1976,24 +1976,69 @@
 rviceMBean;%0A
+import org.opennms.netmgt.mock.MockDatabase;%0A
 import org.o
@@ -2118,436 +2118,895 @@
 er;%0A
-%0Apublic class ImporterServiceJmxTest extends AbstractTransactionalTemporaryDatabaseSpringContextTests %7B%0A    public ImporterServiceJmxTest() %7B%0A        DaoTestConfigBean bean = new DaoTestConfigBean();%0A        bean.afterPropertiesSet();%0A    %7D%0A%0A    @Override%0A    protected void onSetUpInTransactionIfEnabled() throws Exception %7B%0A        super.onSetUpInTransactionIfEnabled();%0A        %0A        MockLogAppender.setupLogging();%0A    %7D%0A
+import org.springframework.beans.factory.access.BeanFactoryReference;%0Aimport org.springframework.context.ApplicationContext;%0Aimport org.springframework.context.support.ClassPathXmlApplicationContext;%0A%0A%0Apublic class ImporterServiceJmxTest %7B%0A    %0A    @Before%0A    public void setUp() throws Exception %7B%0A        %0A        MockDatabase db = new MockDatabase();%0A        DataSourceFactory.setInstance(db);%0A%0A        MockLogAppender.setupLogging();%0A        DaoTestConfigBean bean = new DaoTestConfigBean();%0A        bean.afterPropertiesSet();%0A        %0A        %0A        BeanFactoryReference ref = BeanUtils.getBeanFactory(%22daemonContext%22);%0A        ApplicationContext daemonContext = (ApplicationContext) ref.getFactory();%0A        %0A        new ClassPathXmlApplicationContext(new String%5B%5D %7B %22classpath:META-INF/opennms/mockEventIpcManager.xml%22 %7D, daemonContext);%0A        %0A        %0A    %7D%0A    %0A    @Test
 %0A   
@@ -3033,32 +3033,43 @@
 rtStop() throws 
+Interrupted
 Exception %7B%0A    

fix test for ImporterService