|
63 | 63 | * @deprecated As of release 1.3.0, replaced by {@link com.googlecode.catchexception.apis.BDDCatchException()}
|
64 | 64 | */
|
65 | 65 | @Deprecated
|
66 |
| -public class CatchExceptionBdd { |
67 |
| - |
68 |
| - /** |
69 |
| - * Use it together with {@link #then(Exception)} or |
70 |
| - * {@link #thenThrown(Class)} in order to catch an exception and to get |
71 |
| - * access to the thrown exception (for further verifications). |
72 |
| - * |
73 |
| - * @param <T> |
74 |
| - * The type of the given <code>obj</code>. |
75 |
| - * |
76 |
| - * @param obj |
77 |
| - * The instance that shall be proxied. Must not be |
78 |
| - * <code>null</code>. |
79 |
| - * @return Returns a proxy for the given object. The proxy catches |
80 |
| - * exceptions of the given type when a method on the proxy is |
81 |
| - * called. |
82 |
| - * @see CatchException#catchException(Object) |
83 |
| - */ |
84 |
| - public static <T> T when(T obj) { |
85 |
| - return CatchException.catchException(obj); |
86 |
| - } |
87 |
| - |
88 |
| - /** |
89 |
| - * Throws an assertion if no exception is thrown or if an exception of an |
90 |
| - * unexpected type is thrown. |
91 |
| - * <p> |
92 |
| - * EXAMPLE: |
93 |
| - * <code><pre class="prettyprint lang-java">// given a list with nine members |
94 |
| -List myList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9); |
95 |
| -
|
96 |
| -// when we try to get the 500th member of the fellowship |
97 |
| -when(myList).get(500); |
98 |
| -
|
99 |
| -// then we expect an IndexOutOfBoundsException |
100 |
| -thenThrown(IndexOutOfBoundsException.class); |
101 |
| -</pre></code> |
102 |
| - * |
103 |
| - * @param actualExceptionClazz |
104 |
| - * the expected type of the caught exception. |
105 |
| - */ |
106 |
| - @SuppressWarnings({ "unchecked", "rawtypes" }) |
107 |
| - public static void thenThrown(Class actualExceptionClazz) { |
108 |
| - Exception e = CatchException.caughtException(); |
109 |
| - if (e == null) { |
110 |
| - // no exception caught -> assertion failed |
111 |
| - throw new ExceptionNotThrownAssertionError(actualExceptionClazz); |
112 |
| - } else if (!actualExceptionClazz.isAssignableFrom(CatchException |
113 |
| - .caughtException().getClass())) { |
114 |
| - // caught exception is of wrong type -> assertion failed |
115 |
| - throw new ExceptionNotThrownAssertionError(actualExceptionClazz, e); |
116 |
| - } else { |
117 |
| - // the caught exception is of the expected type -> nothing to do :-) |
118 |
| - } |
119 |
| - } |
| 66 | +public class CatchExceptionBdd extends BDDCatchException { |
120 | 67 |
|
121 | 68 | /**
|
122 | 69 | * Enables <a href="https://github.com/alexruiz/fest-assert-2.x">FEST Fluent
|
|
0 commit comments