Phaneendra Manda | ab5a736 | 2015-12-02 01:10:01 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Phaneendra Manda | ab5a736 | 2015-12-02 01:10:01 +0530 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.driver.extensions; |
| 17 | |
| 18 | import static org.hamcrest.MatcherAssert.assertThat; |
| 19 | import static org.hamcrest.Matchers.is; |
| 20 | import static org.hamcrest.Matchers.notNullValue; |
| 21 | |
| 22 | import org.junit.Test; |
Phaneendra Manda | a272a9f | 2015-12-04 02:42:55 +0530 | [diff] [blame] | 23 | import org.onosproject.net.NshContextHeader; |
Phaneendra Manda | ab5a736 | 2015-12-02 01:10:01 +0530 | [diff] [blame] | 24 | import org.onosproject.net.flow.instructions.ExtensionTreatmentType; |
| 25 | |
| 26 | import com.google.common.testing.EqualsTester; |
| 27 | |
| 28 | /** |
| 29 | * Unit tests for NiciraSetNshContextHeader class. |
| 30 | */ |
| 31 | public class NiciraSetNshContextHeaderTest { |
| 32 | |
Phaneendra Manda | a272a9f | 2015-12-04 02:42:55 +0530 | [diff] [blame] | 33 | final NiciraSetNshContextHeader nshCh1 = new NiciraSetNshContextHeader(NshContextHeader.of(10), |
Phaneendra Manda | ab5a736 | 2015-12-02 01:10:01 +0530 | [diff] [blame] | 34 | ExtensionTreatmentType. |
| 35 | ExtensionTreatmentTypes. |
| 36 | NICIRA_SET_NSH_CH1.type()); |
Phaneendra Manda | a272a9f | 2015-12-04 02:42:55 +0530 | [diff] [blame] | 37 | final NiciraSetNshContextHeader sameAsNshCh1 = new NiciraSetNshContextHeader(NshContextHeader.of(10), |
Phaneendra Manda | ab5a736 | 2015-12-02 01:10:01 +0530 | [diff] [blame] | 38 | ExtensionTreatmentType. |
| 39 | ExtensionTreatmentTypes. |
| 40 | NICIRA_SET_NSH_CH1.type()); |
Phaneendra Manda | a272a9f | 2015-12-04 02:42:55 +0530 | [diff] [blame] | 41 | final NiciraSetNshContextHeader nshCh2 = new NiciraSetNshContextHeader(NshContextHeader.of(20), |
Phaneendra Manda | ab5a736 | 2015-12-02 01:10:01 +0530 | [diff] [blame] | 42 | 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 Manda | a272a9f | 2015-12-04 02:42:55 +0530 | [diff] [blame] | 59 | final NiciraSetNshContextHeader niciraSetNshCh = new NiciraSetNshContextHeader(NshContextHeader.of(10), |
Phaneendra Manda | ab5a736 | 2015-12-02 01:10:01 +0530 | [diff] [blame] | 60 | ExtensionTreatmentType. |
| 61 | ExtensionTreatmentTypes. |
| 62 | NICIRA_SET_NSH_CH1.type()); |
| 63 | assertThat(niciraSetNshCh, is(notNullValue())); |
Phaneendra Manda | a272a9f | 2015-12-04 02:42:55 +0530 | [diff] [blame] | 64 | assertThat(niciraSetNshCh.nshCh().nshContextHeader(), is(10)); |
Phaneendra Manda | ab5a736 | 2015-12-02 01:10:01 +0530 | [diff] [blame] | 65 | assertThat(niciraSetNshCh.type(), is(ExtensionTreatmentType. |
| 66 | ExtensionTreatmentTypes. |
| 67 | NICIRA_SET_NSH_CH1.type())); |
| 68 | } |
| 69 | } |