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.mbean; 019 020 import jade.jademx.JadeMXSuiteTest; 021 import junit.framework.Test; 022 import junit.framework.TestCase; 023 import junit.framework.TestSuite; 024 025 /** 026 * JademxException MBean test 027 * @author David Bernstein, <a href="http://www.caboodlenetworks.com" 028 * >Caboodle Networks, Inc.</a> 029 */ 030 public class JademxExceptionTest extends TestCase { 031 032 033 ///** test(suite) name */ 034 //private static String name = 035 // JadeMXSuiteTest.nameWithClass( 036 // JadeRuntimeTest.class, 037 // "testing JadeRuntime: JADE runtime MBean class"); 038 039 // tests 040 041 /** 042 * test no-argument <code>JademxException</code> constructor 043 */ 044 public void testJademxExceptionEmpty() { 045 JademxException e = new JademxException(); 046 assertNull( e.getCause() ); 047 assertNull( e.getMessage() ); 048 } 049 050 /** 051 * test <code>JademxException</code> constructor with cause 052 */ 053 public void testJademxExceptionCause() { 054 Throwable t = new Throwable(); 055 JademxException e = new JademxException( t ); 056 assertSame( t, e.getCause() ); 057 assertEquals( t.getClass().getName(), e.getMessage() ); 058 } 059 060 /** 061 * test <code>JademxException</code> constructor with message 062 */ 063 public void testJademxExceptionMessage() { 064 String s = "foo"; 065 JademxException e = new JademxException( s ); 066 assertNull( e.getCause() ); 067 assertSame( s, e.getMessage() ); 068 } 069 070 /** 071 * test <code>JademxException</code> constructor with message 072 */ 073 public void testJademxExceptionMessageCause() { 074 String s = "foo"; 075 Throwable t = new Throwable(); 076 JademxException e = new JademxException( s, t ); 077 assertSame( t, e.getCause() ); 078 assertSame( s, e.getMessage() ); 079 } 080 081 // suite 082 083 /** 084 * return the implicit suite of tests 085 * @return the implicit suite of tests 086 */ 087 public static Test suite() { 088 return new TestSuite( 089 JademxExceptionTest.class, 090 JadeMXSuiteTest.nameWithClass( JadeFactoryTest.class, 091 "testing JademxException: jademx exception") ); 092 } 093 094 095 096 }