blob: 5993acf03c72d2dfb317aeaf9bf980c85fa7f291 [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;
Phaneendra Mandaa272a9f2015-12-04 02:42:55 +053023import org.onosproject.net.NshContextHeader;
Phaneendra Mandaab5a7362015-12-02 01:10:01 +053024import org.onosproject.net.flow.instructions.ExtensionTreatmentType;
25
26import com.google.common.testing.EqualsTester;
27
28/**
29 * Unit tests for NiciraSetNshContextHeader class.
30 */
31public class NiciraSetNshContextHeaderTest {
32
Phaneendra Mandaa272a9f2015-12-04 02:42:55 +053033 final NiciraSetNshContextHeader nshCh1 = new NiciraSetNshContextHeader(NshContextHeader.of(10),
Phaneendra Mandaab5a7362015-12-02 01:10:01 +053034 ExtensionTreatmentType.
35 ExtensionTreatmentTypes.
36 NICIRA_SET_NSH_CH1.type());
Phaneendra Mandaa272a9f2015-12-04 02:42:55 +053037 final NiciraSetNshContextHeader sameAsNshCh1 = new NiciraSetNshContextHeader(NshContextHeader.of(10),
Phaneendra Mandaab5a7362015-12-02 01:10:01 +053038 ExtensionTreatmentType.
39 ExtensionTreatmentTypes.
40 NICIRA_SET_NSH_CH1.type());
Phaneendra Mandaa272a9f2015-12-04 02:42:55 +053041 final NiciraSetNshContextHeader nshCh2 = new NiciraSetNshContextHeader(NshContextHeader.of(20),
Phaneendra Mandaab5a7362015-12-02 01:10:01 +053042 ExtensionTreatmentType.
43 ExtensionTreatmentTypes.
44 NICIRA_SET_NSH_CH1.type());
45
46 /**
47 * Checks the operation of equals() methods.
48 */
49 @Test
50 public void testEquals() {
51 new EqualsTester().addEqualityGroup(nshCh1, sameAsNshCh1).addEqualityGroup(nshCh2).testEquals();
52 }
53
54 /**
55 * Checks the construction of a NiciraSetNshSi object.
56 */
57 @Test
58 public void testConstruction() {
Phaneendra Mandaa272a9f2015-12-04 02:42:55 +053059 final NiciraSetNshContextHeader niciraSetNshCh = new NiciraSetNshContextHeader(NshContextHeader.of(10),
Phaneendra Mandaab5a7362015-12-02 01:10:01 +053060 ExtensionTreatmentType.
61 ExtensionTreatmentTypes.
62 NICIRA_SET_NSH_CH1.type());
63 assertThat(niciraSetNshCh, is(notNullValue()));
Phaneendra Mandaa272a9f2015-12-04 02:42:55 +053064 assertThat(niciraSetNshCh.nshCh().nshContextHeader(), is(10));
Phaneendra Mandaab5a7362015-12-02 01:10:01 +053065 assertThat(niciraSetNshCh.type(), is(ExtensionTreatmentType.
66 ExtensionTreatmentTypes.
67 NICIRA_SET_NSH_CH1.type()));
68 }
69}