bobzhou | 1aaecbd | 2015-10-31 17:41:34 +0800 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.vtnrsc.router; |
| 17 | |
| 18 | import static org.hamcrest.MatcherAssert.assertThat; |
| 19 | import static org.hamcrest.Matchers.is; |
| 20 | import static org.hamcrest.Matchers.notNullValue; |
| 21 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 22 | |
| 23 | import org.junit.Test; |
| 24 | import org.onosproject.vtnrsc.RouterId; |
| 25 | |
| 26 | import com.google.common.testing.EqualsTester; |
| 27 | |
| 28 | /** |
| 29 | * Unit tests for RouterId class. |
| 30 | */ |
| 31 | public class RouterIdTest { |
| 32 | final RouterId routerId1 = RouterId.valueOf("1"); |
| 33 | final RouterId sameAsRouterId1 = RouterId.valueOf("1"); |
| 34 | final RouterId routerId2 = RouterId.valueOf("2"); |
| 35 | |
| 36 | /** |
| 37 | * Checks that the RouterId class is immutable. |
| 38 | */ |
| 39 | @Test |
| 40 | public void testImmutability() { |
| 41 | assertThatClassIsImmutable(RouterId.class); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Checks the operation of equals() methods. |
| 46 | */ |
| 47 | @Test |
| 48 | public void testEquals() { |
| 49 | new EqualsTester().addEqualityGroup(routerId1, sameAsRouterId1).addEqualityGroup(routerId2) |
| 50 | .testEquals(); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Checks the construction of a RouterId object. |
| 55 | */ |
| 56 | @Test |
| 57 | public void testConstruction() { |
| 58 | final String routerIdValue = "s"; |
| 59 | final RouterId routerId = RouterId.valueOf(routerIdValue); |
| 60 | assertThat(routerId, is(notNullValue())); |
| 61 | assertThat(routerId.routerId(), is(routerIdValue)); |
| 62 | } |
| 63 | } |