Jian Li | e631216 | 2018-03-21 21:41:00 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-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 | */ |
| 16 | package org.onosproject.openstacknode.impl; |
| 17 | |
| 18 | import com.google.common.testing.EqualsTester; |
| 19 | import org.junit.Test; |
| 20 | import org.onosproject.openstacknode.api.OpenstackPhyInterface; |
| 21 | |
| 22 | import static org.hamcrest.MatcherAssert.assertThat; |
| 23 | import static org.hamcrest.Matchers.is; |
| 24 | |
| 25 | /** |
| 26 | * Unit tests for DefaultOpenstackPhyInterface. |
| 27 | */ |
| 28 | public class DefaultOpenstackPhyInterfaceTest { |
| 29 | |
| 30 | private static final String NETWORK_1 = "mgmtnetwork"; |
| 31 | private static final String NETWORK_2 = "oamnetwork"; |
| 32 | private static final String INTERFACE_1 = "eth3"; |
| 33 | private static final String INTERFACE_2 = "eth4"; |
| 34 | |
| 35 | private static final OpenstackPhyInterface OS_PHY_INTF_1 = |
| 36 | new DefaultOpenstackPhyInterface(NETWORK_1, INTERFACE_1); |
| 37 | private static final OpenstackPhyInterface OS_PHY_INTF_2 = |
| 38 | new DefaultOpenstackPhyInterface(NETWORK_1, INTERFACE_1); |
| 39 | private static final OpenstackPhyInterface OS_PHY_INTF_3 = |
| 40 | new DefaultOpenstackPhyInterface(NETWORK_2, INTERFACE_2); |
| 41 | |
| 42 | @Test |
| 43 | public void testEquality() { |
| 44 | new EqualsTester().addEqualityGroup(OS_PHY_INTF_1, OS_PHY_INTF_2) |
| 45 | .addEqualityGroup(OS_PHY_INTF_3) |
| 46 | .testEquals(); |
| 47 | } |
| 48 | |
| 49 | @Test |
| 50 | public void testConstruction() { |
| 51 | DefaultOpenstackPhyInterface phyIntf = (DefaultOpenstackPhyInterface) |
| 52 | OS_PHY_INTF_1; |
| 53 | |
| 54 | assertThat(phyIntf.network(), is(NETWORK_1)); |
| 55 | assertThat(phyIntf.intf(), is(INTERFACE_1)); |
| 56 | } |
| 57 | } |