Sho SHIMIZU | 15ed4fd | 2014-08-05 14:40:42 -0700 | [diff] [blame] | 1 | package net.onrc.onos.api.newintent; |
| 2 | |
| 3 | import org.junit.Test; |
| 4 | |
| 5 | import static org.junit.Assert.assertEquals; |
| 6 | |
| 7 | /** |
| 8 | * Test of the intent exception. |
| 9 | */ |
| 10 | public class IntentExceptionTest { |
| 11 | |
| 12 | @Test |
| 13 | public void basics() { |
| 14 | validate(new IntentException(), null, null); |
| 15 | validate(new IntentException("foo"), "foo", null); |
| 16 | |
| 17 | Throwable cause = new NullPointerException("bar"); |
| 18 | validate(new IntentException("foo", cause), "foo", cause); |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Validates that the specified exception has the correct message and cause. |
| 23 | * |
| 24 | * @param e exception to test |
| 25 | * @param message expected message |
| 26 | * @param cause expected cause |
| 27 | */ |
| 28 | protected void validate(RuntimeException e, String message, Throwable cause) { |
| 29 | assertEquals("incorrect message", message, e.getMessage()); |
| 30 | assertEquals("incorrect cause", cause, e.getCause()); |
| 31 | } |
| 32 | |
| 33 | } |