|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| CascadingErrorTestCase.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
/* ====================================================================
|
|
| 2 |
The Jicarilla Software License
|
|
| 3 |
|
|
| 4 |
Copyright (c) 2003 Leo Simons.
|
|
| 5 |
All rights reserved.
|
|
| 6 |
|
|
| 7 |
Permission is hereby granted, free of charge, to any person obtaining
|
|
| 8 |
a copy of this software and associated documentation files (the
|
|
| 9 |
"Software"), to deal in the Software without restriction, including
|
|
| 10 |
without limitation the rights to use, copy, modify, merge, publish,
|
|
| 11 |
distribute, sublicense, and/or sell copies of the Software, and to
|
|
| 12 |
permit persons to whom the Software is furnished to do so, subject to
|
|
| 13 |
the following conditions:
|
|
| 14 |
|
|
| 15 |
The above copyright notice and this permission notice shall be
|
|
| 16 |
included in all copies or substantial portions of the Software.
|
|
| 17 |
|
|
| 18 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
| 19 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
| 20 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
| 21 |
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
| 22 |
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
| 23 |
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
| 24 |
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
| 25 |
==================================================================== */
|
|
| 26 |
package org.jicarilla.framework.test;
|
|
| 27 |
|
|
| 28 |
import org.jicarilla.framework.CascadingError;
|
|
| 29 |
import org.jicarilla.framework.CascadingThrowable;
|
|
| 30 |
import junit.framework.TestCase;
|
|
| 31 |
|
|
| 32 |
/**
|
|
| 33 |
* <a href="http://www.junit.org/">JUnit</a> {@link junit.framework.TestCase
|
|
| 34 |
* testcase} for CascadingError.
|
|
| 35 |
*
|
|
| 36 |
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
|
|
| 37 |
* @version $Id: CascadingErrorTestCase.java,v 1.1 2003/11/10 22:51:01 lsimons
|
|
| 38 |
* Exp $
|
|
| 39 |
*/
|
|
| 40 |
public class CascadingErrorTestCase extends TestCase |
|
| 41 |
{
|
|
| 42 | 1 |
public void testConstructor() |
| 43 |
{
|
|
| 44 | 1 |
assertNotNull( new CascadingError( null, null ) ); |
| 45 | 1 |
assertNotNull( new CascadingError( "msg", null ) ); |
| 46 | 1 |
assertNotNull( new CascadingError( "msg", new RuntimeException() ) ); |
| 47 | 1 |
assertNotNull( new CascadingError( null, new RuntimeException() ) ); |
| 48 |
|
|
| 49 | 1 |
assertNotNull( new CascadingError( "msg" ) ); |
| 50 |
//ambiguous assertNotNull( new CascadingError( null ) );
|
|
| 51 | 1 |
assertNotNull( new CascadingError() );
|
| 52 |
} |
|
| 53 |
|
|
| 54 | 1 |
public void testGetCause() |
| 55 |
{
|
|
| 56 | 1 |
RuntimeException re = new RuntimeException();
|
| 57 | 1 |
CascadingError e = new CascadingError( "msg", re ); |
| 58 |
|
|
| 59 | 1 |
assertEquals( re, e.getCause() ); |
| 60 |
|
|
| 61 | 1 |
e = new CascadingError( "msg", null ); |
| 62 | 1 |
assertNull( e.getCause() ); |
| 63 |
|
|
| 64 |
// default to jdk 1.3 cause (not that it seems to help,
|
|
| 65 |
// but it still makes sense)
|
|
| 66 | 1 |
Exception exc = new Exception("blah"); |
| 67 | 1 |
try
|
| 68 |
{
|
|
| 69 | 1 |
try
|
| 70 |
{
|
|
| 71 | 1 |
throw exc;
|
| 72 |
} |
|
| 73 |
catch( Exception ex )
|
|
| 74 |
{
|
|
| 75 | 1 |
throw new CascadingError(); |
| 76 |
} |
|
| 77 |
} |
|
| 78 |
catch( CascadingError ex )
|
|
| 79 |
{
|
|
| 80 | 1 |
ex.getCause(); |
| 81 |
} |
|
| 82 |
} |
|
| 83 |
|
|
| 84 | 1 |
public void testCasts() |
| 85 |
{
|
|
| 86 | 1 |
CascadingError e = new CascadingError( "msg", null ); |
| 87 | 1 |
assertTrue( e instanceof Error );
|
| 88 | 1 |
assertTrue( e instanceof CascadingThrowable );
|
| 89 |
} |
|
| 90 |
} |
|
| 91 |
|
|
||||||||||