001 // jademx - JADE management using JMX
002 // Copyright 2005 Caboodle Networks, Inc.
003 //
004 // This library is free software; you can redistribute it and/or
005 // modify it under the terms of the GNU Lesser General Public
006 // License as published by the Free Software Foundation; either
007 // version 2.1 of the License, or (at your option) any later version.
008 //
009 // This library is distributed in the hope that it will be useful,
010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 // Lesser General Public License for more details.
013 //
014 // You should have received a copy of the GNU Lesser General Public
015 // License along with this library; if not, write to the Free Software
016 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
017
018 package jade.jademx.server;
019
020 import jade.jademx.JadeMXSuiteTest;
021 import jade.jademx.util.ThrowableUtil;
022 import junit.framework.Test;
023 import junit.framework.TestCase;
024 import junit.framework.TestSuite;
025
026 /**
027 * JadeMXServerFactory test
028 * @author David Bernstein, <a href="http://www.caboodlenetworks.com"
029 * >Caboodle Networks, Inc.</a>
030 */
031 public class JadeMXServerFactoryTest extends TestCase {
032
033 // tests
034
035 /**
036 * Test instantiating JadeMXServer by system property.
037 * This will use the existing system property, or if none,
038 * the default value.
039 */
040 public void testJadeMXServerBySysProp() {
041 String className =
042 System.getProperty(
043 JadeMXServerFactory.SERVER_TYPE_PROPERTY,
044 JadeMXServerFactory.SERVER_TYPE_DEFAULT );
045 JadeMXServer jadeMXServer = null;
046 try {
047 jadeMXServer = JadeMXServerFactory.jadeMXServerBySysProp();
048 }
049 catch ( Exception e ) {
050 fail( ThrowableUtil.errMsg(
051 "problem creating JadeMXServer by system property", e) );
052 }
053 assertTrue( jadeMXServer + " not instanceof JadeMXServer",
054 jadeMXServer instanceof JadeMXServer );
055
056 assertEquals( "returned JadeMXServer class "+
057 jadeMXServer.getClass().getName()+
058 " not one specified by system property: "+
059 className,
060 className, jadeMXServer.getClass().getName() );
061 }
062
063
064 // suite
065
066 /**
067 * return the implicit suite of tests
068 * @return the implicit suite of tests
069 */
070 public static Test suite() {
071 return new TestSuite(
072 JadeMXServerFactoryTest.class,
073 JadeMXSuiteTest.nameWithClass( JadeMXServerFactoryTest.class,
074 "testing JadeMXServerFactory: JadeMXServer factory class") );
075 }
076
077
078
079 }