Committed by
Gerrit Code Review
ONOS-4083,ONOS-4084:JUNIT for ISIS PDU TLV Data Structures
Change-Id: I0849d87ad1c7f9a8e08aabebd547dfd2dfde49df
Showing
31 changed files
with
3658 additions
and
92 deletions
1 | /* | 1 | /* |
2 | - * Copyright 2016-present Open Networking Laboratory | 2 | +* Copyright 2016-present Open Networking Laboratory |
3 | - * | 3 | +* |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | 4 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
5 | - * you may not use this file except in compliance with 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 | 6 | +* You may obtain a copy of the License at |
7 | - * | 7 | +* |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | 8 | +* http://www.apache.org/licenses/LICENSE-2.0 |
9 | - * | 9 | +* |
10 | - * Unless required by applicable law or agreed to in writing, software | 10 | +* Unless required by applicable law or agreed to in writing, software |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | 11 | +* distributed under the License is distributed on an "AS IS" BASIS, |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | - * See the License for the specific language governing permissions and | 13 | +* See the License for the specific language governing permissions and |
14 | - * limitations under the License. | 14 | +* limitations under the License. |
15 | - */ | 15 | +*/ |
16 | package org.onosproject.isis.io.isispacket.tlv; | 16 | package org.onosproject.isis.io.isispacket.tlv; |
17 | 17 | ||
18 | import com.google.common.base.MoreObjects; | 18 | import com.google.common.base.MoreObjects; |
19 | import com.google.common.primitives.Bytes; | 19 | import com.google.common.primitives.Bytes; |
20 | import org.jboss.netty.buffer.ChannelBuffer; | 20 | import org.jboss.netty.buffer.ChannelBuffer; |
21 | -import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvFinder; | ||
22 | -import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvToBytes; | ||
23 | -import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvType; | ||
24 | -import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv; | ||
25 | import org.onosproject.isis.io.util.IsisUtil; | 21 | import org.onosproject.isis.io.util.IsisUtil; |
26 | 22 | ||
27 | import java.util.ArrayList; | 23 | import java.util.ArrayList; |
... | @@ -32,9 +28,7 @@ import java.util.List; | ... | @@ -32,9 +28,7 @@ import java.util.List; |
32 | */ | 28 | */ |
33 | public class IsExtendedReachability extends TlvHeader implements IsisTlv { | 29 | public class IsExtendedReachability extends TlvHeader implements IsisTlv { |
34 | 30 | ||
35 | - private String neighborId; | 31 | + private List<NeighborForExtendedIs> neighbors = new ArrayList<>(); |
36 | - private int metric; | ||
37 | - private List<TrafficEngineeringSubTlv> trafEnginSubTlv = new ArrayList<>(); | ||
38 | 32 | ||
39 | /** | 33 | /** |
40 | * Creates an instance of IP external reachability TLV. | 34 | * Creates an instance of IP external reachability TLV. |
... | @@ -47,67 +41,20 @@ public class IsExtendedReachability extends TlvHeader implements IsisTlv { | ... | @@ -47,67 +41,20 @@ public class IsExtendedReachability extends TlvHeader implements IsisTlv { |
47 | } | 41 | } |
48 | 42 | ||
49 | /** | 43 | /** |
50 | - * Returns neighbor ID. | 44 | + * Adds the neighbor for extended IS instance to IS extended reachability TLV. |
51 | - * | ||
52 | - * @return neighbor ID | ||
53 | - */ | ||
54 | - public String neighborId() { | ||
55 | - return neighborId; | ||
56 | - } | ||
57 | - | ||
58 | - /** | ||
59 | - * Sets neighbor ID. | ||
60 | - * | ||
61 | - * @param neighborId neighbor ID | ||
62 | - */ | ||
63 | - public void setNeighborId(String neighborId) { | ||
64 | - this.neighborId = neighborId; | ||
65 | - } | ||
66 | - | ||
67 | - /** | ||
68 | - * Returns metric. | ||
69 | * | 45 | * |
70 | - * @return metric | 46 | + * @param neighbor neighbor for extended IS instance |
71 | */ | 47 | */ |
72 | - public int metric() { | 48 | + public void addNeighbor(NeighborForExtendedIs neighbor) { |
73 | - return metric; | 49 | + this.neighbors.add(neighbor); |
74 | - } | ||
75 | - | ||
76 | - /** | ||
77 | - * Sets metric. | ||
78 | - * | ||
79 | - * @param metric metric | ||
80 | - */ | ||
81 | - public void setMetric(int metric) { | ||
82 | - this.metric = metric; | ||
83 | - } | ||
84 | - | ||
85 | - /** | ||
86 | - * Adds the traffic engineering sub TLV to IS extended reachability TLV. | ||
87 | - * | ||
88 | - * @param trafEnginSubTlv traffic engineering sub TLV | ||
89 | - */ | ||
90 | - public void addSubTlv(TrafficEngineeringSubTlv trafEnginSubTlv) { | ||
91 | - this.trafEnginSubTlv.add(trafEnginSubTlv); | ||
92 | } | 50 | } |
93 | 51 | ||
94 | @Override | 52 | @Override |
95 | public void readFrom(ChannelBuffer channelBuffer) { | 53 | public void readFrom(ChannelBuffer channelBuffer) { |
96 | - byte[] tempByteArray = new byte[IsisUtil.ID_SIX_BYTES]; | 54 | + while (channelBuffer.readableBytes() >= IsisUtil.EIGHT_BYTES + IsisUtil.THREE_BYTES) { |
97 | - channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_SIX_BYTES); | 55 | + NeighborForExtendedIs extendedIs = new NeighborForExtendedIs(); |
98 | - this.setNeighborId(IsisUtil.systemId(tempByteArray)); | 56 | + extendedIs.readFrom(channelBuffer); |
99 | - this.setMetric(channelBuffer.readUnsignedMedium()); | 57 | + this.addNeighbor(extendedIs); |
100 | - while (channelBuffer.readableBytes() > 0) { | ||
101 | - TlvHeader tlvHeader = new TlvHeader(); | ||
102 | - tlvHeader.setTlvType(channelBuffer.readByte()); | ||
103 | - tlvHeader.setTlvLength(channelBuffer.readByte()); | ||
104 | - SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType()); | ||
105 | - if (tlvValue != null) { | ||
106 | - this.addSubTlv(SubTlvFinder.findSubTlv(tlvHeader, | ||
107 | - channelBuffer.readBytes(tlvHeader.tlvLength()))); | ||
108 | - } else { | ||
109 | - channelBuffer.readBytes(tlvHeader.tlvLength()); | ||
110 | - } | ||
111 | } | 58 | } |
112 | } | 59 | } |
113 | 60 | ||
... | @@ -128,12 +75,8 @@ public class IsExtendedReachability extends TlvHeader implements IsisTlv { | ... | @@ -128,12 +75,8 @@ public class IsExtendedReachability extends TlvHeader implements IsisTlv { |
128 | */ | 75 | */ |
129 | private byte[] tlvBodyAsBytes() { | 76 | private byte[] tlvBodyAsBytes() { |
130 | List<Byte> byteList = new ArrayList<>(); | 77 | List<Byte> byteList = new ArrayList<>(); |
131 | - byteList.addAll(IsisUtil.sourceAndLanIdToBytes(this.neighborId())); | 78 | + for (NeighborForExtendedIs neighbor : this.neighbors) { |
132 | - byteList.addAll(Bytes.asList(IsisUtil.convertToThreeBytes(this.metric()))); | 79 | + byteList.addAll(Bytes.asList(neighbor.neighborBodyAsbytes())); |
133 | - if (this.trafEnginSubTlv.size() > 0) { | ||
134 | - for (TrafficEngineeringSubTlv trafficEngineeringSubTlv : this.trafEnginSubTlv) { | ||
135 | - byteList.addAll(SubTlvToBytes.tlvToBytes(trafficEngineeringSubTlv)); | ||
136 | - } | ||
137 | } | 80 | } |
138 | return Bytes.toArray(byteList); | 81 | return Bytes.toArray(byteList); |
139 | } | 82 | } |
... | @@ -142,10 +85,7 @@ public class IsExtendedReachability extends TlvHeader implements IsisTlv { | ... | @@ -142,10 +85,7 @@ public class IsExtendedReachability extends TlvHeader implements IsisTlv { |
142 | public String toString() { | 85 | public String toString() { |
143 | return MoreObjects.toStringHelper(getClass()) | 86 | return MoreObjects.toStringHelper(getClass()) |
144 | .omitNullValues() | 87 | .omitNullValues() |
145 | - .add("neighborId", neighborId) | 88 | + .add("neighbors", neighbors) |
146 | - .add("metric", metric) | ||
147 | - .add("trafEnginSubTlv", trafEnginSubTlv) | ||
148 | .toString(); | 89 | .toString(); |
149 | } | 90 | } |
150 | - | 91 | +} |
151 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import com.google.common.base.MoreObjects; | ||
19 | +import com.google.common.primitives.Bytes; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
21 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvFinder; | ||
22 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvToBytes; | ||
23 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.SubTlvType; | ||
24 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv; | ||
25 | +import org.onosproject.isis.io.util.IsisUtil; | ||
26 | + | ||
27 | +import java.util.ArrayList; | ||
28 | +import java.util.List; | ||
29 | + | ||
30 | +/** | ||
31 | + * Representation of IS extended reachability neighbors. | ||
32 | + */ | ||
33 | +public class NeighborForExtendedIs { | ||
34 | + | ||
35 | + private String neighborId; | ||
36 | + private int metric; | ||
37 | + private List<TrafficEngineeringSubTlv> teSubTlv = new ArrayList<>(); | ||
38 | + | ||
39 | + /** | ||
40 | + * Returns neighbor ID. | ||
41 | + * | ||
42 | + * @return neighbor ID | ||
43 | + */ | ||
44 | + public String neighborId() { | ||
45 | + return neighborId; | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Sets neighbor ID. | ||
50 | + * | ||
51 | + * @param neighborId neighbor ID | ||
52 | + */ | ||
53 | + public void setNeighborId(String neighborId) { | ||
54 | + this.neighborId = neighborId; | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * Returns metric. | ||
59 | + * | ||
60 | + * @return metric | ||
61 | + */ | ||
62 | + public int metric() { | ||
63 | + return metric; | ||
64 | + } | ||
65 | + | ||
66 | + /** | ||
67 | + * Sets metric. | ||
68 | + * | ||
69 | + * @param metric metric | ||
70 | + */ | ||
71 | + public void setMetric(int metric) { | ||
72 | + this.metric = metric; | ||
73 | + } | ||
74 | + | ||
75 | + /** | ||
76 | + * Adds the TE for extended IS instance to IS extended reachability TLV. | ||
77 | + * | ||
78 | + * @param trafficEngineeringSubTlv TE for extended IS instance | ||
79 | + */ | ||
80 | + public void addSubTlv(TrafficEngineeringSubTlv trafficEngineeringSubTlv) { | ||
81 | + this.teSubTlv.add(trafficEngineeringSubTlv); | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * Reads from the channel buffer and populate this instance. | ||
86 | + * | ||
87 | + * @param channelBuffer channel buffer instance | ||
88 | + */ | ||
89 | + public void readFrom(ChannelBuffer channelBuffer) { | ||
90 | + byte[] tempByteArray = new byte[IsisUtil.ID_PLUS_ONE_BYTE]; | ||
91 | + channelBuffer.readBytes(tempByteArray, 0, IsisUtil.ID_PLUS_ONE_BYTE); | ||
92 | + this.setNeighborId(IsisUtil.systemIdPlus(tempByteArray)); | ||
93 | + this.setMetric(channelBuffer.readUnsignedMedium()); | ||
94 | + int nTlvPresent = channelBuffer.readByte(); | ||
95 | + if (nTlvPresent > 0) { | ||
96 | + while (channelBuffer.readableBytes() > IsisUtil.TWO_BYTES) { | ||
97 | + TlvHeader tlvHeader = new TlvHeader(); | ||
98 | + tlvHeader.setTlvType(channelBuffer.readByte()); | ||
99 | + tlvHeader.setTlvLength(channelBuffer.readByte()); | ||
100 | + SubTlvType tlvValue = SubTlvType.get(tlvHeader.tlvType()); | ||
101 | + int tlvLength = tlvHeader.tlvLength(); | ||
102 | + if (tlvValue != null) { | ||
103 | + if (channelBuffer.readableBytes() >= tlvLength) { | ||
104 | + this.addSubTlv(SubTlvFinder.findSubTlv(tlvHeader, | ||
105 | + channelBuffer.readBytes(tlvHeader.tlvLength()))); | ||
106 | + } | ||
107 | + } else { | ||
108 | + if (channelBuffer.readableBytes() >= tlvLength) { | ||
109 | + channelBuffer.readBytes(tlvLength); | ||
110 | + } | ||
111 | + } | ||
112 | + } | ||
113 | + } | ||
114 | + } | ||
115 | + | ||
116 | + /** | ||
117 | + * Returns neighbor details of IS extended reachability TLV. | ||
118 | + * | ||
119 | + * @return neighbor details of IS extended reachability TLV. | ||
120 | + */ | ||
121 | + public byte[] neighborBodyAsbytes() { | ||
122 | + List<Byte> byteList = new ArrayList<>(); | ||
123 | + byteList.addAll(IsisUtil.sourceAndLanIdToBytes(this.neighborId())); | ||
124 | + byteList.addAll(Bytes.asList(IsisUtil.convertToThreeBytes(this.metric()))); | ||
125 | + if (this.teSubTlv.size() > 0) { | ||
126 | + for (TrafficEngineeringSubTlv trafficEngineeringSubTlv : this.teSubTlv) { | ||
127 | + byteList.addAll(SubTlvToBytes.tlvToBytes(trafficEngineeringSubTlv)); | ||
128 | + } | ||
129 | + } | ||
130 | + return Bytes.toArray(byteList); | ||
131 | + } | ||
132 | + | ||
133 | + @Override | ||
134 | + public String toString() { | ||
135 | + return MoreObjects.toStringHelper(getClass()) | ||
136 | + .omitNullValues() | ||
137 | + .add("neighborId", neighborId) | ||
138 | + .add("metric", metric) | ||
139 | + .add("teSubTlv", teSubTlv) | ||
140 | + .toString(); | ||
141 | + } | ||
142 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv; | ||
17 | + | ||
18 | +import com.google.common.base.MoreObjects; | ||
19 | +import com.google.common.primitives.Bytes; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
21 | +import org.onlab.packet.Ip4Address; | ||
22 | +import org.onosproject.isis.io.isispacket.tlv.TlvHeader; | ||
23 | +import org.onosproject.isis.io.util.IsisUtil; | ||
24 | +import org.slf4j.Logger; | ||
25 | +import org.slf4j.LoggerFactory; | ||
26 | + | ||
27 | +import java.util.ArrayList; | ||
28 | +import java.util.List; | ||
29 | + | ||
30 | +/** | ||
31 | + * Representation of interface ip address TE value. | ||
32 | + */ | ||
33 | +public class InterfaceIpAddress extends TlvHeader implements TrafficEngineeringSubTlv { | ||
34 | + private static final Logger log = | ||
35 | + LoggerFactory.getLogger(InterfaceIpAddress.class); | ||
36 | + private List<Ip4Address> localInterfaceIPAddress = new ArrayList<>(); | ||
37 | + | ||
38 | + /** | ||
39 | + * Creates an instance of local interface ip address. | ||
40 | + * | ||
41 | + * @param header tlv header instance | ||
42 | + */ | ||
43 | + public InterfaceIpAddress(TlvHeader header) { | ||
44 | + this.setTlvType(header.tlvType()); | ||
45 | + this.setTlvLength(header.tlvLength()); | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Adds local interface ip address. | ||
50 | + * | ||
51 | + * @param localAddress ip address | ||
52 | + */ | ||
53 | + public void addLocalInterfaceIPAddress(Ip4Address localAddress) { | ||
54 | + localInterfaceIPAddress.add(localAddress); | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * Returns local interface ip address. | ||
59 | + * | ||
60 | + * @return localAddress ip address | ||
61 | + */ | ||
62 | + public List<Ip4Address> getLocalInterfaceIPAddress() { | ||
63 | + return localInterfaceIPAddress; | ||
64 | + } | ||
65 | + | ||
66 | + /** | ||
67 | + * Reads bytes from channel buffer. | ||
68 | + * | ||
69 | + * @param channelBuffer channel buffer instance | ||
70 | + */ | ||
71 | + public void readFrom(ChannelBuffer channelBuffer) { | ||
72 | + while (channelBuffer.readableBytes() >= IsisUtil.FOUR_BYTES) { | ||
73 | + byte[] tempByteArray = new byte[IsisUtil.FOUR_BYTES]; | ||
74 | + channelBuffer.readBytes(tempByteArray, 0, IsisUtil.FOUR_BYTES); | ||
75 | + this.addLocalInterfaceIPAddress(Ip4Address.valueOf(tempByteArray)); | ||
76 | + } | ||
77 | + } | ||
78 | + | ||
79 | + /** | ||
80 | + * Returns local interface ip address as byte array. | ||
81 | + * | ||
82 | + * @return local interface ip address as byte array | ||
83 | + */ | ||
84 | + public byte[] asBytes() { | ||
85 | + byte[] linkSubType = null; | ||
86 | + byte[] linkSubTlvHeader = tlvHeaderAsByteArray(); | ||
87 | + byte[] linkSubTlvBody = tlvBodyAsBytes(); | ||
88 | + linkSubType = Bytes.concat(linkSubTlvHeader, linkSubTlvBody); | ||
89 | + | ||
90 | + return linkSubType; | ||
91 | + } | ||
92 | + | ||
93 | + /** | ||
94 | + * Returns byte array of local interface ip address. | ||
95 | + * | ||
96 | + * @return byte array of local interface ip address | ||
97 | + */ | ||
98 | + public byte[] tlvBodyAsBytes() { | ||
99 | + List<Byte> linkSubTypeBody = new ArrayList<>(); | ||
100 | + for (Ip4Address remoteAddress : this.localInterfaceIPAddress) { | ||
101 | + linkSubTypeBody.addAll(Bytes.asList(remoteAddress.toOctets())); | ||
102 | + } | ||
103 | + | ||
104 | + return Bytes.toArray(linkSubTypeBody); | ||
105 | + } | ||
106 | + | ||
107 | + @Override | ||
108 | + public String toString() { | ||
109 | + return MoreObjects.toStringHelper(getClass()) | ||
110 | + .omitNullValues() | ||
111 | + .add("localInterfaceIPAddress", localInterfaceIPAddress) | ||
112 | + .toString(); | ||
113 | + } | ||
114 | +} |
... | @@ -66,6 +66,11 @@ public final class SubTlvFinder { | ... | @@ -66,6 +66,11 @@ public final class SubTlvFinder { |
66 | unreservedBandwidth.readFrom(channelBuffer); | 66 | unreservedBandwidth.readFrom(channelBuffer); |
67 | subTlv = unreservedBandwidth; | 67 | subTlv = unreservedBandwidth; |
68 | break; | 68 | break; |
69 | + case INTERFACEADDRESS: | ||
70 | + InterfaceIpAddress ipInterfaceAddressTlv = new InterfaceIpAddress(tlvHeader); | ||
71 | + ipInterfaceAddressTlv.readFrom(channelBuffer); | ||
72 | + subTlv = ipInterfaceAddressTlv; | ||
73 | + break; | ||
69 | default: | 74 | default: |
70 | //TODO | 75 | //TODO |
71 | break; | 76 | break; | ... | ... |
protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/subtlv/SubTlvToBytes.java
... | @@ -60,6 +60,9 @@ public final class SubTlvToBytes { | ... | @@ -60,6 +60,9 @@ public final class SubTlvToBytes { |
60 | } else if (subTlv instanceof UnreservedBandwidth) { | 60 | } else if (subTlv instanceof UnreservedBandwidth) { |
61 | UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) subTlv; | 61 | UnreservedBandwidth unreservedBandwidth = (UnreservedBandwidth) subTlv; |
62 | subTlvBytes.addAll(Bytes.asList(unreservedBandwidth.asBytes())); | 62 | subTlvBytes.addAll(Bytes.asList(unreservedBandwidth.asBytes())); |
63 | + } else if (subTlv instanceof InterfaceIpAddress) { | ||
64 | + InterfaceIpAddress interfaceIpAddress = (InterfaceIpAddress) subTlv; | ||
65 | + subTlvBytes.addAll(Bytes.asList(interfaceIpAddress.asBytes())); | ||
63 | } else { | 66 | } else { |
64 | log.debug("TlvsToBytes::UNKNOWN TLV TYPE ::TlvsToBytes "); | 67 | log.debug("TlvsToBytes::UNKNOWN TLV TYPE ::TlvsToBytes "); |
65 | } | 68 | } | ... | ... |
... | @@ -23,11 +23,30 @@ import java.util.Map; | ... | @@ -23,11 +23,30 @@ import java.util.Map; |
23 | * Representation of sub tlv type. | 23 | * Representation of sub tlv type. |
24 | */ | 24 | */ |
25 | public enum SubTlvType { | 25 | public enum SubTlvType { |
26 | - ADMINISTRATIVEGROUP(9), | 26 | + /** |
27 | - MAXIMUMBANDWIDTH(6), | 27 | + * Represents traffic engineering administrative group TLV. |
28 | - MAXIMUMRESERVABLEBANDWIDTH(7), | 28 | + */ |
29 | - TRAFFICENGINEERINGMETRIC(5), | 29 | + ADMINISTRATIVEGROUP(3), |
30 | - UNRESERVEDBANDWIDTH(8); | 30 | + /** |
31 | + * Represents traffic engineering maximum bandwidth TLV. | ||
32 | + */ | ||
33 | + MAXIMUMBANDWIDTH(9), | ||
34 | + /** | ||
35 | + * Represents traffic engineering maximum reservable bandwidth TLV. | ||
36 | + */ | ||
37 | + MAXIMUMRESERVABLEBANDWIDTH(10), | ||
38 | + /** | ||
39 | + * Represents traffic engineering metric TLV. | ||
40 | + */ | ||
41 | + TRAFFICENGINEERINGMETRIC(18), | ||
42 | + /** | ||
43 | + * Represents traffic engineering interface address TLV. | ||
44 | + */ | ||
45 | + INTERFACEADDRESS(6), | ||
46 | + /** | ||
47 | + * Represents traffic engineering unreserved bandwidth TLV. | ||
48 | + */ | ||
49 | + UNRESERVEDBANDWIDTH(11); | ||
31 | 50 | ||
32 | // Reverse lookup table | 51 | // Reverse lookup table |
33 | private static final Map<Integer, SubTlvType> LOOKUP = new HashMap<>(); | 52 | private static final Map<Integer, SubTlvType> LOOKUP = new HashMap<>(); | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.easymock.EasyMock; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
23 | +import org.junit.Test; | ||
24 | + | ||
25 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
26 | +import static org.hamcrest.Matchers.is; | ||
27 | +import static org.hamcrest.Matchers.notNullValue; | ||
28 | + | ||
29 | +/** | ||
30 | + * Unit test class for AdjacencyStateTlv. | ||
31 | + */ | ||
32 | +public class AdjacencyStateTlvTest { | ||
33 | + | ||
34 | + private final String neighborSystemId = "2929.2929.2929"; | ||
35 | + private final byte[] tlv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
36 | + private AdjacencyStateTlv adjacencyStateTlv; | ||
37 | + private TlvHeader tlvHeader; | ||
38 | + private int result; | ||
39 | + private byte result2; | ||
40 | + private String result1; | ||
41 | + private ChannelBuffer channelBuffer; | ||
42 | + private byte[] result3; | ||
43 | + | ||
44 | + @Before | ||
45 | + public void setUp() throws Exception { | ||
46 | + tlvHeader = new TlvHeader(); | ||
47 | + adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader); | ||
48 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
49 | + } | ||
50 | + | ||
51 | + @After | ||
52 | + public void tearDown() throws Exception { | ||
53 | + tlvHeader = null; | ||
54 | + adjacencyStateTlv = null; | ||
55 | + channelBuffer = null; | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * Tests localCircuitId() getter method. | ||
60 | + */ | ||
61 | + @Test | ||
62 | + public void testLocalCircuitId() throws Exception { | ||
63 | + adjacencyStateTlv.setLocalCircuitId(1); | ||
64 | + result = adjacencyStateTlv.localCircuitId(); | ||
65 | + assertThat(result, is(1)); | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * Tests localCircuitId() setter method. | ||
70 | + */ | ||
71 | + @Test | ||
72 | + public void testSetLocalCircuitId() throws Exception { | ||
73 | + adjacencyStateTlv.setLocalCircuitId(1); | ||
74 | + result = adjacencyStateTlv.localCircuitId(); | ||
75 | + assertThat(result, is(1)); | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Tests neighborSystemId() getter method. | ||
80 | + */ | ||
81 | + @Test | ||
82 | + public void testNeighborSystemId() throws Exception { | ||
83 | + adjacencyStateTlv.setNeighborSystemId(neighborSystemId); | ||
84 | + result1 = adjacencyStateTlv.neighborSystemId(); | ||
85 | + assertThat(result1, is(neighborSystemId)); | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * Tests neighborSystemId() setter method. | ||
90 | + */ | ||
91 | + @Test | ||
92 | + public void testSetNeighborSystemId() throws Exception { | ||
93 | + adjacencyStateTlv.setNeighborSystemId(neighborSystemId); | ||
94 | + result1 = adjacencyStateTlv.neighborSystemId(); | ||
95 | + assertThat(result1, is(neighborSystemId)); | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * Tests neighborLocalCircuitId() getter method. | ||
100 | + */ | ||
101 | + @Test | ||
102 | + public void testNeighborLocalCircuitId() throws Exception { | ||
103 | + adjacencyStateTlv.setNeighborLocalCircuitId(1); | ||
104 | + result = adjacencyStateTlv.neighborLocalCircuitId(); | ||
105 | + assertThat(result, is(1)); | ||
106 | + } | ||
107 | + | ||
108 | + /** | ||
109 | + * Tests neighborLocalCircuitId() setter method. | ||
110 | + */ | ||
111 | + @Test | ||
112 | + public void testSetNeighborLocalCircuitId() throws Exception { | ||
113 | + adjacencyStateTlv.setNeighborLocalCircuitId(1); | ||
114 | + result = adjacencyStateTlv.neighborLocalCircuitId(); | ||
115 | + assertThat(result, is(1)); | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * Tests adjacencyType() getter method. | ||
120 | + */ | ||
121 | + @Test | ||
122 | + public void testAdjacencyType() throws Exception { | ||
123 | + adjacencyStateTlv.setAdjacencyType((byte) 1); | ||
124 | + result2 = adjacencyStateTlv.adjacencyType(); | ||
125 | + assertThat(result2, is((byte) 1)); | ||
126 | + } | ||
127 | + | ||
128 | + /** | ||
129 | + * Tests adjacencyType() setter method. | ||
130 | + */ | ||
131 | + @Test | ||
132 | + public void testSetAdjacencyType() throws Exception { | ||
133 | + adjacencyStateTlv.setAdjacencyType((byte) 1); | ||
134 | + result2 = adjacencyStateTlv.adjacencyType(); | ||
135 | + assertThat(result2, is((byte) 1)); | ||
136 | + } | ||
137 | + | ||
138 | + /** | ||
139 | + * Tests readFrom() method. | ||
140 | + */ | ||
141 | + @Test | ||
142 | + public void testReadFrom() throws Exception { | ||
143 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
144 | + adjacencyStateTlv.readFrom(channelBuffer); | ||
145 | + assertThat(adjacencyStateTlv.adjacencyType(), is((byte) 0)); | ||
146 | + } | ||
147 | + | ||
148 | + /** | ||
149 | + * Tests asBytes() method. | ||
150 | + */ | ||
151 | + @Test | ||
152 | + public void testAsBytes() throws Exception { | ||
153 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
154 | + adjacencyStateTlv.readFrom(channelBuffer); | ||
155 | + result3 = adjacencyStateTlv.asBytes(); | ||
156 | + assertThat(result3, is(notNullValue())); | ||
157 | + } | ||
158 | + | ||
159 | + /** | ||
160 | + * Tests toString() method. | ||
161 | + */ | ||
162 | + @Test | ||
163 | + public void testToString() throws Exception { | ||
164 | + assertThat(adjacencyStateTlv.toString(), is(notNullValue())); | ||
165 | + } | ||
166 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/AreaAddressTlvTest.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.easymock.EasyMock; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
23 | +import org.junit.Test; | ||
24 | + | ||
25 | +import java.util.List; | ||
26 | + | ||
27 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
28 | +import static org.hamcrest.Matchers.is; | ||
29 | +import static org.hamcrest.Matchers.notNullValue; | ||
30 | + | ||
31 | +/** | ||
32 | + * Unit test class for AreaAddressTlv. | ||
33 | + */ | ||
34 | +public class AreaAddressTlvTest { | ||
35 | + | ||
36 | + private final String areaAddres = "490001"; | ||
37 | + private final byte[] tlv = {1, 49}; | ||
38 | + private AreaAddressTlv areaAddressTlv; | ||
39 | + private TlvHeader tlvHeader; | ||
40 | + private List<String> result; | ||
41 | + private ChannelBuffer channelBuffer; | ||
42 | + private byte[] result1; | ||
43 | + | ||
44 | + @Before | ||
45 | + public void setUp() throws Exception { | ||
46 | + tlvHeader = new TlvHeader(); | ||
47 | + areaAddressTlv = new AreaAddressTlv(tlvHeader); | ||
48 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
49 | + } | ||
50 | + | ||
51 | + @After | ||
52 | + public void tearDown() throws Exception { | ||
53 | + tlvHeader = null; | ||
54 | + areaAddressTlv = null; | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * Tests addAddress() method. | ||
59 | + */ | ||
60 | + @Test | ||
61 | + public void testAddAddress() throws Exception { | ||
62 | + areaAddressTlv.addAddress(areaAddres); | ||
63 | + result = areaAddressTlv.areaAddress(); | ||
64 | + assertThat(result.size(), is(1)); | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Tests areaAddress() setter method. | ||
69 | + */ | ||
70 | + @Test | ||
71 | + public void testSetAreaAddress() throws Exception { | ||
72 | + areaAddressTlv.addAddress(areaAddres); | ||
73 | + result = areaAddressTlv.areaAddress(); | ||
74 | + assertThat(result.size(), is(1)); | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * Tests readFrom() method. | ||
79 | + */ | ||
80 | + @Test | ||
81 | + public void testReadFrom() throws Exception { | ||
82 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
83 | + areaAddressTlv.readFrom(channelBuffer); | ||
84 | + assertThat(areaAddressTlv.areaAddress().size(), is(1)); | ||
85 | + } | ||
86 | + | ||
87 | + /** | ||
88 | + * Tests asBytes() method. | ||
89 | + */ | ||
90 | + @Test | ||
91 | + public void testAsBytes() throws Exception { | ||
92 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
93 | + areaAddressTlv.readFrom(channelBuffer); | ||
94 | + result1 = areaAddressTlv.asBytes(); | ||
95 | + assertThat(result1, is(notNullValue())); | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * Tests toString() method. | ||
100 | + */ | ||
101 | + @Test | ||
102 | + public void testToString() throws Exception { | ||
103 | + assertThat(areaAddressTlv.toString(), is(notNullValue())); | ||
104 | + } | ||
105 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/HostNameTlvTest.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.easymock.EasyMock; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
23 | +import org.junit.Test; | ||
24 | + | ||
25 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
26 | +import static org.hamcrest.Matchers.is; | ||
27 | +import static org.hamcrest.Matchers.notNullValue; | ||
28 | + | ||
29 | +/** | ||
30 | + * Unit test class for HostNameTlv. | ||
31 | + */ | ||
32 | +public class HostNameTlvTest { | ||
33 | + private final String hostName = "TEST"; | ||
34 | + private final byte[] tlv = hostName.getBytes(); | ||
35 | + private HostNameTlv hostNameTlv; | ||
36 | + private TlvHeader tlvHeader; | ||
37 | + private String result; | ||
38 | + private ChannelBuffer channelBuffer; | ||
39 | + private byte[] result1; | ||
40 | + | ||
41 | + @Before | ||
42 | + public void setUp() throws Exception { | ||
43 | + tlvHeader = new TlvHeader(); | ||
44 | + tlvHeader.setTlvLength(tlv.length); | ||
45 | + hostNameTlv = new HostNameTlv(tlvHeader); | ||
46 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
47 | + } | ||
48 | + | ||
49 | + @After | ||
50 | + public void tearDown() throws Exception { | ||
51 | + tlvHeader = null; | ||
52 | + hostNameTlv = null; | ||
53 | + } | ||
54 | + | ||
55 | + /** | ||
56 | + * Tests hostName() getter method. | ||
57 | + */ | ||
58 | + @Test | ||
59 | + public void testHostName() throws Exception { | ||
60 | + hostNameTlv.setHostName(hostName); | ||
61 | + result = hostNameTlv.hostName(); | ||
62 | + assertThat(result, is(hostName)); | ||
63 | + } | ||
64 | + | ||
65 | + /** | ||
66 | + * Tests hostName() setter method. | ||
67 | + */ | ||
68 | + @Test | ||
69 | + public void testSetHostName() throws Exception { | ||
70 | + hostNameTlv.setHostName(hostName); | ||
71 | + result = hostNameTlv.hostName(); | ||
72 | + assertThat(result, is(hostName)); | ||
73 | + } | ||
74 | + | ||
75 | + /** | ||
76 | + * Tests readFrom() method. | ||
77 | + */ | ||
78 | + @Test | ||
79 | + public void testReadFrom() throws Exception { | ||
80 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
81 | + hostNameTlv.readFrom(channelBuffer); | ||
82 | + assertThat(hostNameTlv.hostName(), is(hostName)); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Tests asBytes() method. | ||
87 | + */ | ||
88 | + @Test | ||
89 | + public void testAsBytes() throws Exception { | ||
90 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
91 | + hostNameTlv.readFrom(channelBuffer); | ||
92 | + result1 = hostNameTlv.asBytes(); | ||
93 | + assertThat(result1, is(notNullValue())); | ||
94 | + } | ||
95 | + | ||
96 | + /** | ||
97 | + * Tests toString() method. | ||
98 | + */ | ||
99 | + @Test | ||
100 | + public void testToString() throws Exception { | ||
101 | + assertThat(hostNameTlv.toString(), is(notNullValue())); | ||
102 | + } | ||
103 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.easymock.EasyMock; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
23 | +import org.junit.Test; | ||
24 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.AdministrativeGroup; | ||
25 | +import org.onosproject.isis.io.isispacket.tlv.subtlv.TrafficEngineeringSubTlv; | ||
26 | + | ||
27 | +import static org.hamcrest.CoreMatchers.is; | ||
28 | +import static org.hamcrest.CoreMatchers.notNullValue; | ||
29 | +import static org.junit.Assert.assertThat; | ||
30 | + | ||
31 | +/** | ||
32 | + * Unit test class for IP ExtendedReachabilityTlv. | ||
33 | + */ | ||
34 | +public class IpExtendedReachabilityTlvTest { | ||
35 | + private final String prefix = "00"; | ||
36 | + private final byte[] tlv = {0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
37 | + private final byte[] tlv1 = {0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
38 | + private final byte[] tlv2 = {0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
39 | + private final byte[] tlv3 = {0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
40 | + private TlvHeader tlvHeader; | ||
41 | + private IpExtendedReachabilityTlv ipExtendedReachabilityTlv; | ||
42 | + private String result; | ||
43 | + private boolean result1; | ||
44 | + private int result2; | ||
45 | + private TrafficEngineeringSubTlv trafficEngineeringSubTlv; | ||
46 | + private byte result4; | ||
47 | + private ChannelBuffer channelBuffer; | ||
48 | + private byte[] result3; | ||
49 | + | ||
50 | + @Before | ||
51 | + public void setUp() throws Exception { | ||
52 | + tlvHeader = new TlvHeader(); | ||
53 | + ipExtendedReachabilityTlv = new IpExtendedReachabilityTlv(tlvHeader); | ||
54 | + trafficEngineeringSubTlv = new AdministrativeGroup(tlvHeader); | ||
55 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
56 | + } | ||
57 | + | ||
58 | + @After | ||
59 | + public void tearDown() throws Exception { | ||
60 | + tlvHeader = null; | ||
61 | + ipExtendedReachabilityTlv = null; | ||
62 | + | ||
63 | + } | ||
64 | + | ||
65 | + /** | ||
66 | + * Tests prefix() getter method. | ||
67 | + */ | ||
68 | + @Test | ||
69 | + public void testPrefix() throws Exception { | ||
70 | + ipExtendedReachabilityTlv.setPrefix(prefix); | ||
71 | + result = ipExtendedReachabilityTlv.prefix(); | ||
72 | + assertThat(result, is("00")); | ||
73 | + } | ||
74 | + | ||
75 | + /** | ||
76 | + * Tests prefix() setter method. | ||
77 | + */ | ||
78 | + @Test | ||
79 | + public void testSetPrefix() throws Exception { | ||
80 | + ipExtendedReachabilityTlv.setPrefix(prefix); | ||
81 | + result = ipExtendedReachabilityTlv.prefix(); | ||
82 | + assertThat(result, is("00")); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Tests isDown() getter method. | ||
87 | + */ | ||
88 | + | ||
89 | + @Test | ||
90 | + public void testIsDown() throws Exception { | ||
91 | + ipExtendedReachabilityTlv.setDown(true); | ||
92 | + result1 = ipExtendedReachabilityTlv.isDown(); | ||
93 | + assertThat(result1, is(true)); | ||
94 | + } | ||
95 | + | ||
96 | + /** | ||
97 | + * Tests isDown() setter method. | ||
98 | + */ | ||
99 | + @Test | ||
100 | + public void testSetDown() throws Exception { | ||
101 | + ipExtendedReachabilityTlv.setDown(true); | ||
102 | + result1 = ipExtendedReachabilityTlv.isDown(); | ||
103 | + assertThat(result1, is(true)); | ||
104 | + } | ||
105 | + | ||
106 | + /** | ||
107 | + * Tests isSubTlvPresence() getter method. | ||
108 | + */ | ||
109 | + @Test | ||
110 | + public void testIsSubTlvPresence() throws Exception { | ||
111 | + ipExtendedReachabilityTlv.setSubTlvPresence(true); | ||
112 | + result1 = ipExtendedReachabilityTlv.isSubTlvPresence(); | ||
113 | + assertThat(result1, is(true)); | ||
114 | + } | ||
115 | + | ||
116 | + /** | ||
117 | + * Tests isSubTlvPresence() setter method. | ||
118 | + */ | ||
119 | + @Test | ||
120 | + public void testSetSubTlvPresence() throws Exception { | ||
121 | + ipExtendedReachabilityTlv.setSubTlvPresence(true); | ||
122 | + result1 = ipExtendedReachabilityTlv.isSubTlvPresence(); | ||
123 | + assertThat(result1, is(true)); | ||
124 | + } | ||
125 | + | ||
126 | + /** | ||
127 | + * Tests prefixLength() getter method. | ||
128 | + */ | ||
129 | + @Test | ||
130 | + public void testPrefixLength() throws Exception { | ||
131 | + ipExtendedReachabilityTlv.setPrefixLength(10); | ||
132 | + result2 = ipExtendedReachabilityTlv.prefixLength(); | ||
133 | + assertThat(result2, is(10)); | ||
134 | + | ||
135 | + } | ||
136 | + | ||
137 | + /** | ||
138 | + * Tests prefixLength() setter method. | ||
139 | + */ | ||
140 | + @Test | ||
141 | + public void testSetPrefixLength() throws Exception { | ||
142 | + ipExtendedReachabilityTlv.setPrefixLength(10); | ||
143 | + result2 = ipExtendedReachabilityTlv.prefixLength(); | ||
144 | + assertThat(result2, is(10)); | ||
145 | + } | ||
146 | + | ||
147 | + /** | ||
148 | + * Tests addNeighbor() method. | ||
149 | + */ | ||
150 | + @Test | ||
151 | + public void testAddSubTlv() throws Exception { | ||
152 | + ipExtendedReachabilityTlv.addSubTlv(trafficEngineeringSubTlv); | ||
153 | + assertThat(ipExtendedReachabilityTlv, is(notNullValue())); | ||
154 | + | ||
155 | + } | ||
156 | + | ||
157 | + /** | ||
158 | + * Tests subTlvLength() getter method. | ||
159 | + */ | ||
160 | + @Test | ||
161 | + public void testSubTlvLength() throws Exception { | ||
162 | + ipExtendedReachabilityTlv.setSubTlvLength((byte) 10); | ||
163 | + result4 = ipExtendedReachabilityTlv.subTlvLength(); | ||
164 | + assertThat(result4, is((byte) 10)); | ||
165 | + } | ||
166 | + | ||
167 | + /** | ||
168 | + * Tests subTlvLength() setter method. | ||
169 | + */ | ||
170 | + @Test | ||
171 | + public void testSetSubTlvLength() throws Exception { | ||
172 | + ipExtendedReachabilityTlv.setSubTlvLength((byte) 10); | ||
173 | + result4 = ipExtendedReachabilityTlv.subTlvLength(); | ||
174 | + assertThat(result4, is((byte) 10)); | ||
175 | + } | ||
176 | + | ||
177 | + /** | ||
178 | + * Tests metric() getter method. | ||
179 | + */ | ||
180 | + @Test | ||
181 | + public void testMetric() throws Exception { | ||
182 | + ipExtendedReachabilityTlv.setMetric(10); | ||
183 | + result2 = ipExtendedReachabilityTlv.metric(); | ||
184 | + assertThat(result2, is(10)); | ||
185 | + } | ||
186 | + | ||
187 | + /** | ||
188 | + * Tests metric() setter method. | ||
189 | + */ | ||
190 | + @Test | ||
191 | + public void testSetMetric() throws Exception { | ||
192 | + ipExtendedReachabilityTlv.setMetric(10); | ||
193 | + result2 = ipExtendedReachabilityTlv.metric(); | ||
194 | + assertThat(result2, is(10)); | ||
195 | + } | ||
196 | + | ||
197 | + /** | ||
198 | + * Tests readFrom() method. | ||
199 | + */ | ||
200 | + @Test | ||
201 | + public void testReadFrom() throws Exception { | ||
202 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
203 | + ipExtendedReachabilityTlv.readFrom(channelBuffer); | ||
204 | + assertThat(ipExtendedReachabilityTlv.metric(), is(0)); | ||
205 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv1); | ||
206 | + ipExtendedReachabilityTlv.readFrom(channelBuffer); | ||
207 | + assertThat(ipExtendedReachabilityTlv.metric(), is(0)); | ||
208 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv2); | ||
209 | + ipExtendedReachabilityTlv.readFrom(channelBuffer); | ||
210 | + assertThat(ipExtendedReachabilityTlv.metric(), is(0)); | ||
211 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv3); | ||
212 | + ipExtendedReachabilityTlv.readFrom(channelBuffer); | ||
213 | + assertThat(ipExtendedReachabilityTlv.metric(), is(0)); | ||
214 | + } | ||
215 | + | ||
216 | + /** | ||
217 | + * Tests asBytes() method. | ||
218 | + */ | ||
219 | + @Test | ||
220 | + public void testAsBytes() throws Exception { | ||
221 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
222 | + ipExtendedReachabilityTlv.readFrom(channelBuffer); | ||
223 | + ipExtendedReachabilityTlv.setPrefix(prefix); | ||
224 | + result3 = ipExtendedReachabilityTlv.asBytes(); | ||
225 | + assertThat(result3, is(notNullValue())); | ||
226 | + } | ||
227 | + | ||
228 | + /** | ||
229 | + * Tests toString() method. | ||
230 | + */ | ||
231 | + @Test | ||
232 | + public void testToString() throws Exception { | ||
233 | + assertThat(ipExtendedReachabilityTlv.toString(), is(notNullValue())); | ||
234 | + } | ||
235 | + | ||
236 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.easymock.EasyMock; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
23 | +import org.junit.Test; | ||
24 | +import org.onlab.packet.Ip4Address; | ||
25 | + | ||
26 | +import java.util.List; | ||
27 | + | ||
28 | +import static org.hamcrest.CoreMatchers.is; | ||
29 | +import static org.hamcrest.CoreMatchers.notNullValue; | ||
30 | +import static org.junit.Assert.assertThat; | ||
31 | + | ||
32 | +/** | ||
33 | + * Unit test class for IP InterfaceAddressTlv. | ||
34 | + */ | ||
35 | +public class IpInterfaceAddressTlvTest { | ||
36 | + private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10"); | ||
37 | + private final byte[] tlv = {0, 0, 0, 0}; | ||
38 | + private TlvHeader tlvHeader; | ||
39 | + private IpInterfaceAddressTlv ipInterfaceAddressTlv; | ||
40 | + private List<Ip4Address> resultList; | ||
41 | + private byte[] result; | ||
42 | + private ChannelBuffer channelBuffer; | ||
43 | + | ||
44 | + @Before | ||
45 | + public void setUp() throws Exception { | ||
46 | + tlvHeader = new TlvHeader(); | ||
47 | + ipInterfaceAddressTlv = new IpInterfaceAddressTlv(tlvHeader); | ||
48 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
49 | + } | ||
50 | + | ||
51 | + @After | ||
52 | + public void tearDown() throws Exception { | ||
53 | + tlvHeader = null; | ||
54 | + ipInterfaceAddressTlv = null; | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * Tests addInterfaceAddress() method. | ||
59 | + */ | ||
60 | + @Test | ||
61 | + public void testAddInterfaceAddres() throws Exception { | ||
62 | + ipInterfaceAddressTlv.addInterfaceAddres(ip4Address); | ||
63 | + resultList = ipInterfaceAddressTlv.interfaceAddress(); | ||
64 | + assertThat(resultList.size(), is(1)); | ||
65 | + | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * Tests interfaceAddress() getter method. | ||
70 | + */ | ||
71 | + @Test | ||
72 | + public void testInterfaceAddress() throws Exception { | ||
73 | + ipInterfaceAddressTlv.addInterfaceAddres(ip4Address); | ||
74 | + resultList = ipInterfaceAddressTlv.interfaceAddress(); | ||
75 | + assertThat(resultList.size(), is(1)); | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Tests readFrom() method. | ||
80 | + */ | ||
81 | + @Test | ||
82 | + public void testReadFrom() throws Exception { | ||
83 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
84 | + ipInterfaceAddressTlv.readFrom(channelBuffer); | ||
85 | + assertThat(ipInterfaceAddressTlv.interfaceAddress().size(), is(1)); | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * Tests asBytes() method. | ||
90 | + */ | ||
91 | + @Test | ||
92 | + public void testAsBytes() throws Exception { | ||
93 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
94 | + ipInterfaceAddressTlv.readFrom(channelBuffer); | ||
95 | + result = ipInterfaceAddressTlv.asBytes(); | ||
96 | + assertThat(result, is(notNullValue())); | ||
97 | + } | ||
98 | + | ||
99 | + /** | ||
100 | + * Tests toString() method. | ||
101 | + */ | ||
102 | + @Test | ||
103 | + public void testToString() throws Exception { | ||
104 | + assertThat(ipInterfaceAddressTlv.toString(), is(notNullValue())); | ||
105 | + } | ||
106 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.easymock.EasyMock; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
23 | +import org.junit.Test; | ||
24 | + | ||
25 | +import static org.hamcrest.CoreMatchers.is; | ||
26 | +import static org.hamcrest.CoreMatchers.notNullValue; | ||
27 | +import static org.junit.Assert.assertThat; | ||
28 | + | ||
29 | +/** | ||
30 | + * Unit test class for IP InternalReachabilityTlv. | ||
31 | + */ | ||
32 | +public class IpInternalReachabilityTlvTest { | ||
33 | + private final byte[] tlv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
34 | + private TlvHeader tlvHeader; | ||
35 | + private IpInternalReachabilityTlv ipInternalReachabilityTlv; | ||
36 | + private MetricOfInternalReachability metricOfInternalReachability; | ||
37 | + private byte[] result; | ||
38 | + private ChannelBuffer channelBuffer; | ||
39 | + | ||
40 | + @Before | ||
41 | + public void setUp() throws Exception { | ||
42 | + tlvHeader = new TlvHeader(); | ||
43 | + ipInternalReachabilityTlv = new IpInternalReachabilityTlv(tlvHeader); | ||
44 | + metricOfInternalReachability = new MetricOfInternalReachability(); | ||
45 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
46 | + } | ||
47 | + | ||
48 | + @After | ||
49 | + public void tearDown() throws Exception { | ||
50 | + tlvHeader = null; | ||
51 | + ipInternalReachabilityTlv = null; | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * Tests addInternalReachabilityMetric() method. | ||
56 | + */ | ||
57 | + @Test | ||
58 | + public void testAddInternalReachabilityMetric() throws Exception { | ||
59 | + ipInternalReachabilityTlv.addInternalReachabilityMetric(metricOfInternalReachability); | ||
60 | + assertThat(ipInternalReachabilityTlv, is(notNullValue())); | ||
61 | + | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * Tests readFrom() method. | ||
66 | + */ | ||
67 | + @Test | ||
68 | + public void testReadFrom() throws Exception { | ||
69 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
70 | + ipInternalReachabilityTlv.readFrom(channelBuffer); | ||
71 | + assertThat(ipInternalReachabilityTlv, is(notNullValue())); | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * Tests asBytes() method. | ||
76 | + */ | ||
77 | + @Test | ||
78 | + public void testAsBytes() throws Exception { | ||
79 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
80 | + ipInternalReachabilityTlv.readFrom(channelBuffer); | ||
81 | + result = ipInternalReachabilityTlv.asBytes(); | ||
82 | + assertThat(result, is(notNullValue())); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Tests toString() method. | ||
87 | + */ | ||
88 | + @Test | ||
89 | + public void testToString() throws Exception { | ||
90 | + assertThat(ipInternalReachabilityTlv.toString(), is(notNullValue())); | ||
91 | + } | ||
92 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.easymock.EasyMock; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
23 | +import org.junit.Test; | ||
24 | + | ||
25 | +import static org.hamcrest.CoreMatchers.is; | ||
26 | +import static org.hamcrest.CoreMatchers.notNullValue; | ||
27 | +import static org.junit.Assert.assertThat; | ||
28 | + | ||
29 | +/** | ||
30 | + * Unit test class for IS ReachabilityTlv. | ||
31 | + */ | ||
32 | +public class IsReachabilityTlvTest { | ||
33 | + private final byte[] tlv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
34 | + private TlvHeader tlvHeader; | ||
35 | + private IsReachabilityTlv isReachabilityTlv; | ||
36 | + private MetricsOfReachability metricsOfReachability; | ||
37 | + private int resultInt; | ||
38 | + private ChannelBuffer channelBuffer; | ||
39 | + private byte[] result; | ||
40 | + | ||
41 | + @Before | ||
42 | + public void setUp() throws Exception { | ||
43 | + tlvHeader = new TlvHeader(); | ||
44 | + isReachabilityTlv = new IsReachabilityTlv(tlvHeader); | ||
45 | + metricsOfReachability = new MetricsOfReachability(); | ||
46 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
47 | + } | ||
48 | + | ||
49 | + @After | ||
50 | + public void tearDown() throws Exception { | ||
51 | + tlvHeader = null; | ||
52 | + isReachabilityTlv = null; | ||
53 | + } | ||
54 | + | ||
55 | + /** | ||
56 | + * Tests reserved() getter method. | ||
57 | + */ | ||
58 | + @Test | ||
59 | + public void testReserved() throws Exception { | ||
60 | + isReachabilityTlv.setReserved(10); | ||
61 | + resultInt = isReachabilityTlv.reserved(); | ||
62 | + assertThat(resultInt, is(10)); | ||
63 | + } | ||
64 | + | ||
65 | + /** | ||
66 | + * Tests reserved() setter method. | ||
67 | + */ | ||
68 | + @Test | ||
69 | + public void testSetReserved() throws Exception { | ||
70 | + isReachabilityTlv.setReserved(10); | ||
71 | + resultInt = isReachabilityTlv.reserved(); | ||
72 | + assertThat(resultInt, is(10)); | ||
73 | + } | ||
74 | + | ||
75 | + /** | ||
76 | + * Tests addMeticsOfReachability() getter method. | ||
77 | + */ | ||
78 | + @Test | ||
79 | + public void testAddMeticsOfReachability() throws Exception { | ||
80 | + isReachabilityTlv.addMeticsOfReachability(metricsOfReachability); | ||
81 | + assertThat(isReachabilityTlv, is(notNullValue())); | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * Tests readFrom() method. | ||
86 | + */ | ||
87 | + @Test | ||
88 | + public void testReadFrom() throws Exception { | ||
89 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
90 | + isReachabilityTlv.readFrom(channelBuffer); | ||
91 | + assertThat(isReachabilityTlv, is(notNullValue())); | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Tests asBytes() method. | ||
96 | + */ | ||
97 | + @Test | ||
98 | + public void testAsBytes() throws Exception { | ||
99 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
100 | + isReachabilityTlv.readFrom(channelBuffer); | ||
101 | + result = isReachabilityTlv.asBytes(); | ||
102 | + assertThat(result, is(notNullValue())); | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * Tests toString() method. | ||
107 | + */ | ||
108 | + @Test | ||
109 | + public void testToString() throws Exception { | ||
110 | + assertThat(isReachabilityTlv.toString(), is(notNullValue())); | ||
111 | + } | ||
112 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/IsisNeighborTlvTest.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.easymock.EasyMock; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
23 | +import org.junit.Test; | ||
24 | +import org.onlab.packet.MacAddress; | ||
25 | + | ||
26 | +import java.util.List; | ||
27 | + | ||
28 | +import static org.hamcrest.CoreMatchers.is; | ||
29 | +import static org.hamcrest.CoreMatchers.notNullValue; | ||
30 | +import static org.junit.Assert.assertThat; | ||
31 | + | ||
32 | +/** | ||
33 | + * Unit test class for ISIS NeighborTLV. | ||
34 | + */ | ||
35 | +public class IsisNeighborTlvTest { | ||
36 | + private final MacAddress macAddress = MacAddress.valueOf("a4:23:05:00:00:00"); | ||
37 | + private final byte[] tlv = {0, 0, 0, 0, 0, 0}; | ||
38 | + private TlvHeader tlvHeader; | ||
39 | + private IsisNeighborTlv isisNeighborTlv; | ||
40 | + private List<MacAddress> resultList; | ||
41 | + private ChannelBuffer channelBuffer; | ||
42 | + private byte[] result; | ||
43 | + | ||
44 | + @Before | ||
45 | + public void setUp() throws Exception { | ||
46 | + tlvHeader = new TlvHeader(); | ||
47 | + isisNeighborTlv = new IsisNeighborTlv(tlvHeader); | ||
48 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
49 | + } | ||
50 | + | ||
51 | + @After | ||
52 | + public void tearDown() throws Exception { | ||
53 | + tlvHeader = null; | ||
54 | + isisNeighborTlv = null; | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * Tests addNeighbor() getter method. | ||
59 | + */ | ||
60 | + @Test | ||
61 | + public void testAddNeighbor() throws Exception { | ||
62 | + isisNeighborTlv.addNeighbor(macAddress); | ||
63 | + resultList = isisNeighborTlv.neighbor(); | ||
64 | + assertThat(resultList.size(), is(1)); | ||
65 | + | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * Tests neighbor() setter method. | ||
70 | + */ | ||
71 | + @Test | ||
72 | + public void testNeighbor() throws Exception { | ||
73 | + isisNeighborTlv.addNeighbor(macAddress); | ||
74 | + resultList = isisNeighborTlv.neighbor(); | ||
75 | + assertThat(resultList.size(), is(1)); | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Tests readFrom() method. | ||
80 | + */ | ||
81 | + @Test | ||
82 | + public void testReadFrom() throws Exception { | ||
83 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
84 | + isisNeighborTlv.readFrom(channelBuffer); | ||
85 | + assertThat(isisNeighborTlv.neighbor().size(), is(1)); | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * Tests asBytes() getter method. | ||
90 | + */ | ||
91 | + @Test | ||
92 | + public void testAsBytes() throws Exception { | ||
93 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
94 | + isisNeighborTlv.readFrom(channelBuffer); | ||
95 | + result = isisNeighborTlv.asBytes(); | ||
96 | + assertThat(result, is(notNullValue())); | ||
97 | + } | ||
98 | + | ||
99 | + /** | ||
100 | + * Tests toString() method. | ||
101 | + */ | ||
102 | + @Test | ||
103 | + public void testToString() throws Exception { | ||
104 | + assertThat(isisNeighborTlv.toString(), is(notNullValue())); | ||
105 | + } | ||
106 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/LspEntriesTlvTest.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
18 | + | ||
19 | +import org.easymock.EasyMock; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
21 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
22 | +import org.junit.After; | ||
23 | +import org.junit.Before; | ||
24 | +import org.junit.Test; | ||
25 | + | ||
26 | +import java.util.ArrayList; | ||
27 | +import java.util.List; | ||
28 | + | ||
29 | +import static org.hamcrest.CoreMatchers.is; | ||
30 | +import static org.hamcrest.CoreMatchers.notNullValue; | ||
31 | +import static org.junit.Assert.assertThat; | ||
32 | + | ||
33 | +/** | ||
34 | + * Unit test class for LspEntriesTlv. | ||
35 | + */ | ||
36 | +public class LspEntriesTlvTest { | ||
37 | + | ||
38 | + private final byte[] entry = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
39 | + private LspEntriesTlv lspEntriesTlv; | ||
40 | + private TlvHeader tlvHeader; | ||
41 | + private List<LspEntry> lspEntries = new ArrayList(); | ||
42 | + private ChannelBuffer channelBuffer; | ||
43 | + | ||
44 | + @Before | ||
45 | + public void setUp() throws Exception { | ||
46 | + tlvHeader = new TlvHeader(); | ||
47 | + lspEntriesTlv = new LspEntriesTlv(tlvHeader); | ||
48 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
49 | + } | ||
50 | + | ||
51 | + @After | ||
52 | + public void tearDown() throws Exception { | ||
53 | + tlvHeader = null; | ||
54 | + lspEntriesTlv = null; | ||
55 | + lspEntries.clear(); | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * Tests lspEntry() getter method. | ||
60 | + */ | ||
61 | + @Test | ||
62 | + public void testLspEntry() throws Exception { | ||
63 | + lspEntriesTlv.addLspEntry(new LspEntry()); | ||
64 | + assertThat(lspEntriesTlv.lspEntry().size(), is(1)); | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Tests lspEntry() add method. | ||
69 | + */ | ||
70 | + @Test | ||
71 | + public void testAddLspEntry() throws Exception { | ||
72 | + lspEntriesTlv.addLspEntry(new LspEntry()); | ||
73 | + assertThat(lspEntriesTlv.lspEntry().size(), is(1)); | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * Tests readFrom() method. | ||
78 | + */ | ||
79 | + @Test | ||
80 | + public void testReadFrom() throws Exception { | ||
81 | + channelBuffer = ChannelBuffers.copiedBuffer(entry); | ||
82 | + lspEntriesTlv.readFrom(channelBuffer); | ||
83 | + lspEntries = lspEntriesTlv.lspEntry(); | ||
84 | + assertThat(lspEntriesTlv.lspEntry().size(), is(1)); | ||
85 | + } | ||
86 | + | ||
87 | + /** | ||
88 | + * Tests asBytes() method. | ||
89 | + */ | ||
90 | + @Test | ||
91 | + public void testAsBytes() throws Exception { | ||
92 | + channelBuffer = ChannelBuffers.copiedBuffer(entry); | ||
93 | + lspEntriesTlv.readFrom(channelBuffer); | ||
94 | + lspEntriesTlv.asBytes(); | ||
95 | + } | ||
96 | + | ||
97 | + /** | ||
98 | + * Tests toString() method. | ||
99 | + */ | ||
100 | + @Test | ||
101 | + public void testToString() throws Exception { | ||
102 | + assertThat(lspEntriesTlv.toString(), is(notNullValue())); | ||
103 | + } | ||
104 | + | ||
105 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/LspEntryTest.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.easymock.EasyMock; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
23 | +import org.junit.Test; | ||
24 | + | ||
25 | +import static org.hamcrest.CoreMatchers.is; | ||
26 | +import static org.hamcrest.CoreMatchers.notNullValue; | ||
27 | +import static org.junit.Assert.assertThat; | ||
28 | + | ||
29 | +/** | ||
30 | + * Unit test class for LspEntry. | ||
31 | + */ | ||
32 | +public class LspEntryTest { | ||
33 | + | ||
34 | + private final String lspId = "10.10.10.10"; | ||
35 | + private final byte[] entry = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
36 | + private LspEntry lspEntry; | ||
37 | + private int result; | ||
38 | + private String result2; | ||
39 | + private ChannelBuffer channelBuffer; | ||
40 | + private byte[] result3; | ||
41 | + | ||
42 | + @Before | ||
43 | + public void setUp() throws Exception { | ||
44 | + lspEntry = new LspEntry(); | ||
45 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
46 | + } | ||
47 | + | ||
48 | + @After | ||
49 | + public void tearDown() throws Exception { | ||
50 | + lspEntry = null; | ||
51 | + channelBuffer = null; | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * Tests lspSequenceNumber() getter method. | ||
56 | + */ | ||
57 | + @Test | ||
58 | + public void testLspSequenceNumber() throws Exception { | ||
59 | + lspEntry.setLspSequenceNumber(0); | ||
60 | + result = lspEntry.lspSequenceNumber(); | ||
61 | + assertThat(result, is(0)); | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * Tests lspSequenceNumber() setter method. | ||
66 | + */ | ||
67 | + @Test | ||
68 | + public void testSetLspSequenceNumber() throws Exception { | ||
69 | + lspEntry.setLspSequenceNumber(0); | ||
70 | + result = lspEntry.lspSequenceNumber(); | ||
71 | + assertThat(result, is(0)); | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * Tests lspChecksum() getter method. | ||
76 | + */ | ||
77 | + @Test | ||
78 | + public void testLspChecksum() throws Exception { | ||
79 | + lspEntry.setLspChecksum(0); | ||
80 | + result = lspEntry.lspChecksum(); | ||
81 | + assertThat(result, is(0)); | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * Tests lspChecksum() setter method. | ||
86 | + */ | ||
87 | + @Test | ||
88 | + public void testSetLspChecksum() throws Exception { | ||
89 | + lspEntry.setLspChecksum(0); | ||
90 | + result = lspEntry.lspChecksum(); | ||
91 | + assertThat(result, is(0)); | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Tests remainingTime() getter method. | ||
96 | + */ | ||
97 | + @Test | ||
98 | + public void testRemainingTime() throws Exception { | ||
99 | + lspEntry.setRemainingTime(0); | ||
100 | + result = lspEntry.remainingTime(); | ||
101 | + assertThat(result, is(0)); | ||
102 | + } | ||
103 | + | ||
104 | + /** | ||
105 | + * Tests remainingTime() setter method. | ||
106 | + */ | ||
107 | + @Test | ||
108 | + public void testSetRemainingTime() throws Exception { | ||
109 | + lspEntry.setRemainingTime(0); | ||
110 | + result = lspEntry.remainingTime(); | ||
111 | + assertThat(result, is(0)); | ||
112 | + } | ||
113 | + | ||
114 | + /** | ||
115 | + * Tests lspId() getter method. | ||
116 | + */ | ||
117 | + @Test | ||
118 | + public void testLspId() throws Exception { | ||
119 | + lspEntry.setLspId(lspId); | ||
120 | + result2 = lspEntry.lspId(); | ||
121 | + assertThat(result2, is("10.10.10.10")); | ||
122 | + } | ||
123 | + | ||
124 | + /** | ||
125 | + * Tests lspId() getter method. | ||
126 | + */ | ||
127 | + @Test | ||
128 | + public void testSetLspId() throws Exception { | ||
129 | + lspEntry.setLspId(lspId); | ||
130 | + result2 = lspEntry.lspId(); | ||
131 | + assertThat(result2, is("10.10.10.10")); | ||
132 | + } | ||
133 | + | ||
134 | + /** | ||
135 | + * Tests readFrom() method. | ||
136 | + */ | ||
137 | + @Test | ||
138 | + public void testReadFrom() throws Exception { | ||
139 | + channelBuffer = ChannelBuffers.copiedBuffer(entry); | ||
140 | + lspEntry.readFrom(channelBuffer); | ||
141 | + assertThat(lspEntry, is(notNullValue())); | ||
142 | + } | ||
143 | + | ||
144 | + /** | ||
145 | + * Tests lspEntryAsBytes() method. | ||
146 | + */ | ||
147 | + @Test | ||
148 | + public void testLspEntryAsBytes() throws Exception { | ||
149 | + channelBuffer = ChannelBuffers.copiedBuffer(entry); | ||
150 | + lspEntry.readFrom(channelBuffer); | ||
151 | + result3 = lspEntry.lspEntryAsBytes(); | ||
152 | + assertThat(lspEntry, is(notNullValue())); | ||
153 | + } | ||
154 | + | ||
155 | + /** | ||
156 | + * Tests toString() method. | ||
157 | + */ | ||
158 | + @Test | ||
159 | + public void testToString() throws Exception { | ||
160 | + assertThat(lspEntry.toString(), is(notNullValue())); | ||
161 | + } | ||
162 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
18 | + | ||
19 | +import org.easymock.EasyMock; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
21 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
22 | +import org.junit.After; | ||
23 | +import org.junit.Before; | ||
24 | +import org.junit.Test; | ||
25 | +import org.onlab.packet.Ip4Address; | ||
26 | + | ||
27 | +import static org.hamcrest.CoreMatchers.is; | ||
28 | +import static org.hamcrest.CoreMatchers.notNullValue; | ||
29 | +import static org.junit.Assert.assertThat; | ||
30 | + | ||
31 | +/** | ||
32 | + * Unit test class for MetricOfInternalReachability. | ||
33 | + */ | ||
34 | +public class MetricOfInternalReachabilityTest { | ||
35 | + | ||
36 | + private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10"); | ||
37 | + private final byte[] internalReachability = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
38 | + private MetricOfInternalReachability reachability; | ||
39 | + private Ip4Address result; | ||
40 | + private boolean result1; | ||
41 | + private byte result2; | ||
42 | + private ChannelBuffer channelBuffer; | ||
43 | + private byte[] result3; | ||
44 | + | ||
45 | + @Before | ||
46 | + public void setUp() throws Exception { | ||
47 | + reachability = new MetricOfInternalReachability(); | ||
48 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
49 | + } | ||
50 | + | ||
51 | + @After | ||
52 | + public void tearDown() throws Exception { | ||
53 | + reachability = null; | ||
54 | + result = null; | ||
55 | + result1 = false; | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * Tests getIpAddress() getter method. | ||
60 | + */ | ||
61 | + @Test | ||
62 | + public void testGetIpAddress() throws Exception { | ||
63 | + reachability.setIpAddress(ip4Address); | ||
64 | + result = reachability.getIpAddress(); | ||
65 | + assertThat(result, is(ip4Address)); | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * Tests setIpAddress() setter method. | ||
70 | + */ | ||
71 | + @Test | ||
72 | + public void testSetIpAddress() throws Exception { | ||
73 | + reachability.setIpAddress(ip4Address); | ||
74 | + result = reachability.getIpAddress(); | ||
75 | + assertThat(result, is(ip4Address)); | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Tests getSubnetAddres() getter method. | ||
80 | + */ | ||
81 | + @Test | ||
82 | + public void testGetSubnetAddres() throws Exception { | ||
83 | + reachability.setSubnetAddres(ip4Address); | ||
84 | + result = reachability.getSubnetAddres(); | ||
85 | + assertThat(result, is(ip4Address)); | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * Tests setSubnetAddres() setter method. | ||
90 | + */ | ||
91 | + @Test | ||
92 | + public void testSetSubnetAddres() throws Exception { | ||
93 | + reachability.setSubnetAddres(ip4Address); | ||
94 | + result = reachability.getSubnetAddres(); | ||
95 | + assertThat(result, is(ip4Address)); | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * Tests isErrorIsInternal() getter method. | ||
100 | + */ | ||
101 | + @Test | ||
102 | + public void testIsErrorIsInternal() throws Exception { | ||
103 | + reachability.setErrorIsInternal(true); | ||
104 | + result1 = reachability.isErrorIsInternal(); | ||
105 | + assertThat(result1, is(true)); | ||
106 | + } | ||
107 | + | ||
108 | + /** | ||
109 | + * Tests isErrorIsInternal() setter method. | ||
110 | + */ | ||
111 | + @Test | ||
112 | + public void testSetErrorIsInternal() throws Exception { | ||
113 | + reachability.setErrorIsInternal(true); | ||
114 | + result1 = reachability.isErrorIsInternal(); | ||
115 | + assertThat(result1, is(true)); | ||
116 | + } | ||
117 | + | ||
118 | + /** | ||
119 | + * Tests isExpenseIsInternal() getter method. | ||
120 | + */ | ||
121 | + @Test | ||
122 | + public void testIsExpenseIsInternal() throws Exception { | ||
123 | + reachability.setExpenseIsInternal(true); | ||
124 | + result1 = reachability.isExpenseIsInternal(); | ||
125 | + assertThat(result1, is(true)); | ||
126 | + } | ||
127 | + | ||
128 | + /** | ||
129 | + * Tests isExpenseIsInternal() setter method. | ||
130 | + */ | ||
131 | + @Test | ||
132 | + public void testSetExpenseIsInternal() throws Exception { | ||
133 | + reachability.setExpenseIsInternal(true); | ||
134 | + result1 = reachability.isExpenseIsInternal(); | ||
135 | + assertThat(result1, is(true)); | ||
136 | + } | ||
137 | + | ||
138 | + /** | ||
139 | + * Tests isDelayIsInternal() getter method. | ||
140 | + */ | ||
141 | + @Test | ||
142 | + public void testIsDelayIsInternal() throws Exception { | ||
143 | + reachability.setDelayIsInternal(true); | ||
144 | + result1 = reachability.isDelayIsInternal(); | ||
145 | + assertThat(result1, is(true)); | ||
146 | + } | ||
147 | + | ||
148 | + /** | ||
149 | + * Tests isDelayIsInternal() setter method. | ||
150 | + */ | ||
151 | + @Test | ||
152 | + public void testSetDelayIsInternal() throws Exception { | ||
153 | + reachability.setDelayIsInternal(true); | ||
154 | + result1 = reachability.isDelayIsInternal(); | ||
155 | + assertThat(result1, is(true)); | ||
156 | + } | ||
157 | + | ||
158 | + /** | ||
159 | + * Tests isDefaultDistributionDown() getter method. | ||
160 | + */ | ||
161 | + @Test | ||
162 | + public void testIsDefaultDistributionDown() throws Exception { | ||
163 | + reachability.setDefaultDistributionDown(true); | ||
164 | + result1 = reachability.isDefaultDistributionDown(); | ||
165 | + assertThat(result1, is(true)); | ||
166 | + } | ||
167 | + | ||
168 | + /** | ||
169 | + * Tests isDefaultDistributionDown() setter method. | ||
170 | + */ | ||
171 | + @Test | ||
172 | + public void testSetDefaultDistributionDown() throws Exception { | ||
173 | + reachability.setDefaultDistributionDown(true); | ||
174 | + result1 = reachability.isDefaultDistributionDown(); | ||
175 | + assertThat(result1, is(true)); | ||
176 | + } | ||
177 | + | ||
178 | + /** | ||
179 | + * Tests isDefaultIsInternal() getter method. | ||
180 | + */ | ||
181 | + @Test | ||
182 | + public void testIsDefaultIsInternal() throws Exception { | ||
183 | + reachability.setDefaultIsInternal(true); | ||
184 | + result1 = reachability.isDefaultIsInternal(); | ||
185 | + assertThat(result1, is(true)); | ||
186 | + } | ||
187 | + | ||
188 | + /** | ||
189 | + * Tests isDefaultIsInternal() setter method. | ||
190 | + */ | ||
191 | + @Test | ||
192 | + public void testSetDefaultIsInternal() throws Exception { | ||
193 | + reachability.setDefaultIsInternal(true); | ||
194 | + result1 = reachability.isDefaultIsInternal(); | ||
195 | + assertThat(result1, is(true)); | ||
196 | + } | ||
197 | + | ||
198 | + /** | ||
199 | + * Tests isErrorMetricSupported() getter method. | ||
200 | + */ | ||
201 | + @Test | ||
202 | + public void testIsErrorMetricSupported() throws Exception { | ||
203 | + reachability.setErrorMetricSupported(true); | ||
204 | + result1 = reachability.isErrorMetricSupported(); | ||
205 | + assertThat(result1, is(true)); | ||
206 | + } | ||
207 | + | ||
208 | + /** | ||
209 | + * Tests isErrorMetricSupported() setter method. | ||
210 | + */ | ||
211 | + @Test | ||
212 | + public void testSetErrorMetricSupported() throws Exception { | ||
213 | + reachability.setErrorMetricSupported(true); | ||
214 | + result1 = reachability.isErrorMetricSupported(); | ||
215 | + assertThat(result1, is(true)); | ||
216 | + } | ||
217 | + | ||
218 | + /** | ||
219 | + * Tests isExpenseMetricSupported() setter method. | ||
220 | + */ | ||
221 | + @Test | ||
222 | + public void testIsExpenseMetricSupported() throws Exception { | ||
223 | + reachability.setExpenseMetricSupported(true); | ||
224 | + result1 = reachability.isExpenseMetricSupported(); | ||
225 | + assertThat(result1, is(true)); | ||
226 | + } | ||
227 | + | ||
228 | + /** | ||
229 | + * Tests isExpenseMetricSupported() setter method. | ||
230 | + */ | ||
231 | + @Test | ||
232 | + public void testSetExpenseMetricSupported() throws Exception { | ||
233 | + reachability.setExpenseMetricSupported(true); | ||
234 | + result1 = reachability.isExpenseMetricSupported(); | ||
235 | + assertThat(result1, is(true)); | ||
236 | + } | ||
237 | + | ||
238 | + /** | ||
239 | + * Tests isDelayMetricSupported() getter method. | ||
240 | + */ | ||
241 | + @Test | ||
242 | + public void testIsDelayMetricSupported() throws Exception { | ||
243 | + reachability.setDelayMetricSupported(true); | ||
244 | + result1 = reachability.isDelayMetricSupported(); | ||
245 | + assertThat(result1, is(true)); | ||
246 | + } | ||
247 | + | ||
248 | + /** | ||
249 | + * Tests isDelayMetricSupported() setter method. | ||
250 | + */ | ||
251 | + @Test | ||
252 | + public void testSetDelayMetricSupported() throws Exception { | ||
253 | + reachability.setDelayMetricSupported(true); | ||
254 | + result1 = reachability.isDelayMetricSupported(); | ||
255 | + assertThat(result1, is(true)); | ||
256 | + } | ||
257 | + | ||
258 | + /** | ||
259 | + * Tests errorMetric() getter method. | ||
260 | + */ | ||
261 | + @Test | ||
262 | + public void testErrorMetric() throws Exception { | ||
263 | + reachability.setErrorMetric((byte) 0); | ||
264 | + result2 = reachability.errorMetric(); | ||
265 | + assertThat(result2, is((byte) 0)); | ||
266 | + } | ||
267 | + | ||
268 | + /** | ||
269 | + * Tests errorMetric() setter method. | ||
270 | + */ | ||
271 | + @Test | ||
272 | + public void testSetErrorMetric() throws Exception { | ||
273 | + reachability.setErrorMetric((byte) 0); | ||
274 | + result2 = reachability.errorMetric(); | ||
275 | + assertThat(result2, is((byte) 0)); | ||
276 | + } | ||
277 | + | ||
278 | + /** | ||
279 | + * Tests delayMetric() getter method. | ||
280 | + */ | ||
281 | + @Test | ||
282 | + public void testDelayMetric() throws Exception { | ||
283 | + reachability.setDelayMetric((byte) 0); | ||
284 | + result2 = reachability.delayMetric(); | ||
285 | + assertThat(result2, is((byte) 0)); | ||
286 | + } | ||
287 | + | ||
288 | + /** | ||
289 | + * Tests delayMetric() setter method. | ||
290 | + */ | ||
291 | + @Test | ||
292 | + public void testSetDelayMetric() throws Exception { | ||
293 | + reachability.setDelayMetric((byte) 0); | ||
294 | + result2 = reachability.delayMetric(); | ||
295 | + assertThat(result2, is((byte) 0)); | ||
296 | + } | ||
297 | + | ||
298 | + /** | ||
299 | + * Tests defaultMetric() getter method. | ||
300 | + */ | ||
301 | + @Test | ||
302 | + public void testDefaultMetric() throws Exception { | ||
303 | + reachability.setDefaultMetric((byte) 0); | ||
304 | + result2 = reachability.defaultMetric(); | ||
305 | + assertThat(result2, is((byte) 0)); | ||
306 | + } | ||
307 | + | ||
308 | + /** | ||
309 | + * Tests defaultMetric() setter method. | ||
310 | + */ | ||
311 | + @Test | ||
312 | + public void testSetDefaultMetric() throws Exception { | ||
313 | + reachability.setDefaultMetric((byte) 0); | ||
314 | + result2 = reachability.defaultMetric(); | ||
315 | + assertThat(result2, is((byte) 0)); | ||
316 | + } | ||
317 | + | ||
318 | + /** | ||
319 | + * Tests readFrom() method. | ||
320 | + */ | ||
321 | + @Test | ||
322 | + public void testReadFrom() throws Exception { | ||
323 | + channelBuffer = ChannelBuffers.copiedBuffer(internalReachability); | ||
324 | + reachability.readFrom(channelBuffer); | ||
325 | + assertThat(reachability, is(notNullValue())); | ||
326 | + } | ||
327 | + | ||
328 | + /** | ||
329 | + * Tests asBytes() method. | ||
330 | + */ | ||
331 | + @Test | ||
332 | + public void testAsBytes() throws Exception { | ||
333 | + channelBuffer = ChannelBuffers.copiedBuffer(internalReachability); | ||
334 | + reachability.readFrom(channelBuffer); | ||
335 | + result3 = reachability.asBytes(); | ||
336 | + assertThat(result3, is(notNullValue())); | ||
337 | + } | ||
338 | + | ||
339 | + /** | ||
340 | + * Tests toString() method. | ||
341 | + */ | ||
342 | + @Test | ||
343 | + public void testToString() throws Exception { | ||
344 | + assertThat(reachability.toString(), is(notNullValue())); | ||
345 | + } | ||
346 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
18 | + | ||
19 | +import org.easymock.EasyMock; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
21 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
22 | +import org.junit.After; | ||
23 | +import org.junit.Before; | ||
24 | +import org.junit.Test; | ||
25 | +import org.onlab.packet.Ip4Address; | ||
26 | + | ||
27 | +import static org.hamcrest.CoreMatchers.is; | ||
28 | +import static org.hamcrest.CoreMatchers.notNullValue; | ||
29 | +import static org.junit.Assert.assertThat; | ||
30 | + | ||
31 | +/** | ||
32 | + * Unit test class for MetricsOfReachability. | ||
33 | + */ | ||
34 | +public class MetricsOfReachabilityTest { | ||
35 | + private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10"); | ||
36 | + private final byte[] metricReachability = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
37 | + private MetricsOfReachability reachability; | ||
38 | + private String neighborId = "2929.2929.2929"; | ||
39 | + private Ip4Address result; | ||
40 | + private boolean result1; | ||
41 | + private byte result2; | ||
42 | + private ChannelBuffer channelBuffer; | ||
43 | + private byte[] result3; | ||
44 | + private String result4; | ||
45 | + | ||
46 | + @Before | ||
47 | + public void setUp() throws Exception { | ||
48 | + reachability = new MetricsOfReachability(); | ||
49 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
50 | + result1 = false; | ||
51 | + } | ||
52 | + | ||
53 | + @After | ||
54 | + public void tearDown() throws Exception { | ||
55 | + reachability = null; | ||
56 | + result1 = false; | ||
57 | + result3 = null; | ||
58 | + channelBuffer = null; | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * Tests isDelayIsInternal() getter method. | ||
63 | + */ | ||
64 | + @Test | ||
65 | + public void testIsDelayIsInternal() throws Exception { | ||
66 | + reachability.setDelayIsInternal(true); | ||
67 | + result1 = reachability.isDelayIsInternal(); | ||
68 | + assertThat(result1, is(true)); | ||
69 | + } | ||
70 | + | ||
71 | + /** | ||
72 | + * Tests isDelayIsInternal() setter method. | ||
73 | + */ | ||
74 | + @Test | ||
75 | + public void testSetDelayIsInternal() throws Exception { | ||
76 | + reachability.setDelayIsInternal(true); | ||
77 | + result1 = reachability.isDelayIsInternal(); | ||
78 | + assertThat(result1, is(true)); | ||
79 | + } | ||
80 | + | ||
81 | + /** | ||
82 | + * Tests isExpenseIsInternal() getter method. | ||
83 | + */ | ||
84 | + @Test | ||
85 | + public void testIsExpenseIsInternal() throws Exception { | ||
86 | + reachability.setExpenseIsInternal(true); | ||
87 | + result1 = reachability.isExpenseIsInternal(); | ||
88 | + assertThat(result1, is(true)); | ||
89 | + } | ||
90 | + | ||
91 | + /** | ||
92 | + * Tests isExpenseIsInternal() setter method. | ||
93 | + */ | ||
94 | + @Test | ||
95 | + public void testSetExpenseIsInternal() throws Exception { | ||
96 | + reachability.setExpenseIsInternal(true); | ||
97 | + result1 = reachability.isExpenseIsInternal(); | ||
98 | + assertThat(result1, is(true)); | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * Tests isErrorIsInternal() getter method. | ||
103 | + */ | ||
104 | + @Test | ||
105 | + public void testIsErrorIsInternal() throws Exception { | ||
106 | + reachability.setErrorIsInternal(true); | ||
107 | + result1 = reachability.isErrorIsInternal(); | ||
108 | + assertThat(result1, is(true)); | ||
109 | + } | ||
110 | + | ||
111 | + /** | ||
112 | + * Tests isErrorIsInternal() setter method. | ||
113 | + */ | ||
114 | + @Test | ||
115 | + public void testSetErrorIsInternal() throws Exception { | ||
116 | + reachability.setErrorIsInternal(true); | ||
117 | + result1 = reachability.isErrorIsInternal(); | ||
118 | + assertThat(result1, is(true)); | ||
119 | + } | ||
120 | + | ||
121 | + /** | ||
122 | + * Tests isDefaultIsInternal() getter method. | ||
123 | + */ | ||
124 | + @Test | ||
125 | + public void testIsDefaultIsInternal() throws Exception { | ||
126 | + reachability.setDefaultIsInternal(true); | ||
127 | + result1 = reachability.isDefaultIsInternal(); | ||
128 | + assertThat(result1, is(true)); | ||
129 | + } | ||
130 | + | ||
131 | + /** | ||
132 | + * Tests isDefaultIsInternal() setter method. | ||
133 | + */ | ||
134 | + @Test | ||
135 | + public void testSetDefaultIsInternal() throws Exception { | ||
136 | + reachability.setDefaultIsInternal(true); | ||
137 | + result1 = reachability.isDefaultIsInternal(); | ||
138 | + assertThat(result1, is(true)); | ||
139 | + } | ||
140 | + | ||
141 | + @Test | ||
142 | + public void testIsDelayMetricSupported() throws Exception { | ||
143 | + reachability.setDelayMetricSupported(true); | ||
144 | + result1 = reachability.isDelayMetricSupported(); | ||
145 | + assertThat(result1, is(true)); | ||
146 | + } | ||
147 | + | ||
148 | + /** | ||
149 | + * Tests isDelayMetricSupported() setter method. | ||
150 | + */ | ||
151 | + @Test | ||
152 | + public void testSetDelayMetricSupported() throws Exception { | ||
153 | + reachability.setDelayMetricSupported(true); | ||
154 | + result1 = reachability.isDelayMetricSupported(); | ||
155 | + assertThat(result1, is(true)); | ||
156 | + } | ||
157 | + | ||
158 | + /** | ||
159 | + * Tests isExpenseMetricSupported() getter method. | ||
160 | + */ | ||
161 | + @Test | ||
162 | + public void testIsExpenseMetricSupported() throws Exception { | ||
163 | + reachability.setExpenseMetricSupported(true); | ||
164 | + result1 = reachability.isExpenseMetricSupported(); | ||
165 | + assertThat(result1, is(true)); | ||
166 | + } | ||
167 | + | ||
168 | + /** | ||
169 | + * Tests isExpenseMetricSupported() setter method. | ||
170 | + */ | ||
171 | + @Test | ||
172 | + public void testSetExpenseMetricSupported() throws Exception { | ||
173 | + reachability.setExpenseMetricSupported(true); | ||
174 | + result1 = reachability.isExpenseMetricSupported(); | ||
175 | + assertThat(result1, is(true)); | ||
176 | + } | ||
177 | + | ||
178 | + /** | ||
179 | + * Tests isErrorMetricSupported() getter method. | ||
180 | + */ | ||
181 | + @Test | ||
182 | + public void testIsErrorMetricSupported() throws Exception { | ||
183 | + reachability.setErrorMetricSupported(true); | ||
184 | + result1 = reachability.isErrorMetricSupported(); | ||
185 | + assertThat(result1, is(true)); | ||
186 | + } | ||
187 | + | ||
188 | + /** | ||
189 | + * Tests isErrorMetricSupported() setter method. | ||
190 | + */ | ||
191 | + @Test | ||
192 | + public void testSetErrorMetricSupported() throws Exception { | ||
193 | + reachability.setErrorMetricSupported(true); | ||
194 | + result1 = reachability.isErrorMetricSupported(); | ||
195 | + assertThat(result1, is(true)); | ||
196 | + } | ||
197 | + | ||
198 | + /** | ||
199 | + * Tests neighborId() getter method. | ||
200 | + */ | ||
201 | + @Test | ||
202 | + public void testNeighborId() throws Exception { | ||
203 | + reachability.setNeighborId(neighborId); | ||
204 | + result4 = reachability.neighborId(); | ||
205 | + assertThat(result4, is(neighborId)); | ||
206 | + } | ||
207 | + | ||
208 | + /** | ||
209 | + * Tests neighborId() setter method. | ||
210 | + */ | ||
211 | + @Test | ||
212 | + public void testSetNeighborId() throws Exception { | ||
213 | + reachability.setNeighborId(neighborId); | ||
214 | + result4 = reachability.neighborId(); | ||
215 | + assertThat(result4, is(neighborId)); | ||
216 | + } | ||
217 | + | ||
218 | + /** | ||
219 | + * Tests defaultMetric() getter method. | ||
220 | + */ | ||
221 | + @Test | ||
222 | + public void testDefaultMetric() throws Exception { | ||
223 | + reachability.setDefaultMetric((byte) 0); | ||
224 | + result2 = reachability.defaultMetric(); | ||
225 | + assertThat(result2, is((byte) 0)); | ||
226 | + } | ||
227 | + | ||
228 | + /** | ||
229 | + * Tests defaultMetric() setter method. | ||
230 | + */ | ||
231 | + @Test | ||
232 | + public void testSetDefaultMetric() throws Exception { | ||
233 | + reachability.setDefaultMetric((byte) 0); | ||
234 | + result2 = reachability.defaultMetric(); | ||
235 | + assertThat(result2, is((byte) 0)); | ||
236 | + } | ||
237 | + | ||
238 | + /** | ||
239 | + * Tests delayMetric() getter method. | ||
240 | + */ | ||
241 | + @Test | ||
242 | + public void testDelayMetric() throws Exception { | ||
243 | + reachability.setDelayMetric((byte) 0); | ||
244 | + result2 = reachability.delayMetric(); | ||
245 | + assertThat(result2, is((byte) 0)); | ||
246 | + } | ||
247 | + | ||
248 | + /** | ||
249 | + * Tests delayMetric() setter method. | ||
250 | + */ | ||
251 | + @Test | ||
252 | + public void testSetDelayMetric() throws Exception { | ||
253 | + reachability.setDelayMetric((byte) 0); | ||
254 | + result2 = reachability.delayMetric(); | ||
255 | + assertThat(result2, is((byte) 0)); | ||
256 | + } | ||
257 | + | ||
258 | + /** | ||
259 | + * Tests expenseMetric() getter method. | ||
260 | + */ | ||
261 | + @Test | ||
262 | + public void testExpenseMetric() throws Exception { | ||
263 | + reachability.setExpenseMetric((byte) 0); | ||
264 | + result2 = reachability.expenseMetric(); | ||
265 | + assertThat(result2, is((byte) 0)); | ||
266 | + } | ||
267 | + | ||
268 | + /** | ||
269 | + * Tests expenseMetric() setter method. | ||
270 | + */ | ||
271 | + @Test | ||
272 | + public void testSetExpenseMetric() throws Exception { | ||
273 | + reachability.setExpenseMetric((byte) 0); | ||
274 | + result2 = reachability.expenseMetric(); | ||
275 | + assertThat(result2, is((byte) 0)); | ||
276 | + } | ||
277 | + | ||
278 | + /** | ||
279 | + * Tests errorMetric() getter method. | ||
280 | + */ | ||
281 | + @Test | ||
282 | + public void testErrorMetric() throws Exception { | ||
283 | + reachability.setErrorMetric((byte) 0); | ||
284 | + result2 = reachability.errorMetric(); | ||
285 | + assertThat(result2, is((byte) 0)); | ||
286 | + } | ||
287 | + | ||
288 | + /** | ||
289 | + * Tests errorMetric() setter method. | ||
290 | + */ | ||
291 | + @Test | ||
292 | + public void testSetErrorMetric() throws Exception { | ||
293 | + reachability.setErrorMetric((byte) 0); | ||
294 | + result2 = reachability.errorMetric(); | ||
295 | + assertThat(result2, is((byte) 0)); | ||
296 | + } | ||
297 | + | ||
298 | + /** | ||
299 | + * Tests readFrom() method. | ||
300 | + */ | ||
301 | + @Test | ||
302 | + public void testReadFrom() throws Exception { | ||
303 | + channelBuffer = ChannelBuffers.copiedBuffer(metricReachability); | ||
304 | + reachability.readFrom(channelBuffer); | ||
305 | + assertThat(reachability, is(notNullValue())); | ||
306 | + } | ||
307 | + | ||
308 | + /** | ||
309 | + * Tests asBytes() method. | ||
310 | + */ | ||
311 | + @Test | ||
312 | + public void testAsBytes() throws Exception { | ||
313 | + channelBuffer = ChannelBuffers.copiedBuffer(metricReachability); | ||
314 | + reachability.readFrom(channelBuffer); | ||
315 | + result3 = reachability.asBytes(); | ||
316 | + assertThat(result3, is(notNullValue())); | ||
317 | + } | ||
318 | + | ||
319 | + /** | ||
320 | + * Tests toString() method. | ||
321 | + */ | ||
322 | + @Test | ||
323 | + public void testToString() throws Exception { | ||
324 | + assertThat(reachability.toString(), is(notNullValue())); | ||
325 | + } | ||
326 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/PaddingTlvTest.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
20 | +import org.junit.After; | ||
21 | +import org.junit.Before; | ||
22 | +import org.junit.Test; | ||
23 | + | ||
24 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
25 | +import static org.hamcrest.Matchers.is; | ||
26 | +import static org.hamcrest.Matchers.notNullValue; | ||
27 | + | ||
28 | +/** | ||
29 | + * Unit test class for PaddingTlv. | ||
30 | + */ | ||
31 | +public class PaddingTlvTest { | ||
32 | + | ||
33 | + private final byte[] tlv = {0, 0, 0, 0, 0, 0, 0}; | ||
34 | + private PaddingTlv paddingTlv; | ||
35 | + private TlvHeader tlvHeader; | ||
36 | + private ChannelBuffer channelBuffer; | ||
37 | + private byte[] result; | ||
38 | + | ||
39 | + @Before | ||
40 | + public void setUp() throws Exception { | ||
41 | + tlvHeader = new TlvHeader(); | ||
42 | + paddingTlv = new PaddingTlv(tlvHeader); | ||
43 | + } | ||
44 | + | ||
45 | + @After | ||
46 | + public void tearDown() throws Exception { | ||
47 | + paddingTlv = null; | ||
48 | + } | ||
49 | + | ||
50 | + /** | ||
51 | + * Tests readFrom() method. | ||
52 | + */ | ||
53 | + @Test | ||
54 | + public void testReadFrom() throws Exception { | ||
55 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
56 | + paddingTlv.readFrom(channelBuffer); | ||
57 | + assertThat(paddingTlv, is(notNullValue())); | ||
58 | + } | ||
59 | + | ||
60 | + /** | ||
61 | + * Tests asBytes() method. | ||
62 | + */ | ||
63 | + @Test | ||
64 | + public void testAsBytes() throws Exception { | ||
65 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
66 | + paddingTlv.readFrom(channelBuffer); | ||
67 | + result = paddingTlv.asBytes(); | ||
68 | + assertThat(result, is(notNullValue())); | ||
69 | + } | ||
70 | + | ||
71 | + /** | ||
72 | + * Tests toString() getter method. | ||
73 | + */ | ||
74 | + @Test | ||
75 | + public void testToString() throws Exception { | ||
76 | + assertThat(paddingTlv.toString(), is(notNullValue())); | ||
77 | + } | ||
78 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
20 | +import org.junit.After; | ||
21 | +import org.junit.Before; | ||
22 | +import org.junit.Test; | ||
23 | + | ||
24 | +import java.util.List; | ||
25 | + | ||
26 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
27 | +import static org.hamcrest.Matchers.is; | ||
28 | +import static org.hamcrest.Matchers.notNullValue; | ||
29 | + | ||
30 | +/** | ||
31 | + * Unit test class for ProtocolSupportedTlv. | ||
32 | + */ | ||
33 | +public class ProtocolSupportedTlvTest { | ||
34 | + private final byte[] tlv = {0}; | ||
35 | + private ProtocolSupportedTlv protocolSupportedTlv; | ||
36 | + private TlvHeader tlvHeader; | ||
37 | + private List<Byte> supported; | ||
38 | + private ChannelBuffer channelBuffer; | ||
39 | + private byte[] result; | ||
40 | + | ||
41 | + @Before | ||
42 | + public void setUp() throws Exception { | ||
43 | + tlvHeader = new TlvHeader(); | ||
44 | + protocolSupportedTlv = new ProtocolSupportedTlv(tlvHeader); | ||
45 | + } | ||
46 | + | ||
47 | + @After | ||
48 | + public void tearDown() throws Exception { | ||
49 | + tlvHeader = null; | ||
50 | + protocolSupportedTlv = null; | ||
51 | + channelBuffer = null; | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * Tests addProtocolSupported() method. | ||
56 | + */ | ||
57 | + @Test | ||
58 | + public void testAddProtocolSupported() throws Exception { | ||
59 | + protocolSupportedTlv.addProtocolSupported((byte) 1); | ||
60 | + supported = protocolSupportedTlv.protocolSupported(); | ||
61 | + assertThat(supported.size(), is(1)); | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * Tests addProtocolSupported() getter method. | ||
66 | + */ | ||
67 | + @Test | ||
68 | + public void testProtocolSupported() throws Exception { | ||
69 | + protocolSupportedTlv.addProtocolSupported((byte) 1); | ||
70 | + supported = protocolSupportedTlv.protocolSupported(); | ||
71 | + assertThat(supported.size(), is(1)); | ||
72 | + } | ||
73 | + | ||
74 | + /** | ||
75 | + * Tests readFrom() method. | ||
76 | + */ | ||
77 | + @Test | ||
78 | + public void testReadFrom() throws Exception { | ||
79 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
80 | + protocolSupportedTlv.readFrom(channelBuffer); | ||
81 | + supported = protocolSupportedTlv.protocolSupported(); | ||
82 | + assertThat(supported.size(), is(1)); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Tests asBytes() method. | ||
87 | + */ | ||
88 | + @Test | ||
89 | + public void testAsBytes() throws Exception { | ||
90 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
91 | + protocolSupportedTlv.readFrom(channelBuffer); | ||
92 | + result = protocolSupportedTlv.asBytes(); | ||
93 | + assertThat(result, is(notNullValue())); | ||
94 | + } | ||
95 | + | ||
96 | + /** | ||
97 | + * Tests toString() method. | ||
98 | + */ | ||
99 | + @Test | ||
100 | + public void testToString() throws Exception { | ||
101 | + assertThat(protocolSupportedTlv.toString(), is(notNullValue())); | ||
102 | + } | ||
103 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvFinderTest.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
20 | +import org.junit.After; | ||
21 | +import org.junit.Before; | ||
22 | +import org.junit.Test; | ||
23 | + | ||
24 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
25 | +import static org.hamcrest.Matchers.instanceOf; | ||
26 | + | ||
27 | +/** | ||
28 | + * Unit test class for TlvFinder. | ||
29 | + */ | ||
30 | +public class TlvFinderTest { | ||
31 | + | ||
32 | + private final byte[] tlv = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
33 | + private final byte[] tlv1 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
34 | + private TlvFinder tlvFinder; | ||
35 | + private TlvHeader tlvHeader; | ||
36 | + private ChannelBuffer channelBuffer; | ||
37 | + private IsisTlv isisTlv; | ||
38 | + | ||
39 | + @Before | ||
40 | + public void setUp() throws Exception { | ||
41 | + tlvFinder = new TlvFinder(); | ||
42 | + tlvHeader = new TlvHeader(); | ||
43 | + } | ||
44 | + | ||
45 | + @After | ||
46 | + public void tearDown() throws Exception { | ||
47 | + tlvFinder = null; | ||
48 | + isisTlv = null; | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * Tests IsisTlv() getter method. | ||
53 | + */ | ||
54 | + @Test | ||
55 | + public void testIsisTlv() throws Exception { | ||
56 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
57 | + | ||
58 | + tlvHeader.setTlvType(TlvType.AREAADDRESS.value()); | ||
59 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
60 | + assertThat(isisTlv, instanceOf(AreaAddressTlv.class)); | ||
61 | + | ||
62 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
63 | + tlvHeader.setTlvType(TlvType.HOSTNAME.value()); | ||
64 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
65 | + assertThat(isisTlv, instanceOf(HostNameTlv.class)); | ||
66 | + | ||
67 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
68 | + tlvHeader.setTlvType(TlvType.IDRPINFORMATION.value()); | ||
69 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
70 | + assertThat(isisTlv, instanceOf(IdrpInformationTlv.class)); | ||
71 | + | ||
72 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
73 | + tlvHeader.setTlvType(TlvType.IPEXTENDEDREACHABILITY.value()); | ||
74 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
75 | + assertThat(isisTlv, instanceOf(IpExtendedReachabilityTlv.class)); | ||
76 | + | ||
77 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
78 | + tlvHeader.setTlvType(TlvType.IPINTERFACEADDRESS.value()); | ||
79 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
80 | + assertThat(isisTlv, instanceOf(IpInterfaceAddressTlv.class)); | ||
81 | + | ||
82 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
83 | + tlvHeader.setTlvType(TlvType.IPINTERNALREACHABILITY.value()); | ||
84 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
85 | + assertThat(isisTlv, instanceOf(IpInternalReachabilityTlv.class)); | ||
86 | + | ||
87 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
88 | + tlvHeader.setTlvType(TlvType.PROTOCOLSUPPORTED.value()); | ||
89 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
90 | + assertThat(isisTlv, instanceOf(ProtocolSupportedTlv.class)); | ||
91 | + | ||
92 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
93 | + tlvHeader.setTlvType(TlvType.ISREACHABILITY.value()); | ||
94 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
95 | + assertThat(isisTlv, instanceOf(IsReachabilityTlv.class)); | ||
96 | + | ||
97 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
98 | + tlvHeader.setTlvType(TlvType.ISNEIGHBORS.value()); | ||
99 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
100 | + assertThat(isisTlv, instanceOf(IsisNeighborTlv.class)); | ||
101 | + | ||
102 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
103 | + tlvHeader.setTlvType(TlvType.LSPENTRY.value()); | ||
104 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
105 | + assertThat(isisTlv, instanceOf(LspEntriesTlv.class)); | ||
106 | + | ||
107 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv); | ||
108 | + tlvHeader.setTlvType(TlvType.PADDING.value()); | ||
109 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
110 | + assertThat(isisTlv, instanceOf(PaddingTlv.class)); | ||
111 | + | ||
112 | + channelBuffer = ChannelBuffers.copiedBuffer(tlv1); | ||
113 | + tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value()); | ||
114 | + isisTlv = tlvFinder.findTlv(tlvHeader, channelBuffer); | ||
115 | + assertThat(isisTlv, instanceOf(AdjacencyStateTlv.class)); | ||
116 | + } | ||
117 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvHeaderTest.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.easymock.EasyMock; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
20 | +import org.junit.After; | ||
21 | +import org.junit.Before; | ||
22 | +import org.junit.Test; | ||
23 | + | ||
24 | +import static org.hamcrest.CoreMatchers.*; | ||
25 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
26 | + | ||
27 | +/** | ||
28 | + * Unit test class for TlvHeader. | ||
29 | + */ | ||
30 | +public class TlvHeaderTest { | ||
31 | + | ||
32 | + private TlvHeader tlvHeader; | ||
33 | + private int result; | ||
34 | + private ChannelBuffer channelBuffer; | ||
35 | + | ||
36 | + @Before | ||
37 | + public void setUp() throws Exception { | ||
38 | + tlvHeader = new TlvHeader(); | ||
39 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
40 | + } | ||
41 | + | ||
42 | + @After | ||
43 | + public void tearDown() throws Exception { | ||
44 | + tlvHeader = null; | ||
45 | + channelBuffer = null; | ||
46 | + } | ||
47 | + | ||
48 | + /** | ||
49 | + * Tests tlvLength() getter method. | ||
50 | + */ | ||
51 | + @Test | ||
52 | + public void testTlvLength() throws Exception { | ||
53 | + tlvHeader.setTlvLength(1); | ||
54 | + result = tlvHeader.tlvLength(); | ||
55 | + assertThat(result, is(1)); | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * Tests tlvLength() setter method. | ||
60 | + */ | ||
61 | + @Test | ||
62 | + public void testSetTlvLength() throws Exception { | ||
63 | + tlvHeader.setTlvLength(1); | ||
64 | + result = tlvHeader.tlvLength(); | ||
65 | + assertThat(result, is(1)); | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * Tests tlvType() getter method. | ||
70 | + */ | ||
71 | + @Test | ||
72 | + public void testTlvType() throws Exception { | ||
73 | + tlvHeader.setTlvType(1); | ||
74 | + result = tlvHeader.tlvType(); | ||
75 | + assertThat(result, is(1)); | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Tests tlvType() setter method. | ||
80 | + */ | ||
81 | + @Test | ||
82 | + public void testSetTlvType() throws Exception { | ||
83 | + tlvHeader.setTlvType(1); | ||
84 | + result = tlvHeader.tlvType(); | ||
85 | + assertThat(result, is(1)); | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + * Tests readFrom() method. | ||
90 | + */ | ||
91 | + @Test | ||
92 | + public void testReadFrom() throws Exception { | ||
93 | + tlvHeader.readFrom(channelBuffer); | ||
94 | + assertThat(tlvHeader, is(notNullValue())); | ||
95 | + } | ||
96 | + | ||
97 | + /** | ||
98 | + * Tests asBytes() getter method. | ||
99 | + */ | ||
100 | + @Test | ||
101 | + public void testAsBytes() throws Exception { | ||
102 | + assertThat(tlvHeader.asBytes(), is(nullValue())); | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * Tests tlvHeaderAsByteArray() method. | ||
107 | + */ | ||
108 | + @Test | ||
109 | + public void testTlvHeaderAsByteArray() throws Exception { | ||
110 | + tlvHeader.setTlvLength(1); | ||
111 | + tlvHeader.setTlvType(1); | ||
112 | + assertThat(tlvHeader.tlvHeaderAsByteArray(), is(notNullValue())); | ||
113 | + assertThat(tlvHeader.tlvType(), is(1)); | ||
114 | + assertThat(tlvHeader.tlvLength(), is(1)); | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * Tests toString() getter method. | ||
119 | + */ | ||
120 | + @Test | ||
121 | + public void testToString() throws Exception { | ||
122 | + assertThat(tlvHeader.toString(), is(notNullValue())); | ||
123 | + } | ||
124 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
protocols/isis/isisio/src/test/java/org/onosproject/isis/io/isispacket/tlv/TlvsToBytesTest.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv; | ||
17 | + | ||
18 | +import org.junit.Test; | ||
19 | +import org.onlab.packet.Ip4Address; | ||
20 | +import org.onlab.packet.MacAddress; | ||
21 | +import org.onosproject.isis.controller.IsisInterfaceState; | ||
22 | +import org.onosproject.isis.io.util.IsisConstants; | ||
23 | + | ||
24 | +import java.util.List; | ||
25 | + | ||
26 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
27 | +import static org.hamcrest.Matchers.is; | ||
28 | +import static org.hamcrest.Matchers.notNullValue; | ||
29 | + | ||
30 | +/** | ||
31 | + * Unit test class for TlvsToBytes. | ||
32 | + */ | ||
33 | +public class TlvsToBytesTest { | ||
34 | + private final String areaAddress = "49"; | ||
35 | + private final Ip4Address ip4Address = Ip4Address.valueOf("10.10.10.10"); | ||
36 | + private final String systemName = "ROUTER"; | ||
37 | + private final String neighborId = "2929.2929.2929"; | ||
38 | + private List<Byte> tlv; | ||
39 | + private MacAddress macAddress = MacAddress.valueOf("a4:23:05:00:00:00"); | ||
40 | + private String prefix = "192.168.7"; | ||
41 | + | ||
42 | + /** | ||
43 | + * Tests TlvToBytes() method. | ||
44 | + */ | ||
45 | + @Test | ||
46 | + public void testTlvToBytes() throws Exception { | ||
47 | + TlvHeader tlvHeader = new TlvHeader(); | ||
48 | + tlvHeader.setTlvType(TlvType.AREAADDRESS.value()); | ||
49 | + tlvHeader.setTlvLength(0); | ||
50 | + AreaAddressTlv areaAddressTlv = new AreaAddressTlv(tlvHeader); | ||
51 | + areaAddressTlv.addAddress(areaAddress); | ||
52 | + tlv = TlvsToBytes.tlvToBytes(areaAddressTlv); | ||
53 | + assertThat(tlv, is(notNullValue())); | ||
54 | + | ||
55 | + tlvHeader.setTlvType(TlvType.PROTOCOLSUPPORTED.value()); | ||
56 | + tlvHeader.setTlvLength(0); | ||
57 | + ProtocolSupportedTlv protocolSupportedTlv = new ProtocolSupportedTlv(tlvHeader); | ||
58 | + protocolSupportedTlv.addProtocolSupported((byte) IsisConstants.PROTOCOLSUPPORTED); | ||
59 | + tlv = TlvsToBytes.tlvToBytes(protocolSupportedTlv); | ||
60 | + assertThat(tlv, is(notNullValue())); | ||
61 | + | ||
62 | + tlvHeader.setTlvType(TlvType.IPINTERFACEADDRESS.value()); | ||
63 | + tlvHeader.setTlvLength(0); | ||
64 | + IpInterfaceAddressTlv ipInterfaceAddressTlv = new IpInterfaceAddressTlv(tlvHeader); | ||
65 | + ipInterfaceAddressTlv.addInterfaceAddres(ip4Address); | ||
66 | + tlv = TlvsToBytes.tlvToBytes(ipInterfaceAddressTlv); | ||
67 | + assertThat(tlv, is(notNullValue())); | ||
68 | + | ||
69 | + tlvHeader.setTlvType(TlvType.HOSTNAME.value()); | ||
70 | + tlvHeader.setTlvLength(0); | ||
71 | + HostNameTlv hostNameTlv = new HostNameTlv(tlvHeader); | ||
72 | + hostNameTlv.setHostName(systemName); | ||
73 | + tlv = TlvsToBytes.tlvToBytes(hostNameTlv); | ||
74 | + assertThat(tlv, is(notNullValue())); | ||
75 | + | ||
76 | + tlvHeader.setTlvType(TlvType.ISREACHABILITY.value()); | ||
77 | + tlvHeader.setTlvLength(0); | ||
78 | + IsReachabilityTlv isReachabilityTlv = new IsReachabilityTlv(tlvHeader); | ||
79 | + isReachabilityTlv.setReserved(0); | ||
80 | + MetricsOfReachability metricsOfReachability = new MetricsOfReachability(); | ||
81 | + metricsOfReachability.setDefaultMetric((byte) 10); | ||
82 | + metricsOfReachability.setDefaultIsInternal(true); | ||
83 | + metricsOfReachability.setDelayMetric((byte) 10); | ||
84 | + metricsOfReachability.setDelayIsInternal(true); | ||
85 | + metricsOfReachability.setDelayMetricSupported(true); | ||
86 | + metricsOfReachability.setExpenseMetric((byte) 10); | ||
87 | + metricsOfReachability.setExpenseIsInternal(true); | ||
88 | + metricsOfReachability.setExpenseMetricSupported(true); | ||
89 | + metricsOfReachability.setErrorMetric((byte) 10); | ||
90 | + metricsOfReachability.setErrorIsInternal(true); | ||
91 | + metricsOfReachability.setErrorMetricSupported(true); | ||
92 | + metricsOfReachability.setNeighborId(neighborId); | ||
93 | + isReachabilityTlv.addMeticsOfReachability(metricsOfReachability); | ||
94 | + tlv = TlvsToBytes.tlvToBytes(isReachabilityTlv); | ||
95 | + assertThat(tlv, is(notNullValue())); | ||
96 | + | ||
97 | + tlvHeader.setTlvType(TlvType.IPINTERNALREACHABILITY.value()); | ||
98 | + tlvHeader.setTlvLength(0); | ||
99 | + IpInternalReachabilityTlv ipInterReacTlv = new IpInternalReachabilityTlv(tlvHeader); | ||
100 | + MetricOfInternalReachability metricOfIntRea = new MetricOfInternalReachability(); | ||
101 | + metricOfIntRea.setDefaultMetric((byte) 10); | ||
102 | + metricOfIntRea.setDefaultIsInternal(true); | ||
103 | + metricOfIntRea.setDefaultDistributionDown(true); | ||
104 | + metricOfIntRea.setDelayMetric((byte) 0); | ||
105 | + metricOfIntRea.setDelayMetricSupported(false); | ||
106 | + metricOfIntRea.setDelayIsInternal(true); | ||
107 | + metricOfIntRea.setExpenseMetric((byte) 0); | ||
108 | + metricOfIntRea.setExpenseMetricSupported(false); | ||
109 | + metricOfIntRea.setExpenseIsInternal(true); | ||
110 | + metricOfIntRea.setErrorMetric((byte) 0); | ||
111 | + metricOfIntRea.setErrorMetricSupported(false); | ||
112 | + metricOfIntRea.setExpenseIsInternal(true); | ||
113 | + metricOfIntRea.setIpAddress(ip4Address); | ||
114 | + metricOfIntRea.setSubnetAddres(ip4Address); | ||
115 | + ipInterReacTlv.addInternalReachabilityMetric(metricOfIntRea); | ||
116 | + tlv = TlvsToBytes.tlvToBytes(ipInterReacTlv); | ||
117 | + assertThat(tlv, is(notNullValue())); | ||
118 | + | ||
119 | + tlvHeader.setTlvType(TlvType.PADDING.value()); | ||
120 | + tlvHeader.setTlvLength(255); | ||
121 | + PaddingTlv paddingTlv = new PaddingTlv(tlvHeader); | ||
122 | + tlv = TlvsToBytes.tlvToBytes(paddingTlv); | ||
123 | + assertThat(tlv, is(notNullValue())); | ||
124 | + | ||
125 | + tlvHeader.setTlvType(TlvType.IPEXTENDEDREACHABILITY.value()); | ||
126 | + tlvHeader.setTlvLength(0); | ||
127 | + IpExtendedReachabilityTlv extendedTlv = new IpExtendedReachabilityTlv(tlvHeader); | ||
128 | + extendedTlv.setDown(false); | ||
129 | + extendedTlv.setMetric(10); | ||
130 | + extendedTlv.setPrefix(prefix); | ||
131 | + extendedTlv.setPrefixLength(24); | ||
132 | + extendedTlv.setSubTlvLength((byte) 0); | ||
133 | + extendedTlv.setSubTlvPresence(false); | ||
134 | + tlv = TlvsToBytes.tlvToBytes(extendedTlv); | ||
135 | + assertThat(tlv, is(notNullValue())); | ||
136 | + | ||
137 | + tlvHeader.setTlvType(TlvType.ADJACENCYSTATE.value()); | ||
138 | + tlvHeader.setTlvLength(0); | ||
139 | + AdjacencyStateTlv adjacencyStateTlv = new AdjacencyStateTlv(tlvHeader); | ||
140 | + adjacencyStateTlv.setAdjacencyType((byte) IsisInterfaceState.DOWN.value()); | ||
141 | + tlv = TlvsToBytes.tlvToBytes(adjacencyStateTlv); | ||
142 | + assertThat(tlv, is(notNullValue())); | ||
143 | + | ||
144 | + tlvHeader.setTlvType(TlvType.ISNEIGHBORS.value()); | ||
145 | + tlvHeader.setTlvLength(0); | ||
146 | + IsisNeighborTlv isisNeighborTlv = new IsisNeighborTlv(tlvHeader); | ||
147 | + isisNeighborTlv.addNeighbor(macAddress); | ||
148 | + tlv = TlvsToBytes.tlvToBytes(isisNeighborTlv); | ||
149 | + assertThat(tlv, is(notNullValue())); | ||
150 | + | ||
151 | + tlvHeader.setTlvType(TlvType.EXTENDEDISREACHABILITY.value()); | ||
152 | + tlvHeader.setTlvLength(0); | ||
153 | + IsExtendedReachability reachability = new IsExtendedReachability(tlvHeader); | ||
154 | + NeighborForExtendedIs forExtendedIs = new NeighborForExtendedIs(); | ||
155 | + forExtendedIs.setMetric(10); | ||
156 | + forExtendedIs.setNeighborId(neighborId); | ||
157 | + reachability.addNeighbor(forExtendedIs); | ||
158 | + tlv = TlvsToBytes.tlvToBytes(reachability); | ||
159 | + assertThat(tlv, is(notNullValue())); | ||
160 | + } | ||
161 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv; | ||
17 | + | ||
18 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
20 | +import org.junit.After; | ||
21 | +import org.junit.Before; | ||
22 | +import org.junit.Test; | ||
23 | +import org.onosproject.isis.io.isispacket.tlv.TlvHeader; | ||
24 | + | ||
25 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
26 | +import static org.hamcrest.Matchers.is; | ||
27 | +import static org.hamcrest.Matchers.notNullValue; | ||
28 | + | ||
29 | +/** | ||
30 | + * Unit test class for AdministrativeGroup. | ||
31 | + */ | ||
32 | +public class AdministrativeGroupTest { | ||
33 | + | ||
34 | + private final byte[] packet = {0, 0, 0, 1}; | ||
35 | + private AdministrativeGroup administrativeGroup; | ||
36 | + private ChannelBuffer channelBuffer; | ||
37 | + private TlvHeader tlvHeader; | ||
38 | + private byte[] result; | ||
39 | + | ||
40 | + @Before | ||
41 | + public void setUp() throws Exception { | ||
42 | + administrativeGroup = new AdministrativeGroup(new TlvHeader()); | ||
43 | + } | ||
44 | + | ||
45 | + @After | ||
46 | + public void tearDown() throws Exception { | ||
47 | + administrativeGroup = null; | ||
48 | + channelBuffer = null; | ||
49 | + tlvHeader = null; | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * Tests administrativeGroup() getter method. | ||
54 | + */ | ||
55 | + @Test | ||
56 | + public void testGetAdministrativeGroup() throws Exception { | ||
57 | + administrativeGroup.setAdministrativeGroup(1); | ||
58 | + assertThat(administrativeGroup.administrativeGroup(), is(1)); | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * Tests administrativeGroup() setter method. | ||
63 | + */ | ||
64 | + @Test | ||
65 | + public void testSetAdministrativeGroup() throws Exception { | ||
66 | + administrativeGroup.setAdministrativeGroup(1); | ||
67 | + assertThat(administrativeGroup.administrativeGroup(), is(1)); | ||
68 | + } | ||
69 | + | ||
70 | + /** | ||
71 | + * Tests readFrom() method. | ||
72 | + */ | ||
73 | + @Test | ||
74 | + public void testReadFrom() throws Exception { | ||
75 | + tlvHeader = new TlvHeader(); | ||
76 | + tlvHeader.setTlvType(9); | ||
77 | + tlvHeader.setTlvLength(4); | ||
78 | + administrativeGroup = new AdministrativeGroup(tlvHeader); | ||
79 | + channelBuffer = ChannelBuffers.copiedBuffer(packet); | ||
80 | + administrativeGroup.readFrom(channelBuffer); | ||
81 | + assertThat(administrativeGroup.administrativeGroup(), is(notNullValue())); | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * Tests asBytes() method. | ||
86 | + */ | ||
87 | + @Test | ||
88 | + public void testAsBytes() throws Exception { | ||
89 | + result = administrativeGroup.asBytes(); | ||
90 | + assertThat(result, is(notNullValue())); | ||
91 | + } | ||
92 | + | ||
93 | + /** | ||
94 | + * Tests getLinkSubTypeTlvBodyAsByteArray() method. | ||
95 | + */ | ||
96 | + @Test | ||
97 | + public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception { | ||
98 | + result = administrativeGroup.tlvBodyAsBytes(); | ||
99 | + assertThat(result, is(notNullValue())); | ||
100 | + } | ||
101 | + | ||
102 | + /** | ||
103 | + * Tests to string method. | ||
104 | + */ | ||
105 | + @Test | ||
106 | + public void testToString() throws Exception { | ||
107 | + assertThat(administrativeGroup.toString(), is(notNullValue())); | ||
108 | + } | ||
109 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv; | ||
17 | + | ||
18 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
20 | +import org.junit.After; | ||
21 | +import org.junit.Before; | ||
22 | +import org.junit.Test; | ||
23 | +import org.onlab.packet.Ip4Address; | ||
24 | +import org.onosproject.isis.io.isispacket.tlv.TlvHeader; | ||
25 | + | ||
26 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
27 | +import static org.hamcrest.Matchers.is; | ||
28 | +import static org.hamcrest.Matchers.notNullValue; | ||
29 | + | ||
30 | +/** | ||
31 | + * Unit test class for InterfaceIpAddress. | ||
32 | + */ | ||
33 | +public class InterfaceIpAddressTest { | ||
34 | + private final byte[] packet = {1, 1, 1, 1}; | ||
35 | + private final byte[] packet1 = {}; | ||
36 | + private InterfaceIpAddress interfaceIpAddress; | ||
37 | + private TlvHeader tlvHeader; | ||
38 | + private Ip4Address ip4Address = Ip4Address.valueOf("1.1.1.1"); | ||
39 | + private byte[] result; | ||
40 | + private ChannelBuffer channelBuffer; | ||
41 | + | ||
42 | + @Before | ||
43 | + public void setUp() throws Exception { | ||
44 | + interfaceIpAddress = new InterfaceIpAddress(new TlvHeader()); | ||
45 | + } | ||
46 | + | ||
47 | + @After | ||
48 | + public void tearDown() throws Exception { | ||
49 | + interfaceIpAddress = null; | ||
50 | + tlvHeader = null; | ||
51 | + result = null; | ||
52 | + channelBuffer = null; | ||
53 | + } | ||
54 | + | ||
55 | + /** | ||
56 | + * Tests to string method. | ||
57 | + */ | ||
58 | + @Test | ||
59 | + public void testToString() throws Exception { | ||
60 | + assertThat(interfaceIpAddress.toString(), is(notNullValue())); | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * Tests addLocalInterfaceIPAddress() method. | ||
65 | + */ | ||
66 | + @Test | ||
67 | + public void testAddLocalInterfaceIPAddress() throws Exception { | ||
68 | + interfaceIpAddress.addLocalInterfaceIPAddress(ip4Address); | ||
69 | + assertThat(interfaceIpAddress, is(notNullValue())); | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * Tests readFrom() method. | ||
74 | + */ | ||
75 | + @Test | ||
76 | + public void testReadFrom() { | ||
77 | + tlvHeader = new TlvHeader(); | ||
78 | + tlvHeader.setTlvType(3); | ||
79 | + tlvHeader.setTlvLength(4); | ||
80 | + interfaceIpAddress = new InterfaceIpAddress(tlvHeader); | ||
81 | + channelBuffer = ChannelBuffers.copiedBuffer(packet); | ||
82 | + interfaceIpAddress.readFrom(channelBuffer); | ||
83 | + assertThat(interfaceIpAddress, is(notNullValue())); | ||
84 | + } | ||
85 | + | ||
86 | + /** | ||
87 | + * Tests readFrom() method. | ||
88 | + */ | ||
89 | + @Test | ||
90 | + public void testReadFrom1() throws Exception { | ||
91 | + tlvHeader = new TlvHeader(); | ||
92 | + tlvHeader.setTlvType(3); | ||
93 | + tlvHeader.setTlvLength(4); | ||
94 | + interfaceIpAddress = new InterfaceIpAddress(tlvHeader); | ||
95 | + channelBuffer = ChannelBuffers.copiedBuffer(packet1); | ||
96 | + interfaceIpAddress.readFrom(channelBuffer); | ||
97 | + assertThat(interfaceIpAddress, is(notNullValue())); | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * Tests asBytes() method. | ||
102 | + */ | ||
103 | + @Test | ||
104 | + public void testAsBytes() throws Exception { | ||
105 | + result = interfaceIpAddress.asBytes(); | ||
106 | + assertThat(result, is(notNullValue())); | ||
107 | + } | ||
108 | + | ||
109 | + /** | ||
110 | + * Tests getLinkSubTypeTlvBodyAsByteArray() method. | ||
111 | + */ | ||
112 | + @Test | ||
113 | + public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception { | ||
114 | + result = interfaceIpAddress.tlvBodyAsBytes(); | ||
115 | + assertThat(result, is(notNullValue())); | ||
116 | + } | ||
117 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv; | ||
17 | + | ||
18 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
20 | +import org.junit.After; | ||
21 | +import org.junit.Before; | ||
22 | +import org.junit.Test; | ||
23 | +import org.onosproject.isis.io.isispacket.tlv.TlvHeader; | ||
24 | + | ||
25 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
26 | +import static org.hamcrest.Matchers.is; | ||
27 | +import static org.hamcrest.Matchers.notNullValue; | ||
28 | + | ||
29 | +/** | ||
30 | + * Unit test class for MaximumBandwidth. | ||
31 | + */ | ||
32 | +public class MaximumBandwidthTest { | ||
33 | + | ||
34 | + private final byte[] packet = {0, 0, 0, 0}; | ||
35 | + private MaximumBandwidth maximumBandwidth; | ||
36 | + private TlvHeader header; | ||
37 | + private ChannelBuffer channelBuffer; | ||
38 | + private byte[] result; | ||
39 | + | ||
40 | + @Before | ||
41 | + public void setUp() throws Exception { | ||
42 | + maximumBandwidth = new MaximumBandwidth(new TlvHeader()); | ||
43 | + } | ||
44 | + | ||
45 | + @After | ||
46 | + public void tearDown() throws Exception { | ||
47 | + maximumBandwidth = null; | ||
48 | + header = null; | ||
49 | + channelBuffer = null; | ||
50 | + result = null; | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * Tests maximumBandwidth() setter method. | ||
55 | + */ | ||
56 | + @Test | ||
57 | + public void testSetMaximumBandwidth() throws Exception { | ||
58 | + maximumBandwidth.setMaximumBandwidth(123456.00f); | ||
59 | + assertThat(maximumBandwidth, is(notNullValue())); | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * Tests readFrom() method. | ||
64 | + */ | ||
65 | + @Test | ||
66 | + public void testReadFrom() throws Exception { | ||
67 | + header = new TlvHeader(); | ||
68 | + header.setTlvType(6); | ||
69 | + header.setTlvLength(4); | ||
70 | + channelBuffer = ChannelBuffers.copiedBuffer(packet); | ||
71 | + maximumBandwidth = new MaximumBandwidth(header); | ||
72 | + maximumBandwidth.readFrom(channelBuffer); | ||
73 | + assertThat(maximumBandwidth, is(notNullValue())); | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * Tests asBytes() method. | ||
78 | + */ | ||
79 | + @Test | ||
80 | + public void testAsBytes() throws Exception { | ||
81 | + result = maximumBandwidth.asBytes(); | ||
82 | + assertThat(result, is(notNullValue())); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Tests to string method. | ||
87 | + */ | ||
88 | + @Test | ||
89 | + public void testToString() throws Exception { | ||
90 | + assertThat(maximumBandwidth.toString(), is(notNullValue())); | ||
91 | + } | ||
92 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv; | ||
17 | + | ||
18 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
20 | +import org.junit.After; | ||
21 | +import org.junit.Before; | ||
22 | +import org.junit.Test; | ||
23 | +import org.onosproject.isis.io.isispacket.tlv.TlvHeader; | ||
24 | + | ||
25 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
26 | +import static org.hamcrest.Matchers.is; | ||
27 | +import static org.hamcrest.Matchers.notNullValue; | ||
28 | + | ||
29 | +/** | ||
30 | + * Unit test class for MaximumReservableBandwidth. | ||
31 | + */ | ||
32 | +public class MaximumReservableBandwidthTest { | ||
33 | + | ||
34 | + private final byte[] packet = {0, 0, 0, 0}; | ||
35 | + private MaximumReservableBandwidth maximumReservableBandwidth; | ||
36 | + private TlvHeader header; | ||
37 | + private ChannelBuffer channelBuffer; | ||
38 | + private byte[] result; | ||
39 | + | ||
40 | + @Before | ||
41 | + public void setUp() throws Exception { | ||
42 | + maximumReservableBandwidth = new MaximumReservableBandwidth(new TlvHeader()); | ||
43 | + } | ||
44 | + | ||
45 | + @After | ||
46 | + public void tearDown() throws Exception { | ||
47 | + maximumReservableBandwidth = null; | ||
48 | + header = null; | ||
49 | + channelBuffer = null; | ||
50 | + result = null; | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * Tests maximumBandwidth() setter method. | ||
55 | + */ | ||
56 | + @Test | ||
57 | + public void testSetMaximumBandwidth() throws Exception { | ||
58 | + maximumReservableBandwidth.setMaximumBandwidth(123456.78f); | ||
59 | + assertThat(maximumReservableBandwidth, is(notNullValue())); | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * Tests readFrom() method. | ||
64 | + */ | ||
65 | + @Test | ||
66 | + public void testReadFrom() throws Exception { | ||
67 | + header = new TlvHeader(); | ||
68 | + header.setTlvType(6); | ||
69 | + header.setTlvLength(4); | ||
70 | + channelBuffer = ChannelBuffers.copiedBuffer(packet); | ||
71 | + maximumReservableBandwidth = new MaximumReservableBandwidth(header); | ||
72 | + maximumReservableBandwidth.readFrom(channelBuffer); | ||
73 | + assertThat(maximumReservableBandwidth, is(notNullValue())); | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * Tests asBytes() method. | ||
78 | + */ | ||
79 | + @Test | ||
80 | + public void testAsBytes() throws Exception { | ||
81 | + result = maximumReservableBandwidth.asBytes(); | ||
82 | + assertThat(result, is(notNullValue())); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Tests getLinkSubTypeTlvBodyAsByteArray() method. | ||
87 | + */ | ||
88 | + @Test | ||
89 | + public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception { | ||
90 | + result = maximumReservableBandwidth.tlvBodyAsBytes(); | ||
91 | + assertThat(result, is(notNullValue())); | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Tests to string method. | ||
96 | + */ | ||
97 | + @Test | ||
98 | + public void testToString() throws Exception { | ||
99 | + assertThat(maximumReservableBandwidth.toString(), is(notNullValue())); | ||
100 | + } | ||
101 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv; | ||
17 | + | ||
18 | +import org.easymock.EasyMock; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
20 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
23 | +import org.junit.Test; | ||
24 | +import org.onosproject.isis.io.isispacket.tlv.TlvHeader; | ||
25 | + | ||
26 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
27 | +import static org.hamcrest.Matchers.is; | ||
28 | +import static org.hamcrest.Matchers.notNullValue; | ||
29 | + | ||
30 | +/** | ||
31 | + * Unit test class for SubTlvFinder. | ||
32 | + */ | ||
33 | +public class SubTlvFinderTest { | ||
34 | + private final byte[] packet1 = {0, 0, 0, 1}; | ||
35 | + private TlvHeader tlvHeader; | ||
36 | + private ChannelBuffer channelBuffer; | ||
37 | + private TrafficEngineeringSubTlv tlv; | ||
38 | + | ||
39 | + @Before | ||
40 | + public void setUp() throws Exception { | ||
41 | + tlvHeader = new TlvHeader(); | ||
42 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
43 | + } | ||
44 | + | ||
45 | + @After | ||
46 | + public void tearDown() throws Exception { | ||
47 | + tlvHeader = null; | ||
48 | + channelBuffer = null; | ||
49 | + } | ||
50 | + | ||
51 | + @Test | ||
52 | + public void testFindSubTlv() throws Exception { | ||
53 | + | ||
54 | + tlvHeader.setTlvLength(4); | ||
55 | + tlvHeader.setTlvType(SubTlvType.ADMINISTRATIVEGROUP.value()); | ||
56 | + AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader); | ||
57 | + channelBuffer = ChannelBuffers.copiedBuffer(packet1); | ||
58 | + tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer); | ||
59 | + assertThat(tlv, is(notNullValue())); | ||
60 | + | ||
61 | + tlvHeader = new TlvHeader(); | ||
62 | + tlvHeader.setTlvLength(4); | ||
63 | + tlvHeader.setTlvType(SubTlvType.TRAFFICENGINEERINGMETRIC.value()); | ||
64 | + TrafficEngineeringMetric trafficEngineeringMetric = new TrafficEngineeringMetric(tlvHeader); | ||
65 | + channelBuffer = ChannelBuffers.copiedBuffer(packet1); | ||
66 | + tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer); | ||
67 | + assertThat(tlv, is(notNullValue())); | ||
68 | + | ||
69 | + tlvHeader = new TlvHeader(); | ||
70 | + tlvHeader.setTlvLength(4); | ||
71 | + tlvHeader.setTlvType(SubTlvType.MAXIMUMBANDWIDTH.value()); | ||
72 | + MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader); | ||
73 | + channelBuffer = ChannelBuffers.copiedBuffer(packet1); | ||
74 | + tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer); | ||
75 | + assertThat(tlv, is(notNullValue())); | ||
76 | + | ||
77 | + tlvHeader = new TlvHeader(); | ||
78 | + tlvHeader.setTlvLength(4); | ||
79 | + tlvHeader.setTlvType(SubTlvType.MAXIMUMRESERVABLEBANDWIDTH.value()); | ||
80 | + MaximumReservableBandwidth maximumReservableBandwidth = new MaximumReservableBandwidth(tlvHeader); | ||
81 | + channelBuffer = ChannelBuffers.copiedBuffer(packet1); | ||
82 | + tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer); | ||
83 | + assertThat(tlv, is(notNullValue())); | ||
84 | + | ||
85 | + tlvHeader = new TlvHeader(); | ||
86 | + tlvHeader.setTlvLength(4); | ||
87 | + tlvHeader.setTlvType(SubTlvType.UNRESERVEDBANDWIDTH.value()); | ||
88 | + UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader); | ||
89 | + channelBuffer = ChannelBuffers.copiedBuffer(packet1); | ||
90 | + tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer); | ||
91 | + assertThat(tlv, is(notNullValue())); | ||
92 | + | ||
93 | + tlvHeader = new TlvHeader(); | ||
94 | + tlvHeader.setTlvLength(4); | ||
95 | + tlvHeader.setTlvType(SubTlvType.INTERFACEADDRESS.value()); | ||
96 | + InterfaceIpAddress ipInterfaceAddressTlv = new InterfaceIpAddress(tlvHeader); | ||
97 | + channelBuffer = ChannelBuffers.copiedBuffer(packet1); | ||
98 | + tlv = SubTlvFinder.findSubTlv(tlvHeader, channelBuffer); | ||
99 | + assertThat(tlv, is(notNullValue())); | ||
100 | + } | ||
101 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +package org.onosproject.isis.io.isispacket.tlv.subtlv; | ||
2 | + | ||
3 | +import org.easymock.EasyMock; | ||
4 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
5 | +import org.junit.After; | ||
6 | +import org.junit.Before; | ||
7 | +import org.junit.Test; | ||
8 | +import org.onosproject.isis.io.isispacket.tlv.TlvHeader; | ||
9 | + | ||
10 | +import java.util.List; | ||
11 | + | ||
12 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
13 | +import static org.hamcrest.Matchers.is; | ||
14 | +import static org.hamcrest.Matchers.notNullValue; | ||
15 | + | ||
16 | +/** | ||
17 | + * Unit test class for SubTlvToBytes. | ||
18 | + */ | ||
19 | +public class SubTlvToBytesTest { | ||
20 | + private TlvHeader tlvHeader; | ||
21 | + private ChannelBuffer channelBuffer; | ||
22 | + private List<Byte> tlv; | ||
23 | + | ||
24 | + @Before | ||
25 | + public void setUp() throws Exception { | ||
26 | + tlvHeader = new TlvHeader(); | ||
27 | + channelBuffer = EasyMock.createMock(ChannelBuffer.class); | ||
28 | + } | ||
29 | + | ||
30 | + @After | ||
31 | + public void tearDown() throws Exception { | ||
32 | + tlvHeader = null; | ||
33 | + channelBuffer = null; | ||
34 | + } | ||
35 | + | ||
36 | + @Test | ||
37 | + public void testTlvToBytes() throws Exception { | ||
38 | + tlvHeader.setTlvLength(4); | ||
39 | + tlvHeader.setTlvType(9); | ||
40 | + AdministrativeGroup administrativeGroup = new AdministrativeGroup(tlvHeader); | ||
41 | + tlv = SubTlvToBytes.tlvToBytes(administrativeGroup); | ||
42 | + assertThat(tlv, is(notNullValue())); | ||
43 | + | ||
44 | + tlvHeader = new TlvHeader(); | ||
45 | + tlvHeader.setTlvLength(4); | ||
46 | + tlvHeader.setTlvType(5); | ||
47 | + TrafficEngineeringMetric trafficEngineeringMetric = new TrafficEngineeringMetric(tlvHeader); | ||
48 | + tlv = SubTlvToBytes.tlvToBytes(trafficEngineeringMetric); | ||
49 | + assertThat(tlv, is(notNullValue())); | ||
50 | + | ||
51 | + tlvHeader = new TlvHeader(); | ||
52 | + tlvHeader.setTlvLength(4); | ||
53 | + tlvHeader.setTlvType(6); | ||
54 | + MaximumBandwidth maximumBandwidth = new MaximumBandwidth(tlvHeader); | ||
55 | + tlv = SubTlvToBytes.tlvToBytes(maximumBandwidth); | ||
56 | + assertThat(tlv, is(notNullValue())); | ||
57 | + | ||
58 | + tlvHeader = new TlvHeader(); | ||
59 | + tlvHeader.setTlvLength(4); | ||
60 | + tlvHeader.setTlvType(7); | ||
61 | + MaximumReservableBandwidth maximumReservableBandwidth = new MaximumReservableBandwidth(tlvHeader); | ||
62 | + tlv = SubTlvToBytes.tlvToBytes(maximumReservableBandwidth); | ||
63 | + assertThat(tlv, is(notNullValue())); | ||
64 | + | ||
65 | + tlvHeader = new TlvHeader(); | ||
66 | + tlvHeader.setTlvLength(4); | ||
67 | + tlvHeader.setTlvType(8); | ||
68 | + UnreservedBandwidth unreservedBandwidth = new UnreservedBandwidth(tlvHeader); | ||
69 | + tlv = SubTlvToBytes.tlvToBytes(unreservedBandwidth); | ||
70 | + assertThat(tlv, is(notNullValue())); | ||
71 | + } | ||
72 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv; | ||
17 | + | ||
18 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
20 | +import org.junit.After; | ||
21 | +import org.junit.Before; | ||
22 | +import org.junit.Test; | ||
23 | + | ||
24 | +import static org.hamcrest.CoreMatchers.is; | ||
25 | +import static org.hamcrest.CoreMatchers.notNullValue; | ||
26 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
27 | +import org.onosproject.isis.io.isispacket.tlv.TlvHeader; | ||
28 | + | ||
29 | +/** | ||
30 | + * Unit test class for TrafficEngineeringMetric. | ||
31 | + */ | ||
32 | +public class TrafficEngineeringMetricTest { | ||
33 | + | ||
34 | + private final byte[] packet = {0, 0, 1, 1}; | ||
35 | + private TrafficEngineeringMetric trafficEngineeringMetric; | ||
36 | + private TlvHeader header; | ||
37 | + private byte[] result; | ||
38 | + private ChannelBuffer channelBuffer; | ||
39 | + | ||
40 | + @Before | ||
41 | + public void setUp() throws Exception { | ||
42 | + trafficEngineeringMetric = new TrafficEngineeringMetric(new TlvHeader()); | ||
43 | + } | ||
44 | + | ||
45 | + @After | ||
46 | + public void tearDown() throws Exception { | ||
47 | + trafficEngineeringMetric = null; | ||
48 | + header = null; | ||
49 | + result = null; | ||
50 | + channelBuffer = null; | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * Tests trafficEngineeringMetric() setter method. | ||
55 | + */ | ||
56 | + @Test | ||
57 | + public void testSetTrafficEngineeringMetric() throws Exception { | ||
58 | + trafficEngineeringMetric.setTrafficEngineeringMetric(123456789L); | ||
59 | + assertThat(trafficEngineeringMetric, is(notNullValue())); | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * Tests readFrom() method. | ||
64 | + */ | ||
65 | + @Test | ||
66 | + public void testReadFrom() throws Exception { | ||
67 | + header = new TlvHeader(); | ||
68 | + header.setTlvLength(4); | ||
69 | + header.setTlvType(5); | ||
70 | + channelBuffer = ChannelBuffers.copiedBuffer(packet); | ||
71 | + trafficEngineeringMetric = new TrafficEngineeringMetric(header); | ||
72 | + trafficEngineeringMetric.readFrom(channelBuffer); | ||
73 | + assertThat(trafficEngineeringMetric, is(notNullValue())); | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * Tests asBytes() method. | ||
78 | + */ | ||
79 | + @Test | ||
80 | + public void testAsBytes() throws Exception { | ||
81 | + result = trafficEngineeringMetric.asBytes(); | ||
82 | + assertThat(result, is(notNullValue())); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Tests getLinkSubTypeTlvBodyAsByteArray() method. | ||
87 | + */ | ||
88 | + @Test | ||
89 | + public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception { | ||
90 | + result = trafficEngineeringMetric.tlvBodyAsBytes(); | ||
91 | + assertThat(result, is(notNullValue())); | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Tests to string method. | ||
96 | + */ | ||
97 | + @Test | ||
98 | + public void testToString() throws Exception { | ||
99 | + assertThat(trafficEngineeringMetric.toString(), is(notNullValue())); | ||
100 | + } | ||
101 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016-present 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.isis.io.isispacket.tlv.subtlv; | ||
17 | + | ||
18 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
19 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
20 | +import org.junit.After; | ||
21 | +import org.junit.Before; | ||
22 | +import org.junit.Test; | ||
23 | +import org.onosproject.isis.io.isispacket.tlv.TlvHeader; | ||
24 | + | ||
25 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
26 | +import static org.hamcrest.Matchers.is; | ||
27 | +import static org.hamcrest.Matchers.notNullValue; | ||
28 | + | ||
29 | +/** | ||
30 | + * Unit test class for UnreservedBandwidth. | ||
31 | + */ | ||
32 | +public class UnreservedBandwidthTest { | ||
33 | + | ||
34 | + private final byte[] packet = {0, 0, 0, 1}; | ||
35 | + private UnreservedBandwidth unreservedBandwidth; | ||
36 | + private TlvHeader header; | ||
37 | + private byte[] result; | ||
38 | + private ChannelBuffer channelBuffer; | ||
39 | + | ||
40 | + @Before | ||
41 | + public void setUp() throws Exception { | ||
42 | + unreservedBandwidth = new UnreservedBandwidth(new TlvHeader()); | ||
43 | + } | ||
44 | + | ||
45 | + @After | ||
46 | + public void tearDown() throws Exception { | ||
47 | + unreservedBandwidth = null; | ||
48 | + header = null; | ||
49 | + result = null; | ||
50 | + channelBuffer = null; | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * Tests to string method. | ||
55 | + */ | ||
56 | + @Test | ||
57 | + public void testToString() throws Exception { | ||
58 | + assertThat(unreservedBandwidth.toString(), is(notNullValue())); | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * Tests addUnReservedBandwidth() method. | ||
63 | + */ | ||
64 | + @Test | ||
65 | + public void testAddUnReservedBandwidth() throws Exception { | ||
66 | + unreservedBandwidth.addUnReservedBandwidth(123456.78f); | ||
67 | + assertThat(unreservedBandwidth, is(notNullValue())); | ||
68 | + } | ||
69 | + | ||
70 | + /** | ||
71 | + * Tests readFrom() method. | ||
72 | + */ | ||
73 | + @Test | ||
74 | + public void testReadFrom() throws Exception { | ||
75 | + header = new TlvHeader(); | ||
76 | + header.setTlvLength(4); | ||
77 | + header.setTlvType(8); | ||
78 | + channelBuffer = ChannelBuffers.copiedBuffer(packet); | ||
79 | + unreservedBandwidth = new UnreservedBandwidth(header); | ||
80 | + unreservedBandwidth.readFrom(channelBuffer); | ||
81 | + unreservedBandwidth.readFrom(channelBuffer); | ||
82 | + assertThat(unreservedBandwidth, is(notNullValue())); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * Tests asBytes() method. | ||
87 | + */ | ||
88 | + @Test | ||
89 | + public void testAsBytes() throws Exception { | ||
90 | + result = unreservedBandwidth.asBytes(); | ||
91 | + assertThat(result, is(notNullValue())); | ||
92 | + } | ||
93 | + | ||
94 | + /** | ||
95 | + * Tests getLinkSubTypeTlvBodyAsByteArray() method. | ||
96 | + */ | ||
97 | + @Test | ||
98 | + public void testGetLinkSubTypeTlvBodyAsByteArray() throws Exception { | ||
99 | + result = unreservedBandwidth.asBytes(); | ||
100 | + assertThat(result, is(notNullValue())); | ||
101 | + } | ||
102 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment