blob: ed11e3903b85f79342615b5ac42352206ea144a0 [file] [log] [blame]
Sean Condon0e89bda2017-03-21 14:23:19 +00001/*
2 * Copyright 2017-present Open Networking Foundation
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 */
16package org.onosproject.incubator.net.l2monitoring.cfm.identifier;
17
18import static org.junit.Assert.assertTrue;
19import static org.junit.Assert.fail;
20
21import org.junit.Test;
22
23public class MepIdTest {
24 @Test
25 public void testLowRange() {
26 try {
27 MepId.valueOf((short) -1);
28 fail("Exception expected for MepId = -1");
29 } catch (IllegalArgumentException e) {
30 assertTrue(e.getMessage().contains("Invalid value for Mep Id"));
31 }
32
33 try {
34 MepId.valueOf((short) 0);
35 fail("Exception expected for MepId = 0");
36 } catch (IllegalArgumentException e) {
37 assertTrue(e.getMessage().contains("Invalid value for Mep Id"));
38 }
39 }
40
41 @Test
42 public void testHighRange() {
43 try {
44 MepId.valueOf((short) 8192);
45 fail("Exception expected for MepId = 8192");
46 } catch (IllegalArgumentException e) {
47 assertTrue(e.getMessage().contains("Invalid value for Mep Id"));
48 }
49
50 try {
51 MepId.valueOf((short) 33333); //Above the range of short
52 fail("Exception expected for MepId = 33333");
53 } catch (IllegalArgumentException e) {
54 assertTrue(e.getMessage().contains("Invalid value for Mep Id"));
55 }
56 }
57
58}