blob: 02564e693eaacd5d1bde94d64c3a750ed2f4da61 [file] [log] [blame]
Brian O'Connorf3d06162014-10-02 15:54:12 -07001package org.onlab.onos.net.intent;
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}