blob: 45d6d941b32a9f4fd2d64aeea844c911a092fd28 [file] [log] [blame]
Phaneendra Mandaab5a7362015-12-02 01:10:01 +05301/*
2 * Copyright 2015 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 */
16package org.onosproject.driver.extensions;
17
18import static org.hamcrest.MatcherAssert.assertThat;
19import static org.hamcrest.Matchers.is;
20import static org.hamcrest.Matchers.notNullValue;
21
22import org.junit.Test;
23import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
24
25import com.google.common.testing.EqualsTester;
26
27/**
28 * Unit tests for NiciraSetNshContextHeader class.
29 */
30public class NiciraSetNshContextHeaderTest {
31
32 final NiciraSetNshContextHeader nshCh1 = new NiciraSetNshContextHeader(10,
33 ExtensionTreatmentType.
34 ExtensionTreatmentTypes.
35 NICIRA_SET_NSH_CH1.type());
36 final NiciraSetNshContextHeader sameAsNshCh1 = new NiciraSetNshContextHeader(10,
37 ExtensionTreatmentType.
38 ExtensionTreatmentTypes.
39 NICIRA_SET_NSH_CH1.type());
40 final NiciraSetNshContextHeader nshCh2 = new NiciraSetNshContextHeader(20,
41 ExtensionTreatmentType.
42 ExtensionTreatmentTypes.
43 NICIRA_SET_NSH_CH1.type());
44
45 /**
46 * Checks the operation of equals() methods.
47 */
48 @Test
49 public void testEquals() {
50 new EqualsTester().addEqualityGroup(nshCh1, sameAsNshCh1).addEqualityGroup(nshCh2).testEquals();
51 }
52
53 /**
54 * Checks the construction of a NiciraSetNshSi object.
55 */
56 @Test
57 public void testConstruction() {
58 final NiciraSetNshContextHeader niciraSetNshCh = new NiciraSetNshContextHeader(10,
59 ExtensionTreatmentType.
60 ExtensionTreatmentTypes.
61 NICIRA_SET_NSH_CH1.type());
62 assertThat(niciraSetNshCh, is(notNullValue()));
63 assertThat(niciraSetNshCh.nshCh(), is(10));
64 assertThat(niciraSetNshCh.type(), is(ExtensionTreatmentType.
65 ExtensionTreatmentTypes.
66 NICIRA_SET_NSH_CH1.type()));
67 }
68}