blob: 574449ba29a6120eba744d6c175129a99a2a08fc [file] [log] [blame]
Sho SHIMIZU15ed4fd2014-08-05 14:40:42 -07001package net.onrc.onos.api.newintent;
2
3import org.junit.Test;
4
5import static org.junit.Assert.assertEquals;
6
7/**
8 * Test of the intent exception.
9 */
10public 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}