📄 testconfigurationcomponent.java
字号:
/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "Exolab" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of Exoffice Technologies. For written permission,
* please contact info@exolab.org.
*
* 4. Products derived from this Software may not be called "Exolab"
* nor may "Exolab" appear in their names without prior written
* permission of Exoffice Technologies. Exolab is a registered
* trademark of Exoffice Technologies.
*
* 5. Due credit should be given to the Exolab Project
* (http://www.exolab.org/).
*
* THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
*
* $Id: TestConfigurationComponent.java,v 1.7 2004/01/29 12:07:18 tanderson Exp $
*
* Date Author Changes
* 2/27/1999 jima Created
* 8/02/2001 jima Changed its name from ConfigCT and redeveloped
* it for junit
*/
package org.exolab.testharness.jms.config;
// junit library
import junit.framework.TestCase;
// jms library
import org.exolab.jms.config.ConfigurationManager;
import org.exolab.jms.config.Configuration;
import org.exolab.jms.config.ConnectionFactories;
import org.exolab.jms.config.ConnectionFactory;
import org.exolab.jms.config.Connector;
import org.exolab.jms.config.Connectors;
import org.exolab.jms.config.DatabaseConfiguration;
import org.exolab.jms.config.FileDoesNotExistException;
import org.exolab.jms.config.ConfigurationFileException;
import org.exolab.jms.config.QueueConnectionFactory;
import org.exolab.jms.config.TopicConnectionFactory;
import org.exolab.jms.config.XAQueueConnectionFactory;
import org.exolab.jms.config.XATopicConnectionFactory;
/**
* This file includes the test cases for the OpenJMS configuration component
* It incl,udes test cases which reads in a valid and invalid xml file and
* also access attributes of the configuration file
* <p>
* TC01 Read in a valid configuration file
* TC02 Read in a non-existent configuration file
* TC03 Read in an invalid configuration file
* TC04 Access all configuration elements
*
* @version $Revision: 1.7 $ $Date: 2004/01/29 12:07:18 $
* @author <a href="mailto:jima@exoffice.com">Jim Alateras</a>
* @see org.exolab.jtf.CWTestCateogry
* @see org.exolab.jtf.CWTestCase
*/
public class TestConfigurationComponent extends TestCase {
/**
* Save the configuration information so that it can be restored
*/
private String _path = null;
/**
* Constructor
*/
public TestConfigurationComponent(String name) {
super(name);
}
protected void setUp() {
}
protected void tearDown() {
}
/**
* Test that the configuration is correctly populated
*/
public void testConfigurationItems() {
try {
Configuration config = ConfigurationManager.getConfig();
assertTrue(config.getServerConfiguration().getHost() != null);
assertTrue(config.getLoggerConfiguration().getFile() != null);
assertTrue(config.getJndiConfiguration() != null);
assertTrue(config.getConnectors() != null);
Connector[] connectors = config.getConnectors().getConnector();
assertTrue(connectors.length > 0);
for (int index = 0; index < connectors.length; ++index) {
Connector connector = connectors[index];
assertTrue(connector.getScheme() != null);
ConnectionFactories factories =
connector.getConnectionFactories();
assertTrue(factories != null);
QueueConnectionFactory[] queues =
factories.getQueueConnectionFactory();
assertTrue(queues != null);
TopicConnectionFactory[] topics =
factories.getTopicConnectionFactory();
assertTrue(topics != null);
XAQueueConnectionFactory[] xaqueues =
factories.getXAQueueConnectionFactory();
assertTrue(xaqueues != null);
XATopicConnectionFactory[] xatopics =
factories.getXATopicConnectionFactory();
assertTrue(xatopics != null);
for (int i = 0; i < queues.length; ++i) {
assertTrue(queues[i].getName() != null);
}
for (int i = 0; i < topics.length; ++i) {
assertTrue(topics[i].getName() != null);
}
for (int i = 0; i < xaqueues.length; ++i) {
assertTrue(xaqueues[i].getName() != null);
}
for (int i = 0; i < xatopics.length; ++i) {
assertTrue(xatopics[i].getName() != null);
}
}
assertTrue(config.getMessageManagerConfiguration() != null);
DatabaseConfiguration dbconfig = config.getDatabaseConfiguration();
assertTrue(dbconfig != null);
assertTrue(dbconfig.getRdbmsDatabaseConfiguration() != null ||
dbconfig.getJdbmDatabaseConfiguration() != null);
} catch (Exception exception) {
fail("testConfigurationItems " + exception.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -