1 /**
2 *
3 * Copyright 2003-2004 The Apache Software Foundation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 //
19 // This source code implements specifications defined by the Java
20 // Community Process. In order to remain compliant with the specification
21 // DO NOT add / change / or delete method signatures!
22 //
23
24 package javax.jms;
25
26 import junit.framework.TestCase;
27
28
29 /**
30 * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
31 */
32 public class JMSExceptionTest extends TestCase {
33 public void testConstructorNull() {
34 JMSException ex = new JMSException(null);
35 assertNull(ex.getMessage());
36 assertNull(ex.getErrorCode());
37 assertNull(ex.getLinkedException());
38 }
39
40 public void testConstructorNullNull() {
41 JMSException ex = new JMSException(null, null);
42 assertNull(ex.getMessage());
43 assertNull(ex.getErrorCode());
44 assertNull(ex.getLinkedException());
45 }
46
47 public void testConstructorNullString() {
48 String expected = "some code";
49 JMSException ex = new JMSException(null, expected);
50 assertNull(ex.getMessage());
51 assertEquals(expected, ex.getErrorCode());
52 assertNull(ex.getLinkedException());
53 }
54
55 public void testConstructorString() {
56 String expected = "some message";
57 JMSException ex = new JMSException(expected);
58 assertEquals(expected, ex.getMessage());
59 assertNull(ex.getErrorCode());
60 assertNull(ex.getLinkedException());
61 }
62
63 public void testConstructorStringNull() {
64 String expected = "some message";
65 JMSException ex = new JMSException(expected, null);
66 assertEquals(expected, ex.getMessage());
67 assertNull(ex.getErrorCode());
68 assertNull(ex.getLinkedException());
69 }
70
71 public void testConstructorStringString() {
72 String expectedMessage = "some message";
73 String expectedCode = "some code";
74 JMSException ex = new JMSException(expectedMessage, expectedCode);
75 assertEquals(expectedMessage, ex.getMessage());
76 assertEquals(expectedCode, ex.getErrorCode());
77 assertNull(ex.getLinkedException());
78 }
79
80 public void testSetLinkedException() {
81 Exception expected = new Exception();
82 JMSException ex = new JMSException(null);
83 ex.setLinkedException(expected);
84 assertEquals(expected, ex.getLinkedException());
85 }
86 }