Committed by
Gerrit Code Review
[ONOS-3252] Add the junit test code of VirtualPortId
Change-Id: Ia26594913a7c33406379a0015464c89567790a42
Showing
1 changed file
with
66 additions
and
0 deletions
| 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 | + | ||
| 17 | +package org.onosproject.vtnrsc.virtualport; | ||
| 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 | +import org.onosproject.vtnrsc.VirtualPortId; | ||
| 26 | + | ||
| 27 | +import com.google.common.testing.EqualsTester; | ||
| 28 | + | ||
| 29 | +/** | ||
| 30 | + * Unit tests for VirtualPortId class. | ||
| 31 | + */ | ||
| 32 | +public class VirtualPortIdTest { | ||
| 33 | + | ||
| 34 | + final VirtualPortId virtualPortId1 = VirtualPortId.portId("1"); | ||
| 35 | + final VirtualPortId sameAsVirtualPortId1 = VirtualPortId.portId("1"); | ||
| 36 | + final VirtualPortId virtualPortId2 = VirtualPortId.portId("2"); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * Checks that the VirtualPortId class is immutable. | ||
| 40 | + */ | ||
| 41 | + @Test | ||
| 42 | + public void testImmutability() { | ||
| 43 | + assertThatClassIsImmutable(VirtualPortId.class); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * Checks the operation of equals(). | ||
| 48 | + */ | ||
| 49 | + @Test | ||
| 50 | + public void testEquals() { | ||
| 51 | + new EqualsTester().addEqualityGroup(virtualPortId1, sameAsVirtualPortId1) | ||
| 52 | + .addEqualityGroup(virtualPortId2).testEquals(); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * Checks the construction of a VirtualPortId object. | ||
| 57 | + */ | ||
| 58 | + @Test | ||
| 59 | + public void testConstruction() { | ||
| 60 | + final String vPortIdValue = "aaa"; | ||
| 61 | + final VirtualPortId virtualPortId = VirtualPortId.portId(vPortIdValue); | ||
| 62 | + assertThat(virtualPortId, is(notNullValue())); | ||
| 63 | + assertThat(virtualPortId.portId(), is(vPortIdValue)); | ||
| 64 | + | ||
| 65 | + } | ||
| 66 | +} |
-
Please register or login to post a comment