KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jtests > jms > framework > JMSTestCase


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2002 INRIA
4  * Contact: joram-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer(s): Jeff Mesnil (jmesnil@inrialpes.fr)
22  * Contributor(s): ______________________________________.
23  */

24
25 package org.objectweb.jtests.jms.framework;
26
27 import junit.framework.*;
28 import javax.jms.JMSException JavaDoc;
29
30 /**
31  * Class extending <code>junit.framework.TestCase</code> to
32  * provide a new <code>fail()</code> method with an <code>Exception</code>
33  * as parameter.
34  *<br />
35  * Every Test Case for JMS should extend this class instead of <code>junit.framework.TestCase</code>
36  *
37  * @author Jeff Mesnil (jmesnil@inrialpes.fr)
38  * @version $Id: JMSTestCase.java,v 1.1 2002/04/21 21:15:19 chirino Exp $
39  */

40 public class JMSTestCase extends TestCase {
41     
42     /**
43      * Fails a test with an exception which will be used for a message.
44      *
45      * If the exception is an instance of <code>javax.jms.JMSException</code>, the
46      * message of the failure will contained both the JMSException and its linked exception
47      * (provided there's one).
48      */

49     public void fail (Exception JavaDoc e) {
50     if (e instanceof javax.jms.JMSException JavaDoc) {
51         JMSException JavaDoc exception = (JMSException JavaDoc) e;
52         String JavaDoc message = e.toString();
53         Exception JavaDoc linkedException = exception.getLinkedException();
54         if (linkedException != null) {
55         message += " [linked exception: "+ linkedException +"]";
56         }
57         super.fail(message);
58     } else {
59         super.fail(e.getMessage());
60     }
61     }
62     
63     public JMSTestCase(String JavaDoc name) {
64     super(name);
65     }
66 }
67
68     
69
Popular Tags