Committed by
Gerrit Code Review
UT added for Pcep TLVs
Change-Id: Ic231a2af9dafa2a5ee235808066aa531fea95242
Showing
9 changed files
with
301 additions
and
0 deletions
... | @@ -40,6 +40,17 @@ public class PcepNaiIpv4Adjacency implements PcepNai { | ... | @@ -40,6 +40,17 @@ public class PcepNaiIpv4Adjacency implements PcepNai { |
40 | this.remoteIpv4Addr = remoteIpv4; | 40 | this.remoteIpv4Addr = remoteIpv4; |
41 | } | 41 | } |
42 | 42 | ||
43 | + /** | ||
44 | + * Returns Object of Pcep nai Ipv4 Adjacency. | ||
45 | + * | ||
46 | + * @param localIpv4Addr local ipv4 address | ||
47 | + * @param remoteIpv4Addr remote ipv4 address | ||
48 | + * @return Object of Pcep nai Ipv4 Adjacency | ||
49 | + */ | ||
50 | + public static PcepNaiIpv4Adjacency of(int localIpv4Addr, int remoteIpv4Addr) { | ||
51 | + return new PcepNaiIpv4Adjacency(localIpv4Addr, remoteIpv4Addr); | ||
52 | + } | ||
53 | + | ||
43 | @Override | 54 | @Override |
44 | public byte getType() { | 55 | public byte getType() { |
45 | return ST_TYPE; | 56 | return ST_TYPE; | ... | ... |
... | @@ -39,6 +39,16 @@ public class PcepNaiIpv6NodeId implements PcepNai { | ... | @@ -39,6 +39,16 @@ public class PcepNaiIpv6NodeId implements PcepNai { |
39 | this.ipv6NodeId = value; | 39 | this.ipv6NodeId = value; |
40 | } | 40 | } |
41 | 41 | ||
42 | + /** | ||
43 | + * Return object of Pcep Nai Ipv6 Node ID. | ||
44 | + * | ||
45 | + * @param ipv6NodeId Ipv6 node ID. | ||
46 | + * @return object of Pcep Nai Ipv6 Node ID. | ||
47 | + */ | ||
48 | + public static PcepNaiIpv6NodeId of(byte[] ipv6NodeId) { | ||
49 | + return new PcepNaiIpv6NodeId(ipv6NodeId); | ||
50 | + } | ||
51 | + | ||
42 | @Override | 52 | @Override |
43 | public byte getType() { | 53 | public byte getType() { |
44 | return ST_TYPE; | 54 | return ST_TYPE; | ... | ... |
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.pcepio; | ||
17 | + | ||
18 | +import org.junit.Test; | ||
19 | +import org.onosproject.pcepio.types.NexthopIPv4addressTlv; | ||
20 | + | ||
21 | +import com.google.common.testing.EqualsTester; | ||
22 | + | ||
23 | +/** | ||
24 | + * Equality test for NexthopIPv4addressTlv. | ||
25 | + */ | ||
26 | +public class NexthopIPv4addressTlvTest { | ||
27 | + | ||
28 | + private final NexthopIPv4addressTlv tlv1 = new NexthopIPv4addressTlv(0x0A); | ||
29 | + private final NexthopIPv4addressTlv sameAsTlv1 = new NexthopIPv4addressTlv(0x0A); | ||
30 | + private final NexthopIPv4addressTlv tlv2 = NexthopIPv4addressTlv.of(0x0B); | ||
31 | + | ||
32 | + @Test | ||
33 | + public void basics() { | ||
34 | + new EqualsTester() | ||
35 | + .addEqualityGroup(tlv1, sameAsTlv1) | ||
36 | + .addEqualityGroup(tlv2) | ||
37 | + .testEquals(); | ||
38 | + } | ||
39 | +} |
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.pcepio; | ||
18 | + | ||
19 | +import org.junit.Test; | ||
20 | +import org.onosproject.pcepio.types.NexthopIPv6addressTlv; | ||
21 | + | ||
22 | +import com.google.common.testing.EqualsTester; | ||
23 | + | ||
24 | +/** | ||
25 | + * Equality test for NexthopIPv6addressTlv. | ||
26 | + */ | ||
27 | +public class NexthopIPv6addressTlvTest { | ||
28 | + | ||
29 | + private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, | ||
30 | + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00 }; | ||
31 | + private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, | ||
32 | + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; | ||
33 | + | ||
34 | + private final NexthopIPv6addressTlv tlv1 = NexthopIPv6addressTlv.of(b1); | ||
35 | + private final NexthopIPv6addressTlv sameAsTlv1 = NexthopIPv6addressTlv.of(b1); | ||
36 | + private final NexthopIPv6addressTlv tlv2 = NexthopIPv6addressTlv.of(b2); | ||
37 | + | ||
38 | + @Test | ||
39 | + public void basics() { | ||
40 | + new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); | ||
41 | + } | ||
42 | + | ||
43 | +} |
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.pcepio; | ||
17 | + | ||
18 | +import org.junit.Test; | ||
19 | +import org.onosproject.pcepio.types.NexthopUnnumberedIPv4IDTlv; | ||
20 | + | ||
21 | +import com.google.common.testing.EqualsTester; | ||
22 | + | ||
23 | +/** | ||
24 | + * Equality test for NexthopUnnumberedIPv4IDTlv. | ||
25 | + */ | ||
26 | +public class NexthopUnnumberedIPv4IDTlvTest { | ||
27 | + | ||
28 | + private final NexthopUnnumberedIPv4IDTlv tlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A); | ||
29 | + private final NexthopUnnumberedIPv4IDTlv sameAsTlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A); | ||
30 | + private final NexthopUnnumberedIPv4IDTlv tlv2 = NexthopUnnumberedIPv4IDTlv.of(0x0B, 0x0B); | ||
31 | + | ||
32 | + @Test | ||
33 | + public void basics() { | ||
34 | + new EqualsTester() | ||
35 | + .addEqualityGroup(tlv1, sameAsTlv1) | ||
36 | + .addEqualityGroup(tlv2) | ||
37 | + .testEquals(); | ||
38 | + } | ||
39 | +} |
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.pcepio; | ||
17 | + | ||
18 | +import org.junit.Test; | ||
19 | +import org.onosproject.pcepio.types.PathKeySubObject; | ||
20 | + | ||
21 | +import com.google.common.testing.EqualsTester; | ||
22 | + | ||
23 | +/** | ||
24 | + * Test of the PathKeySubObject. | ||
25 | + */ | ||
26 | +public class PathKeySubObjectTest { | ||
27 | + | ||
28 | + private final PathKeySubObject tlv1 = new PathKeySubObject((short) 0x0A, 0x0A); | ||
29 | + private final PathKeySubObject sameAsTlv1 = PathKeySubObject.of((short) 0x0A, 0x0A); | ||
30 | + private final PathKeySubObject tlv2 = new PathKeySubObject((short) 0x0B, 0x0B); | ||
31 | + | ||
32 | + @Test | ||
33 | + public void basics() { | ||
34 | + new EqualsTester() | ||
35 | + .addEqualityGroup(tlv1, sameAsTlv1) | ||
36 | + .addEqualityGroup(tlv2) | ||
37 | + .testEquals(); | ||
38 | + } | ||
39 | +} |
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.pcepio; | ||
18 | + | ||
19 | +import org.junit.Test; | ||
20 | +import org.onosproject.pcepio.types.PcepNaiIpv4Adjacency; | ||
21 | + | ||
22 | +import com.google.common.testing.EqualsTester; | ||
23 | + | ||
24 | +/** | ||
25 | + * Equality test for PcepNaiIpv4Adjacency. | ||
26 | + */ | ||
27 | +public class PcepNaiIpv4AdjacencyTest { | ||
28 | + | ||
29 | + private final PcepNaiIpv4Adjacency obj1 = PcepNaiIpv4Adjacency.of(2, 16); | ||
30 | + private final PcepNaiIpv4Adjacency sameAsObj1 = PcepNaiIpv4Adjacency.of(2, 16); | ||
31 | + private final PcepNaiIpv4Adjacency obj2 = PcepNaiIpv4Adjacency.of(3, 16); | ||
32 | + | ||
33 | + @Test | ||
34 | + public void basics() { | ||
35 | + new EqualsTester().addEqualityGroup(obj1, sameAsObj1).addEqualityGroup(obj2).testEquals(); | ||
36 | + } | ||
37 | + | ||
38 | +} |
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.pcepio; | ||
18 | + | ||
19 | +import org.junit.Test; | ||
20 | +import org.onosproject.pcepio.types.PcepNaiIpv6NodeId; | ||
21 | + | ||
22 | +import com.google.common.testing.EqualsTester; | ||
23 | + | ||
24 | +/** | ||
25 | + * Equality test for PcepNaiIpv6NodeId. | ||
26 | + */ | ||
27 | +public class PcepNaiIpv6NodeIdTest { | ||
28 | + | ||
29 | + private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, | ||
30 | + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, | ||
31 | + 0x00, 0x00 }; | ||
32 | + private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, | ||
33 | + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, | ||
34 | + 0x00, 0x00 }; | ||
35 | + | ||
36 | + private final PcepNaiIpv6NodeId tlv1 = PcepNaiIpv6NodeId.of(b1); | ||
37 | + private final PcepNaiIpv6NodeId sameAsTlv1 = PcepNaiIpv6NodeId.of(b1); | ||
38 | + private final PcepNaiIpv6NodeId tlv2 = PcepNaiIpv6NodeId.of(b2); | ||
39 | + | ||
40 | + @Test | ||
41 | + public void basics() { | ||
42 | + new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); | ||
43 | + } | ||
44 | + | ||
45 | +} |
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.pcepio; | ||
18 | + | ||
19 | +import org.junit.Test; | ||
20 | +import org.onosproject.pcepio.types.RoutingUniverseTLV; | ||
21 | + | ||
22 | +import com.google.common.testing.EqualsTester; | ||
23 | + | ||
24 | +/** | ||
25 | + * Equality test for RoutingUniverseTlv. | ||
26 | + */ | ||
27 | +public class RoutingUniverseTLVTest { | ||
28 | + | ||
29 | + private final RoutingUniverseTLV tlv1 = RoutingUniverseTLV.of(2); | ||
30 | + private final RoutingUniverseTLV tlv2 = RoutingUniverseTLV.of(2); | ||
31 | + private final RoutingUniverseTLV tlv3 = RoutingUniverseTLV.of(3); | ||
32 | + | ||
33 | + @Test | ||
34 | + public void basics() { | ||
35 | + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); | ||
36 | + } | ||
37 | +} |
-
Please register or login to post a comment