blob: 72add7fae806739680ad2c7e93b2a1d8065cef86 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian O'Connorf3d06162014-10-02 15:54:12 -070016package org.onlab.onos.net.intent;
17
18import org.junit.Test;
19
20import static org.junit.Assert.assertEquals;
21
22/**
23 * Test of the intent exception.
24 */
25public class IntentExceptionTest {
26
27 @Test
28 public void basics() {
29 validate(new IntentException(), null, null);
30 validate(new IntentException("foo"), "foo", null);
31
32 Throwable cause = new NullPointerException("bar");
33 validate(new IntentException("foo", cause), "foo", cause);
34 }
35
36 /**
37 * Validates that the specified exception has the correct message and cause.
38 *
39 * @param e exception to test
40 * @param message expected message
41 * @param cause expected cause
42 */
43 protected void validate(RuntimeException e, String message, Throwable cause) {
44 assertEquals("incorrect message", message, e.getMessage());
45 assertEquals("incorrect cause", cause, e.getCause());
46 }
47
48}