1
2
3
4
5
6
7 package org.abraracourcix.alipes.pipes;
8
9 import junit.framework.TestCase;
10
11 /***
12 * JUnit Test
13 *
14 * @author jdt
15 */
16 public final class MultiplexorExceptionTest extends TestCase {
17 /***
18 * class under test
19 */
20 private MultiplexorException multiplexorException;
21 /***
22 * Multiplexed text expected
23 */
24 private String expected;
25
26 /***
27 * Fire up the UI
28 * @param args ignored
29 */
30 public static void main(final String[] args) {
31 junit.textui.TestRunner.run(MultiplexorExceptionTest.class);
32 }
33
34 /***
35 * Setup
36 *
37 */
38 public void setUp() {
39 final Exception ex1 = new Exception("Exception1");
40 final Throwable t2 = new Throwable("Throwable2");
41 final Exception ex3 = new Exception("Exception3", ex1);
42
43 multiplexorException = new MultiplexorException("Multiplexed exception", ex1);
44 multiplexorException.addCause(t2);
45 multiplexorException.addCause(ex3);
46
47 expected="Multiplexed exception:\nException1\nThrowable2\nException3";
48 }
49
50 /***
51 * Class to test for void MultiplexorException(Throwable)
52 */
53 public void testMultiplexorExceptionThrowable() {
54 new MultiplexorException(new Exception("foo"));
55 }
56 /***
57 * Class to test for void MultiplexorException(String, Throwable)
58 */
59 public void testMultiplexorExceptionStringThrowable() {
60 new MultiplexorException("description",new Exception("foo"));
61 }
62 /***
63 * Class to test for String getMessage()
64 */
65 public void testGetMessage() {
66 final String message = multiplexorException.getMessage();
67 assertTrue(message.indexOf(expected)!=-1);
68 }
69
70 /***
71 * Class to test for String toString()
72 */
73 public void testToString() {
74 assertTrue(multiplexorException.toString().indexOf(expected)!=-1);
75 }
76 }
77
78
79
80
81
82
83
84
85
86
87