Thomas Vachuska | bf916ea | 2015-05-20 18:24:34 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | bf916ea | 2015-05-20 18:24:34 -0700 | [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 | |
| 17 | package org.onosproject.incubator.net.tunnel; |
jcc | 4a20a5f | 2015-04-30 15:43:39 +0800 | [diff] [blame] | 18 | |
| 19 | import static org.hamcrest.MatcherAssert.assertThat; |
| 20 | import static org.hamcrest.Matchers.is; |
| 21 | import static org.hamcrest.Matchers.notNullValue; |
| 22 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 23 | |
| 24 | import org.junit.Test; |
| 25 | |
| 26 | import com.google.common.testing.EqualsTester; |
| 27 | |
| 28 | /** |
| 29 | * Unit tests for tunnel id class. |
| 30 | */ |
| 31 | public class TunnelIdTest { |
| 32 | |
| 33 | final TunnelId tunnelId1 = TunnelId.valueOf(1); |
| 34 | final TunnelId sameAstunnelId1 = TunnelId.valueOf(1); |
| 35 | final TunnelId tunnelId2 = TunnelId.valueOf(2); |
| 36 | |
| 37 | /** |
| 38 | * Checks that the TunnelId class is immutable. |
| 39 | */ |
| 40 | @Test |
| 41 | public void testImmutability() { |
| 42 | assertThatClassIsImmutable(TunnelId.class); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Checks the operation of equals(), hashCode() and toString() methods. |
| 47 | */ |
| 48 | @Test |
| 49 | public void testEquals() { |
| 50 | new EqualsTester() |
| 51 | .addEqualityGroup(tunnelId1, sameAstunnelId1) |
| 52 | .addEqualityGroup(tunnelId2) |
| 53 | .testEquals(); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Checks the construction of a FlowId object. |
| 58 | */ |
| 59 | @Test |
| 60 | public void testConstruction() { |
| 61 | final long tunnelIdValue = 7777L; |
| 62 | final TunnelId tunnelId = TunnelId.valueOf(tunnelIdValue); |
| 63 | assertThat(tunnelId, is(notNullValue())); |
| 64 | assertThat(tunnelId.id(), is(tunnelIdValue)); |
| 65 | } |
| 66 | } |