Committed by
Gerrit Code Review
[ONOS-3248] Add the junit test code of AllowedAddressPair
Change-Id: I8d4086353f37febd15de5323446e22dd57b4e437
Showing
1 changed file
with
76 additions
and
0 deletions
apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/AllowedAddressPairTest.java
0 → 100644
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.onlab.packet.IpAddress; | ||
26 | +import org.onlab.packet.MacAddress; | ||
27 | +import org.onosproject.vtnrsc.AllowedAddressPair; | ||
28 | + | ||
29 | +import com.google.common.testing.EqualsTester; | ||
30 | + | ||
31 | +/** | ||
32 | + * Unit tests for AllowedAddressPair class. | ||
33 | + */ | ||
34 | +public class AllowedAddressPairTest { | ||
35 | + | ||
36 | + final IpAddress ip1 = IpAddress.valueOf("192.168.0.1"); | ||
37 | + final IpAddress ip2 = IpAddress.valueOf("192.168.0.2"); | ||
38 | + final MacAddress mac1 = MacAddress.valueOf("fa:16:3e:76:83:88"); | ||
39 | + final MacAddress mac2 = MacAddress.valueOf("aa:16:3e:76:83:88"); | ||
40 | + | ||
41 | + /** | ||
42 | + * Checks that the AllowedAddressPair class is immutable. | ||
43 | + */ | ||
44 | + @Test | ||
45 | + public void testImmutability() { | ||
46 | + assertThatClassIsImmutable(AllowedAddressPair.class); | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * Checks the operation of equals(). | ||
51 | + */ | ||
52 | + @Test | ||
53 | + public void testEquals() { | ||
54 | + AllowedAddressPair p1 = AllowedAddressPair | ||
55 | + .allowedAddressPair(ip1, mac1); | ||
56 | + AllowedAddressPair p2 = AllowedAddressPair | ||
57 | + .allowedAddressPair(ip1, mac1); | ||
58 | + AllowedAddressPair p3 = AllowedAddressPair | ||
59 | + .allowedAddressPair(ip2, mac2); | ||
60 | + new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3) | ||
61 | + .testEquals(); | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * Checks the construction of a AllowedAddressPair object. | ||
66 | + */ | ||
67 | + @Test | ||
68 | + public void testConstruction() { | ||
69 | + AllowedAddressPair allowedAddressPair = AllowedAddressPair | ||
70 | + .allowedAddressPair(ip1, mac1); | ||
71 | + assertThat(ip1, is(notNullValue())); | ||
72 | + assertThat(ip1, is(allowedAddressPair.ip())); | ||
73 | + assertThat(mac1, is(notNullValue())); | ||
74 | + assertThat(mac1, is(allowedAddressPair.mac())); | ||
75 | + } | ||
76 | +} |
-
Please register or login to post a comment