import java.util.List;
import java.util.Set;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Preconditions;
*/
public static final ASPath EMPTY = new ASPath();
private static final long serialVersionUID = 7951172606939897308L;
- private final Set<ASNumber> aggregatedAsPath;
- private final List<ASNumber> visibleAsPath;
+ private final Set<AsNumber> aggregatedAsPath;
+ private final List<AsNumber> visibleAsPath;
private ASPath() {
this.visibleAsPath = Collections.emptyList();
* @param visibleAsPath Ordered list of AS numbers in the path, corresponding to the concatenation of all
* AS_SEQUENCE components.
*/
- public ASPath(final List<ASNumber> visibleAsPath) {
+ public ASPath(final List<AsNumber> visibleAsPath) {
this.aggregatedAsPath = Collections.emptySet();
this.visibleAsPath = Collections.unmodifiableList(Preconditions.checkNotNull(visibleAsPath));
}
* @param aggregatedAsPath Unordered set of AS numbers in the path, corresponding to the concatenation of all AS_SET
* components.
*/
- public ASPath(final List<ASNumber> visibleAsPath, final Set<ASNumber> aggregatedAsPath) {
+ public ASPath(final List<AsNumber> visibleAsPath, final Set<AsNumber> aggregatedAsPath) {
Preconditions.checkNotNull(aggregatedAsPath);
Preconditions.checkNotNull(visibleAsPath);
this.aggregatedAsPath = Collections.unmodifiableSet(aggregatedAsPath);
*
* @return Ordered list of AS numbers.
*/
- public List<ASNumber> getVisibleAsPath() {
+ public List<AsNumber> getVisibleAsPath() {
return this.visibleAsPath;
}
*
* @return Unordered set of AS numbers.
*/
- public Set<ASNumber> getAggregatedAsPath() {
+ public Set<AsNumber> getAggregatedAsPath() {
return this.aggregatedAsPath;
}
import java.io.Serializable;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Preconditions;
*/
public class ASSpecificExtendedCommunity extends ExtendedCommunity implements Serializable {
private static final long serialVersionUID = 6490173838144366385L;
- private final ASNumber globalAdmin;
+ private final AsNumber globalAdmin;
private final byte[] localAdmin;
private final int subType;
* @param globalAdmin Globally-assigned namespace (AS number)
* @param localAdmin Locally-assigned value, has to be 4 bytes long
*/
- public ASSpecificExtendedCommunity(final boolean transitive, final int subType, final ASNumber globalAdmin, final byte[] localAdmin) {
+ public ASSpecificExtendedCommunity(final boolean transitive, final int subType, final AsNumber globalAdmin, final byte[] localAdmin) {
super(false, transitive);
Preconditions.checkArgument(subType > 0 && subType < 255, "Invalid Sub-Type");
Preconditions.checkArgument(localAdmin.length == 4, "Invalid Local Administrator");
/**
* @return Globally-assigned namespace
*/
- public final ASNumber getGlobalAdmin() {
+ public final AsNumber getGlobalAdmin() {
return this.globalAdmin;
}
import java.io.Serializable;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+
import com.google.common.base.Preconditions;
/**
* advertised outside a BGP confederation boundary (a stand-alone autonomous system that is not part of a
* confederation should be considered a confederation itself).
*/
- public static final Community NO_EXPORT = new Community(new ASNumber(0xFFFF), 0xFF01);
+ public static final Community NO_EXPORT = new Community(new AsNumber((long) 0xFFFF), 0xFF01);
/**
* NO_ADVERTISE community. All routes received carrying a communities attribute containing this value MUST NOT be
* advertised to other BGP peers.
*/
- public static final Community NO_ADVERTISE = new Community(new ASNumber(0xFFFF), 0xFF02);
+ public static final Community NO_ADVERTISE = new Community(new AsNumber((long) 0xFFFF), 0xFF02);
/**
* NO_EXPORT_SUBCONFED community. All routes received carrying a communities attribute containing this value MUST
* NOT be advertised to external BGP peers (this includes peers in other members autonomous systems inside a BGP
* confederation).
*/
- public static final Community NO_EXPORT_SUBCONFED = new Community(new ASNumber(0xFFFF), 0xFF03);
+ public static final Community NO_EXPORT_SUBCONFED = new Community(new AsNumber((long) 0xFFFF), 0xFF03);
private static final long serialVersionUID = -944853598551415685L;
private final int semantics;
- private final ASNumber as;
+ private final AsNumber as;
/**
* Create a new community tag for a particular AS number and semantics.
* @param as Global semantics namespace identifier (usually the tagging Autonomous System)
* @param semantics Sematics identifier (specific meaning defined externally by the namespace)
*/
- public Community(final ASNumber as, final int semantics) {
- Preconditions.checkArgument(as.getHighValue() == 0, "Invalid AS number specified");
+ public Community(final AsNumber as, final int semantics) {
Preconditions.checkArgument(semantics > 0 && semantics < 65535, "Invalid semantics specified");
this.semantics = semantics;
this.as = as;
/**
* Return ASNumber of community.
*
- * @return {@link ASNumber}
+ * @return {@link AsNumber}
*/
- public ASNumber getAs() {
+ public AsNumber getAs() {
return this.as;
}
final int asn = Integer.valueOf(parts[0]);
final int sem = Integer.valueOf(parts[1]);
- return new Community(new ASNumber(0, asn), sem);
+ return new Community(new AsNumber((long) asn), sem);
}
}
package org.opendaylight.protocol.bgp.concepts;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
- * @see <a href="http://tools.ietf.org/html/rfc4360#section-5">Route Origin Community</a>
+ * @see <a href="http://tools.ietf.org/html/rfc4360#section-5">Route Origin Community</a>
*/
public class RouteOriginCommunity extends ASSpecificExtendedCommunity {
private static final long serialVersionUID = 540725495203637583L;
/**
- * Construct a RouteOriginCommunity based on global and local
- * administrator values.
- *
+ * Construct a RouteOriginCommunity based on global and local administrator values.
+ *
* @param globalAdmin Global administrator (AS number)
* @param localAdmin Local administrator (AS-specific, opaque value)
*/
- public RouteOriginCommunity(final ASNumber globalAdmin, final byte[] localAdmin) {
+ public RouteOriginCommunity(final AsNumber globalAdmin, final byte[] localAdmin) {
super(false, 3, globalAdmin, localAdmin);
}
}
-
*/
package org.opendaylight.protocol.bgp.concepts;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
* @see <a href="http://tools.ietf.org/html/rfc4360#section-4">Route Target Community</a>
/**
*
- * @param globalAdmin Globally-administered identifier, i.e. an {@link ASNumber}
+ * @param globalAdmin Globally-administered identifier, i.e. an {@link AsNumber}
* @param localAdmin Locally-administered identifier
*/
- public RouteTargetCommunity(final ASNumber globalAdmin, final byte[] localAdmin) {
+ public RouteTargetCommunity(final AsNumber globalAdmin, final byte[] localAdmin) {
super(false, 2, globalAdmin, localAdmin);
}
}
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.protocol.bgp.concepts.ASPath;
-
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
public class ASPathTest {
- private ASNumber asn1, asn2, asn3, asn4, asn5, asn6, asn7, asn8;
+ private AsNumber asn1, asn2, asn3, asn4, asn5, asn6, asn7, asn8;
- private List<ASNumber> visibleAsPath;
- private Set<ASNumber> aggregatedAsPath;
+ private List<AsNumber> visibleAsPath;
+ private Set<AsNumber> aggregatedAsPath;
@Before
public void init() {
- asn1 = new ASNumber(100, 200);
- asn2 = new ASNumber(65534);
- asn3 = new ASNumber(0, 200);
- asn4 = new ASNumber(100, 199);
- asn5 = new ASNumber(99, 199);
- asn6 = new ASNumber(64538);
- asn7 = new ASNumber(0, 200);
- asn8 = new ASNumber(100, 0);
-
- visibleAsPath = new ArrayList<ASNumber>();
- aggregatedAsPath = new HashSet<ASNumber>();
-
- visibleAsPath.add(asn1);
- visibleAsPath.add(asn2);
- visibleAsPath.add(asn3);
- visibleAsPath.add(asn4);
-
- aggregatedAsPath.add(asn5);
- aggregatedAsPath.add(asn6);
- aggregatedAsPath.add(asn7);
- aggregatedAsPath.add(asn8);
+ this.asn1 = new AsNumber(429496729800L);
+ this.asn2 = new AsNumber((long) 65534);
+ this.asn3 = new AsNumber((long) 200);
+ this.asn4 = new AsNumber(429496729799L);
+ this.asn5 = new AsNumber(425201762503L);
+ this.asn6 = new AsNumber((long) 64538);
+ this.asn7 = new AsNumber((long) 200);
+ this.asn8 = new AsNumber(429496729600L);
+
+ this.visibleAsPath = new ArrayList<AsNumber>();
+ this.aggregatedAsPath = new HashSet<AsNumber>();
+
+ this.visibleAsPath.add(this.asn1);
+ this.visibleAsPath.add(this.asn2);
+ this.visibleAsPath.add(this.asn3);
+ this.visibleAsPath.add(this.asn4);
+
+ this.aggregatedAsPath.add(this.asn5);
+ this.aggregatedAsPath.add(this.asn6);
+ this.aggregatedAsPath.add(this.asn7);
+ this.aggregatedAsPath.add(this.asn8);
}
@Test
public void testGetXXXPath() {
- ASPath asp1 = ASPath.EMPTY;
+ final ASPath asp1 = ASPath.EMPTY;
assertEquals(0, asp1.getVisibleAsPath().size());
assertEquals(0, asp1.getAggregatedAsPath().size());
- ASPath asp2 = new ASPath(visibleAsPath);
+ final ASPath asp2 = new ASPath(this.visibleAsPath);
assertEquals(4, asp2.getVisibleAsPath().size());
assertEquals(0, asp2.getAggregatedAsPath().size());
- ASPath asp3 = new ASPath(visibleAsPath, aggregatedAsPath);
+ final ASPath asp3 = new ASPath(this.visibleAsPath, this.aggregatedAsPath);
assertEquals(4, asp3.getVisibleAsPath().size());
assertEquals(4, asp3.getAggregatedAsPath().size());
}
@Test
public void testEqualsHashCode() {
- ASPath asp1 = ASPath.EMPTY;
- ASPath asp2 = asp1;
+ final ASPath asp1 = ASPath.EMPTY;
+ final ASPath asp2 = asp1;
assertEquals(asp1, asp2);
assertEquals(asp1.hashCode(), asp2.hashCode());
assertNotNull(asp1);
assertThat(asp1, not(new Object()));
- ASPath asp3 = new ASPath(visibleAsPath, aggregatedAsPath);
+ final ASPath asp3 = new ASPath(this.visibleAsPath, this.aggregatedAsPath);
assertThat(asp1, not(equalTo(asp3)));
assertThat(asp1.hashCode(), not(equalTo(asp3.hashCode())));
- ASPath asp4 = new ASPath(new ArrayList<ASNumber>(), aggregatedAsPath);
+ final ASPath asp4 = new ASPath(new ArrayList<AsNumber>(), this.aggregatedAsPath);
assertThat(asp3, not(equalTo(asp4)));
}
@Test
public void testToString() {
- ASPath asp = new ASPath(visibleAsPath, aggregatedAsPath);
+ final ASPath asp = new ASPath(this.visibleAsPath, this.aggregatedAsPath);
assertNotNull(asp.toString());
}
import static org.junit.Assert.fail;
import org.junit.Test;
-import org.opendaylight.protocol.bgp.concepts.ASSpecificExtendedCommunity;
-
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
public class ASSpecificExtendedCommunityTest {
private final boolean transitive = true;
private final int subType = 123;
- private final ASNumber globalAdmin = new ASNumber(100, 200);
+ private final AsNumber globalAdmin = new AsNumber(429496729800L);
private final byte[] localAdmin = new byte[] { 10, 0, 0, 1 };
@Test
public void testGetSubType() {
final ASSpecificExtendedCommunity asSpecExCom = new ASSpecificExtendedCommunity(this.transitive, this.subType, this.globalAdmin, this.localAdmin);
assertEquals(123, asSpecExCom.getSubType());
- assertEquals(new ASNumber(100, 200), asSpecExCom.getGlobalAdmin());
+ assertEquals(new AsNumber(429496729800L), asSpecExCom.getGlobalAdmin());
assertArrayEquals(new byte[] { 10, 0, 0, 1 }, asSpecExCom.getLocalAdmin());
final ASSpecificExtendedCommunity a1 = new ASSpecificExtendedCommunity(this.transitive, this.subType, this.globalAdmin, this.localAdmin);
import static org.junit.Assert.fail;
import org.junit.Test;
-import org.opendaylight.protocol.bgp.concepts.Community;
-import org.opendaylight.protocol.bgp.concepts.ExtendedCommunity;
-import org.opendaylight.protocol.bgp.concepts.OpaqueExtendedCommunity;
-import org.opendaylight.protocol.bgp.concepts.RouteOriginCommunity;
-
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
public class CommunityTest {
@Test
public void testCommunity() {
- new Community(new ASNumber(0, 10), 222);
- final ASNumber as = new ASNumber(12);
+ new Community(new AsNumber((long) 10), 222);
+ final AsNumber as = new AsNumber((long) 12);
final Community c = new Community(as, 12);
assertEquals(as, c.getAs());
assertEquals(12, c.getSemantics());
@Test
public void testOverflows() {
try {
- new Community(new ASNumber(0, 10), -2);
+ new Community(new AsNumber((long) 10), -2);
fail("Semantics under range.");
} catch (final IllegalArgumentException e) {
assertEquals("Invalid semantics specified", e.getMessage());
}
try {
- new Community(new ASNumber(5, 10), 5);
- fail("AS high number cannot be null");
- } catch (final IllegalArgumentException e) {
- assertEquals("Invalid AS number specified", e.getMessage());
- }
- try {
- new Community(new ASNumber(0, 10), 65536);
+ new Community(new AsNumber((long) 10), 65536);
fail("Semantics above range.");
} catch (final IllegalArgumentException e) {
assertEquals("Invalid semantics specified", e.getMessage());
@Test
public void testEquals() {
- final Community c1 = new Community(new ASNumber(0, 10), 222);
- final Community c2 = new Community(new ASNumber(0, 10), 222);
+ final Community c1 = new Community(new AsNumber((long) 10), 222);
+ final Community c2 = new Community(new AsNumber((long) 10), 222);
assertEquals(c1, c2);
assertThat(c1, not(new Object()));
}
@Test
public void testHashCode() {
- final Community c1 = new Community(new ASNumber(0, 10), 222);
- final Community c2 = new Community(new ASNumber(0, 10), 222);
+ final Community c1 = new Community(new AsNumber((long) 10), 222);
+ final Community c2 = new Community(new AsNumber((long) 10), 222);
assertEquals(c1.hashCode(), c2.hashCode());
}
@Test
public void testToString() {
- final Community c = new Community(new ASNumber(0, 10), 222);
+ final Community c = new Community(new AsNumber((long) 10), 222);
assertNotNull(c.toString());
}
@Test
public void testValueOf() {
final Community comm = Community.valueOf("12:50");
- assertEquals(comm, new Community(new ASNumber(0, 12), 50));
+ assertEquals(comm, new Community(new AsNumber((long) 12), 50));
}
@Test
public void testExtendedCommunity() {
final ExtendedCommunity ec = new OpaqueExtendedCommunity(false, 5, new byte[] { 1, 2, 3, 4, 5, 6 });
- final Object ec2 = new RouteOriginCommunity(new ASNumber(84), new byte[] { 1, 2, 3, 4 });
+ final Object ec2 = new RouteOriginCommunity(new AsNumber((long) 84), new byte[] { 1, 2, 3, 4 });
assertNotSame(ec, ec2);
assertEquals(ec, new OpaqueExtendedCommunity(false, 5, new byte[] { 1, 2, 3, 4, 5, 6 }));
assertEquals(ec.hashCode(), (new OpaqueExtendedCommunity(false, 5, new byte[] { 1, 2, 3, 4, 5, 6 })).hashCode());
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.protocol.bgp.concepts.RouteOriginCommunity;
-
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
public class RouteOriginCommunityTest {
@Before
public void init() {
- final ASNumber globalAdmin = new ASNumber(100, 200);
+ final AsNumber globalAdmin = new AsNumber(429496729800L);
final byte[] localAdmin = new byte[] { 10, 0, 0, 1 };
this.community = new RouteOriginCommunity(globalAdmin, localAdmin);
}
@Test
public void testGetGlobalAdmin() {
- final ASNumber testAsn = new ASNumber(100, 200);
+ final AsNumber testAsn = new AsNumber(429496729800L);
assertEquals(this.community.getGlobalAdmin(), testAsn);
}
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.protocol.bgp.concepts.RouteTargetCommunity;
-
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
public class RouteTargetCommunityTest {
@Before
public void init() {
- final ASNumber globalAdmin = new ASNumber(100, 200);
+ final AsNumber globalAdmin = new AsNumber(429496729800L);
final byte[] localAdmin = new byte[] { 10, 0, 0, 1 };
this.community = new RouteTargetCommunity(globalAdmin, localAdmin);
}
@Test
public void testGetGlobalAdmin() {
- final ASNumber testAsn = new ASNumber(100, 200);
+ final AsNumber testAsn = new AsNumber(429496729800L);
assertEquals(this.community.getGlobalAdmin(), testAsn);
}
package org.opendaylight.protocol.bgp.linkstate;
import org.opendaylight.protocol.concepts.Identifier;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.base.Preconditions;
public final class NodeIdentifier implements Identifier {
private static final long serialVersionUID = 1L;
- private final ASNumber asNumber;
+ private final AsNumber asNumber;
private final DomainIdentifier domainIdentifier;
private final AreaIdentifier areaIdentifier;
private final RouterIdentifier routerIdentifier;
- public NodeIdentifier(final ASNumber as, final DomainIdentifier domain, final AreaIdentifier area, final RouterIdentifier router) {
+ public NodeIdentifier(final AsNumber as, final DomainIdentifier domain, final AreaIdentifier area, final RouterIdentifier router) {
this.routerIdentifier = Preconditions.checkNotNull(router, "Router Identifier is mandatory.");
this.asNumber = as;
this.domainIdentifier = domain;
*
* @return AS of residence
*/
- public ASNumber getAsNumber() {
+ public AsNumber getAsNumber() {
return this.asNumber;
}
*/
package org.opendaylight.protocol.bgp.linkstate;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
public final class NodeIdentifierFactory {
- private final ASNumber as;
+ private final AsNumber as;
private final DomainIdentifier domain;
private final AreaIdentifier area;
- public NodeIdentifierFactory(final ASNumber as, final DomainIdentifier domain, final AreaIdentifier area) {
+ public NodeIdentifierFactory(final AsNumber as, final DomainIdentifier domain, final AreaIdentifier area) {
this.as = as;
this.area = area;
this.domain = domain;
}
public NodeIdentifier identifierForRouter(final RouterIdentifier router) {
- return new NodeIdentifier(as, domain, area, router);
+ return new NodeIdentifier(this.as, this.domain, this.area, router);
}
public static NodeIdentifier localIdentifier(final RouterIdentifier router) {
import static org.junit.Assert.fail;
import org.junit.Test;
-
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.concepts.IPv6;
import org.opendaylight.protocol.concepts.ISOSystemIdentifier;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
public class NodeIdentifierTest {
- private final NodeIdentifierFactory f = new NodeIdentifierFactory(new ASNumber(25600, 0), null, null);
+ private final NodeIdentifierFactory f = new NodeIdentifierFactory(new AsNumber(109951162777600L), null, null);
@Test
public void testHashCodeEquals() {
import org.opendaylight.protocol.bgp.parser.BGPMessage;
import org.opendaylight.protocol.bgp.parser.BGPParameter;
-
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
* Representation of BGPOpen message.
*/
public static final int BGP_VERSION = 4;
- private final ASNumber myAS;
+ private final AsNumber myAS;
private final short holdTime;
* @param bgpId IPv4 Address of the BGP speaker
* @param optParams List of optional parameters
*/
- public BGPOpenMessage(final ASNumber myAS, final short holdTime, final IPv4Address bgpId, final List<BGPParameter> optParams) {
+ public BGPOpenMessage(final AsNumber myAS, final short holdTime, final IPv4Address bgpId, final List<BGPParameter> optParams) {
super();
this.myAS = myAS;
this.holdTime = holdTime;
*
* @return myAS
*/
- public ASNumber getMyAS() {
+ public AsNumber getMyAS() {
return this.myAS;
}
*/
package org.opendaylight.protocol.bgp.parser.parameter;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
* AS 4B Numbers capability.
*/
public static final int CODE = 65;
- private final ASNumber as;
+ private final AsNumber as;
- public AS4BytesCapability(final ASNumber as) {
+ public AS4BytesCapability(final AsNumber as) {
super(CODE);
this.as = as;
}
*
* @return 4B AS Number
*/
- public ASNumber getASNumber() {
+ public AsNumber getASNumber() {
return this.as;
}
import org.opendaylight.protocol.bgp.parser.parameter.CapabilityParameter;
import org.opendaylight.protocol.bgp.parser.parameter.GracefulCapability;
import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.concepts.Metric;
import org.opendaylight.protocol.concepts.TEMetric;
import org.opendaylight.protocol.framework.DocumentedException;
import org.opendaylight.protocol.util.DefaultingTypesafeContainer;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
final BGPParameter tlv3 = new GracefulCapability(false, 0, tt);
- final BGPParameter tlv4 = new AS4BytesCapability(new ASNumber(40));
+ final BGPParameter tlv4 = new AS4BytesCapability(new AsNumber((long) 40));
assertFalse(((GracefulCapability) tlv3).isRestartFlag());
assertNotSame(((MultiprotocolCapability) tlv1).getAfi(), ((MultiprotocolCapability) tlv2).getAfi());
- assertEquals(40, ((AS4BytesCapability) tlv4).getASNumber().getAsn());
+ assertEquals(40, ((AS4BytesCapability) tlv4).getASNumber().getValue().longValue());
- assertEquals(new AS4BytesCapability(new ASNumber(40)).toString(), tlv4.toString());
+ assertEquals(new AS4BytesCapability(new AsNumber((long) 40)).toString(), tlv4.toString());
}
@Test
@Test
public void testBGPOpenMessage() {
- final BGPMessage msg = new BGPOpenMessage(new ASNumber(58), (short) 5, null, null);
+ final BGPMessage msg = new BGPOpenMessage(new AsNumber((long) 58), (short) 5, null, null);
assertNull(((BGPOpenMessage) msg).getOptParams());
}
@Test
public void testToString() {
- final BGPMessage o = new BGPOpenMessage(new ASNumber(58), (short) 5, null, null);
+ final BGPMessage o = new BGPOpenMessage(new AsNumber((long) 58), (short) 5, null, null);
final BGPMessage n = new BGPNotificationMessage(BGPError.ATTR_FLAGS_MISSING);
assertNotSame(o.toString(), n.toString());
}
import java.util.Map;
import java.util.Map.Entry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPParameter;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.bgp.parser.impl.message.open.BGPParameterParser;
import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4Address;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.primitives.UnsignedBytes;
offset += VERSION_SIZE;
// When our AS number does not fit into two bytes, we report it as AS_TRANS
- ASNumber openAS = msg.getMyAS();
- if (openAS.getHighValue() != 0)
- openAS = ASNumber.TRANS;
+ AsNumber openAS = msg.getMyAS();
+ if (openAS.getValue().longValue() > Integer.MAX_VALUE)
+ openAS = new AsNumber((long) 2345);
- System.arraycopy(ByteArray.intToBytes(openAS.getLowValue()), 2, msgBody, offset, AS_SIZE);
+ System.arraycopy(ByteArray.longToBytes(openAS.getValue()), 6, msgBody, offset, AS_SIZE);
offset += AS_SIZE;
System.arraycopy(ByteArray.shortToBytes(msg.getHoldTime()), 0, msgBody, offset, HOLD_TIME_SIZE);
ByteArray.intToBytes(BGPOpenMessage.BGP_VERSION), 2, 2));
int offset = VERSION_SIZE;
- final ASNumber as = new ASNumber(0, ByteArray.bytesToInt(ByteArray.subByte(bytes, offset, AS_SIZE)));
+ final AsNumber as = new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, offset, AS_SIZE)));
offset += AS_SIZE;
// TODO: BAD_PEER_AS Error: when is an AS unacceptable?
import org.opendaylight.protocol.bgp.parser.parameter.CapabilityParameter;
import org.opendaylight.protocol.bgp.parser.parameter.GracefulCapability;
import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
import org.slf4j.Logger;
}
private static byte[] putAS4BytesParameterValue(final AS4BytesCapability param) {
- return ByteArray.subByte(ByteArray.longToBytes(param.getASNumber().getAsn()), 4, 4);
+ return ByteArray.subByte(ByteArray.longToBytes(param.getASNumber().getValue()), 4, 4);
}
private static MultiprotocolCapability parseMultiProtocolParameterValue(final byte[] bytes) throws BGPParsingException {
}
private static AS4BytesCapability parseAS4BParameterValue(final byte[] bytes) {
- return new AS4BytesCapability(new ASNumber(ByteArray.bytesToLong(bytes)));
+ return new AS4BytesCapability(new AsNumber(ByteArray.bytesToLong(bytes)));
}
private static byte[] putAfi(final BgpAddressFamily afi) {
import java.util.HashSet;
import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
- *
- * Representation of one AS Path Segment. It is, in fact, a TLV, but the length
- * field is representing the count of AS Numbers in the collection (in its
- * value). If the segment is of type AS_SEQUENCE, the collection is a List, if
- * AS_SET, the collection is a Set.
- *
+ *
+ * Representation of one AS Path Segment. It is, in fact, a TLV, but the length field is representing the count of AS
+ * Numbers in the collection (in its value). If the segment is of type AS_SEQUENCE, the collection is a List, if AS_SET,
+ * the collection is a Set.
+ *
*/
public class AsPathSegmentParser {
}
}
- static Collection<ASNumber> parseAsPathSegment(final SegmentType type,
- final int count, final byte[] bytes) {
- final Collection<ASNumber> coll = (type == SegmentType.AS_SEQUENCE) ? new ArrayList<ASNumber>()
- : new HashSet<ASNumber>();
+ static Collection<AsNumber> parseAsPathSegment(final SegmentType type, final int count, final byte[] bytes) {
+ final Collection<AsNumber> coll = (type == SegmentType.AS_SEQUENCE) ? new ArrayList<AsNumber>() : new HashSet<AsNumber>();
int byteOffset = 0;
for (int i = 0; i < count; i++) {
- coll.add(new ASNumber(ByteArray.bytesToLong(ByteArray.subByte(
- bytes, byteOffset, AS_NUMBER_LENGTH))));
+ coll.add(new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(bytes, byteOffset, AS_NUMBER_LENGTH))));
byteOffset += AS_NUMBER_LENGTH;
}
return coll;
import org.opendaylight.protocol.bgp.concepts.RouteTargetCommunity;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4Address;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+
import com.google.common.annotations.VisibleForTesting;
import com.google.common.primitives.UnsignedBytes;
} else if (Arrays.equals(bytes, new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x03 })) {
return Community.NO_EXPORT_SUBCONFED;
}
- return new Community(new ASNumber(ByteArray.bytesToLong(Arrays.copyOfRange(bytes, 0, AS_NUMBER_LENGTH))), ByteArray.bytesToInt(Arrays.copyOfRange(
+ return new Community(new AsNumber(ByteArray.bytesToLong(Arrays.copyOfRange(bytes, 0, AS_NUMBER_LENGTH))), ByteArray.bytesToInt(Arrays.copyOfRange(
bytes, AS_NUMBER_LENGTH, AS_NUMBER_LENGTH + AS_NUMBER_LENGTH)));
}
switch (type) {
case 0:
if (subType == 2) {
- return new RouteTargetCommunity(new ASNumber(ByteArray.bytesToInt(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
+ return new RouteTargetCommunity(new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
value, AS_NUMBER_LENGTH, AS_LOCAL_ADMIN_LENGTH));
} else if (subType == 3) {
- return new RouteOriginCommunity(new ASNumber(ByteArray.bytesToInt(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
+ return new RouteOriginCommunity(new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
value, AS_NUMBER_LENGTH, AS_LOCAL_ADMIN_LENGTH));
} else
- return new ASSpecificExtendedCommunity(false, subType, new ASNumber(ByteArray.bytesToInt(ByteArray.subByte(value, 0,
+ return new ASSpecificExtendedCommunity(false, subType, new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(value, 0,
AS_NUMBER_LENGTH))), ByteArray.subByte(value, AS_NUMBER_LENGTH, AS_LOCAL_ADMIN_LENGTH));
case 40: // 01000000
- return new ASSpecificExtendedCommunity(true, subType, new ASNumber(ByteArray.bytesToInt(ByteArray.subByte(value, 0,
+ return new ASSpecificExtendedCommunity(true, subType, new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(value, 0,
AS_NUMBER_LENGTH))), ByteArray.subByte(value, AS_NUMBER_LENGTH, AS_LOCAL_ADMIN_LENGTH));
case 2:
if (subType == 2) {
- return new RouteTargetCommunity(new ASNumber(ByteArray.bytesToInt(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
+ return new RouteTargetCommunity(new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
value, AS_NUMBER_LENGTH, AS_LOCAL_ADMIN_LENGTH));
} else if (subType == 3) {
- return new RouteOriginCommunity(new ASNumber(ByteArray.bytesToInt(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
+ return new RouteOriginCommunity(new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
value, AS_NUMBER_LENGTH, AS_LOCAL_ADMIN_LENGTH));
} else
throw new BGPDocumentedException("Could not parse Extended Community subtype: " + subType, BGPError.OPT_ATTR_ERROR);
case 1:
if (subType == 2) {
- return new RouteTargetCommunity(new ASNumber(ByteArray.bytesToInt(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
+ return new RouteTargetCommunity(new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
value, AS_NUMBER_LENGTH, AS_LOCAL_ADMIN_LENGTH));
} else if (subType == 3) {
- return new RouteOriginCommunity(new ASNumber(ByteArray.bytesToInt(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
+ return new RouteOriginCommunity(new AsNumber(ByteArray.bytesToLong(ByteArray.subByte(value, 0, AS_NUMBER_LENGTH))), ByteArray.subByte(
value, AS_NUMBER_LENGTH, AS_LOCAL_ADMIN_LENGTH));
} else
return new Inet4SpecificExtendedCommunity(false, subType, new IPv4Address(ByteArray.subByte(value, 0, 4)), ByteArray.subByte(
import org.opendaylight.protocol.bgp.parser.impl.BGPNodeMP;
import org.opendaylight.protocol.bgp.parser.impl.ByteList;
import org.opendaylight.protocol.bgp.parser.impl.MPReach;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.Bandwidth;
import org.opendaylight.protocol.concepts.IGPMetric;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.concepts.SharedRiskLinkGroup;
import org.opendaylight.protocol.concepts.TEMetric;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
private static NodeIdentifier parseNodeDescriptors(final byte[] bytes) throws BGPParsingException {
int byteOffset = 0;
- ASNumber asnumber = null;
+ AsNumber asnumber = null;
DomainIdentifier bgpId = null;
AreaIdentifier ai = null;
RouterIdentifier routerId = null;
logger.debug("Parsing Node Descriptor: {}", Arrays.toString(value));
switch (type) {
case 512:
- asnumber = new ASNumber(ByteArray.bytesToLong(value));
+ asnumber = new AsNumber(ByteArray.bytesToLong(value));
logger.trace("Parsed AS number {}", asnumber);
break;
case 513:
import org.opendaylight.protocol.bgp.parser.impl.PathAttribute;
import org.opendaylight.protocol.bgp.parser.impl.PathAttribute.TypeCode;
import org.opendaylight.protocol.bgp.parser.impl.message.update.AsPathSegmentParser.SegmentType;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.concepts.NetworkAddress;
*/
private static ASPath parseAsPath(final byte[] bytes) throws BGPDocumentedException, BGPParsingException {
int byteOffset = 0;
- List<ASNumber> list = null;
- Set<ASNumber> set = null;
+ List<AsNumber> list = null;
+ Set<AsNumber> set = null;
while (byteOffset < bytes.length) {
final int type = UnsignedBytes.toInt(bytes[byteOffset]);
final SegmentType segmentType = AsPathSegmentParser.parseType(type);
byteOffset += AsPathSegmentParser.LENGTH_SIZE;
if (segmentType == SegmentType.AS_SEQUENCE) {
- list = (List<ASNumber>) AsPathSegmentParser.parseAsPathSegment(segmentType, count,
+ list = (List<AsNumber>) AsPathSegmentParser.parseAsPathSegment(segmentType, count,
ByteArray.subByte(bytes, byteOffset, count * AsPathSegmentParser.AS_NUMBER_LENGTH));
} else {
- set = (Set<ASNumber>) AsPathSegmentParser.parseAsPathSegment(segmentType, count,
+ set = (Set<AsNumber>) AsPathSegmentParser.parseAsPathSegment(segmentType, count,
ByteArray.subByte(bytes, byteOffset, count * AsPathSegmentParser.AS_NUMBER_LENGTH));
}
byteOffset += count * AsPathSegmentParser.AS_NUMBER_LENGTH;
import org.opendaylight.protocol.bgp.util.BGPIPv6RouteImpl;
import org.opendaylight.protocol.bgp.util.BGPLinkImpl;
import org.opendaylight.protocol.bgp.util.BGPNodeImpl;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IGPMetric;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.concepts.IPv4Address;
// attributes
- final ASPath asPath = new ASPath(Lists.newArrayList(new ASNumber(65002)));
+ final ASPath asPath = new ASPath(Lists.newArrayList(new AsNumber((long) 65002)));
final IPv4NextHop nextHop = IPv4NextHop.forString("10.0.0.2");
final Set<Community> comms = Sets.newHashSet(Community.NO_EXPORT, Community.NO_ADVERTISE, Community.NO_EXPORT_SUBCONFED,
- new Community(new ASNumber(0xFFFF), 0xFF10));
+ new Community(new AsNumber((long) 0xFFFF), 0xFF10));
// check path attributes
// attributes
- final ASPath asPath = new ASPath(Lists.newArrayList(new ASNumber(65001)));
+ final ASPath asPath = new ASPath(Lists.newArrayList(new AsNumber((long) 65001)));
final IPv6NextHop nextHop = IPv6NextHop.forString("2001:db8::1", "fe80::c001:bff:fe7e:0");
// attributes
- final ASPath asPath = new ASPath(Lists.newArrayList(new ASNumber(30)), Sets.newHashSet(new ASNumber(10), new ASNumber(20)));
+ final ASPath asPath = new ASPath(Lists.newArrayList(new AsNumber((long) 30)), Sets.newHashSet(new AsNumber((long) 10),
+ new AsNumber((long) 20)));
final BgpAggregator aggregator = new BGPAggregatorImpl(new AsNumber((long) 30), new Ipv4Address("10.0.0.9"));
final IPv4NextHop nextHop = IPv4NextHop.forString("10.0.0.9");
container.setDefaultEntry(new IGPMetric(1));
final NetworkLinkState linkState = new NetworkLinkState(objState, container, null, LinkProtectionType.UNPROTECTED, null, null, null);
- final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new ASNumber(100), new DomainIdentifier(new byte[] { 25, 25, 25, 1 }), new AreaIdentifier(new byte[] {
- 0, 0, 0, 0 }));
+ final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new AsNumber((long) 100), new DomainIdentifier(new byte[] { 25, 25,
+ 25, 1 }), new AreaIdentifier(new byte[] { 0, 0, 0, 0 }));
final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
0x0b, 0x0b, 0x0b, 0x03 })));
// network link state
- final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new ASNumber(100), new DomainIdentifier(new byte[] { 25, 25, 25, 1 }), new AreaIdentifier(new byte[] {
- 0, 0, 0, 0 }));
+ final NodeIdentifierFactory f100 = new NodeIdentifierFactory(new AsNumber((long) 100), new DomainIdentifier(new byte[] { 25, 25,
+ 25, 1 }), new AreaIdentifier(new byte[] { 0, 0, 0, 0 }));
final NodeIdentifier nodeid1 = f100.identifierForRouter(new OSPFv3LANIdentifier(new OSPFRouterIdentifier(new byte[] { 3, 3, 3, 4 }), new OSPFInterfaceIdentifier(new byte[] {
0x0b, 0x0b, 0x0b, 0x03 })));
import org.opendaylight.protocol.bgp.linkstate.SourceProtocol;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.impl.message.update.CommunitiesParser;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.concepts.ISOSystemIdentifier;
import org.opendaylight.protocol.framework.DeserializerException;
@Test
public void testBGPLinkMP() {
- final NodeIdentifier localnodeid = new NodeIdentifier(new ASNumber(25600, 0), null, null, new ISISRouterIdentifier(new ISOSystemIdentifier(new byte[] {
+ final NodeIdentifier localnodeid = new NodeIdentifier(new AsNumber((long) 25600), null, null, new ISISRouterIdentifier(new ISOSystemIdentifier(new byte[] {
0x22, 0x22, 0x22, 0x22, 0x22, 0x22 })));
final NodeIdentifier remotenodeid = NodeIdentifierFactory.localIdentifier(new ISISLANIdentifier(new ISOSystemIdentifier(new byte[] {
0x22, 0x22, 0x22, 0x22, 0x22, 0x22 }), (short) 1));
} catch (final BGPDocumentedException e1) {
fail("Not expected exception: " + e1);
}
- assertEquals(as, new ASSpecificExtendedCommunity(false, 5, new ASNumber(54), new byte[] { 0, 0, 1, 76 }));
+ assertEquals(as, new ASSpecificExtendedCommunity(false, 5, new AsNumber((long) 54), new byte[] { 0, 0, 1, 76 }));
try {
as = (ASSpecificExtendedCommunity) CommunitiesParser.parseExtendedCommunity(new byte[] { 40, 5, 0, 54, 0, 0, 1, 76 });
} catch (final BGPDocumentedException e1) {
fail("Not expected exception: " + e1);
}
- assertEquals(as, new ASSpecificExtendedCommunity(true, 5, new ASNumber(54), new byte[] { 0, 0, 1, 76 }));
+ assertEquals(as, new ASSpecificExtendedCommunity(true, 5, new AsNumber((long) 54), new byte[] { 0, 0, 1, 76 }));
RouteTargetCommunity rtc = null;
try {
} catch (final BGPDocumentedException e1) {
fail("Not expected exception: " + e1);
}
- assertEquals(rtc, new RouteTargetCommunity(new ASNumber(35), new byte[] { 4, 2, 8, 7 }));
+ assertEquals(rtc, new RouteTargetCommunity(new AsNumber((long) 35), new byte[] { 4, 2, 8, 7 }));
RouteOriginCommunity roc = null;
try {
} catch (final BGPDocumentedException e1) {
fail("Not expected exception: " + e1);
}
- assertEquals(roc, new RouteOriginCommunity(new ASNumber(24), new byte[] { 4, 2, 8, 7 }));
+ assertEquals(roc, new RouteOriginCommunity(new AsNumber((long) 24), new byte[] { 4, 2, 8, 7 }));
Inet4SpecificExtendedCommunity sec = null;
try {
import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
import org.opendaylight.protocol.bgp.util.BGPIPv6RouteImpl;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv6Address;
import org.opendaylight.protocol.concepts.IPv6Prefix;
import org.opendaylight.protocol.concepts.Identifier;
import org.opendaylight.protocol.concepts.Prefix;
import org.opendaylight.protocol.framework.DeserializerException;
import org.opendaylight.protocol.framework.DocumentedException;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
*
* @param asn this parameter is passed to ASNumber constructor
*/
- private BGPUpdateMessage fillMessages(final int asn) throws UnknownHostException {
+ private BGPUpdateMessage fillMessages(final long asn) throws UnknownHostException {
- final List<ASNumber> asnums = new ArrayList<ASNumber>();
- asnums.add(new ASNumber(asn));
+ final List<AsNumber> asnums = new ArrayList<AsNumber>();
+ asnums.add(new AsNumber(asn));
final ASPath asPath = new ASPath(asnums);
final NextHop<IPv6Address> nextHop = new IPv6NextHop(new IPv6Address(InetAddress.getByName("2001:db8::1")), new IPv6Address(InetAddress.getByName("fe80::c001:bff:fe7e:0")));
final byte[] input = new byte[] { 5, 8, 13, 21 };
- openMap.put(input, Lists.newArrayList((BGPMessage) new BGPOpenMessage(new ASNumber(30), (short) 30, null, params)));
+ openMap.put(input, Lists.newArrayList((BGPMessage) new BGPOpenMessage(new AsNumber((long) 30), (short) 30, null, params)));
final BGPMessageParserMock mockParser = new BGPMessageParserMock(openMap);
}
final BGPNotificationMessage ntf = new BGPNotificationMessage(BGPError.UNSPECIFIC_OPEN_ERROR);
this.channel.writeAndFlush(ntf);
- negotiationFailed(new BGPDocumentedException("Linkstate capability not advertised.", ntf.getError()));
+ negotiationFailed(new BGPDocumentedException("Linkstate capability is not configured on router. Check the configuration of BGP speaker.", ntf.getError()));
this.state = State.Finished;
return;
}
import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionProposal;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
private final short holdTimer;
- private final ASNumber as;
+ private final AsNumber as;
private final IPv4Address bgpId;
private final BGPSessionPreferences prefs;
- public BGPSessionProposalImpl(final short holdTimer, final ASNumber as, final IPv4Address bgpId) {
+ public BGPSessionProposalImpl(final short holdTimer, final AsNumber as, final IPv4Address bgpId) {
this.holdTimer = holdTimer;
this.as = as;
this.bgpId = bgpId;
/**
* @return the as
*/
- public ASNumber getAs() {
+ public AsNumber getAs() {
return this.as;
}
import java.util.List;
import org.opendaylight.protocol.bgp.parser.BGPParameter;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
* DTO for BGP Session preferences, that contains BGP Open message.
*/
public final class BGPSessionPreferences {
- private final ASNumber as;
+ private final AsNumber as;
private final int hold;
*
* @param prefs BGP Open message
*/
- public BGPSessionPreferences(final ASNumber as, final int hold, final IPv4Address bgpId, final List<BGPParameter> params) {
+ public BGPSessionPreferences(final AsNumber as, final int hold, final IPv4Address bgpId, final List<BGPParameter> params) {
this.as = as;
this.hold = hold;
this.bgpId = bgpId;
*
* @return AS number
*/
- public ASNumber getMyAs() {
+ public AsNumber getMyAs() {
return this.as;
}
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
import org.opendaylight.protocol.bgp.parser.BGPUpdateSynchronized;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
@Test
public void testBGPSessionPreferences() {
- final BGPSessionPreferences sp = new BGPSessionPreferences(new ASNumber(58), (short) 5, null, null);
+ final BGPSessionPreferences sp = new BGPSessionPreferences(new AsNumber((long) 58), (short) 5, null, null);
assertNull(sp.getBgpId());
assertEquals((short) 5, sp.getHoldTime());
- assertEquals(58, sp.getMyAs().getAsn());
+ assertEquals(58, sp.getMyAs().getValue().longValue());
}
@Test
import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
final List<BGPParameter> tlvs = Lists.newArrayList();
tlvs.add(new MultiprotocolCapability(this.ipv4tt));
tlvs.add(new MultiprotocolCapability(this.linkstatett));
- final BGPSessionPreferences prefs = new BGPSessionPreferences(new ASNumber(30), (short) 3, null, tlvs);
+ final BGPSessionPreferences prefs = new BGPSessionPreferences(new AsNumber((long) 30), (short) 3, null, tlvs);
this.clientSession = new BGPSessionNegotiator(new HashedWheelTimer(), new DefaultPromise<BGPSessionImpl>(GlobalEventExecutor.INSTANCE), this.speakerListener, prefs, new SimpleSessionListener());
doAnswer(new Answer<Object>() {
@Override
doReturn(this.pipeline).when(this.speakerListener).pipeline();
doReturn(this.pipeline).when(this.pipeline).replace(any(ChannelHandler.class), any(String.class), any(ChannelHandler.class));
doReturn(mock(ChannelFuture.class)).when(this.speakerListener).close();
- this.classicOpen = new BGPOpenMessage(new ASNumber(30), (short) 3, null, tlvs);
+ this.classicOpen = new BGPOpenMessage(new AsNumber((long) 30), (short) 3, null, tlvs);
}
@Test
this.clientSession.channelActive(null);
assertEquals(1, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(0) instanceof BGPOpenMessage);
- this.clientSession.handleMessage(new BGPOpenMessage(new ASNumber(30), (short) 1, null, null));
+ this.clientSession.handleMessage(new BGPOpenMessage(new AsNumber((long) 30), (short) 1, null, null));
assertEquals(2, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(1) instanceof BGPNotificationMessage);
final BGPMessage m = this.receivedMsgs.get(this.receivedMsgs.size() - 1);
this.clientSession.handleMessage(new BGPKeepAliveMessage());
assertEquals(this.clientSession.getState(), BGPSessionNegotiator.State.Finished);
try {
- this.clientSession.handleMessage(new BGPOpenMessage(new ASNumber(30), (short) 3, null, null));
+ this.clientSession.handleMessage(new BGPOpenMessage(new AsNumber((long) 30), (short) 3, null, null));
fail("Exception should be thrown.");
} catch (final IllegalStateException e) {
assertEquals("Unexpected state Finished", e.getMessage());
import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
import org.opendaylight.protocol.bgp.parser.parameter.GracefulCapability;
import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.framework.DeserializerException;
import org.opendaylight.protocol.framework.DocumentedException;
import org.opendaylight.protocol.framework.ProtocolMessageFactory;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpSubsequentAddressFamily;
@Test
public void testOpenMessage() throws UnknownHostException, DeserializerException, DocumentedException {
- final BGPMessage open = new BGPOpenMessage(new ASNumber(100), (short) 180, new IPv4Address(InetAddress.getByName("20.20.20.20")), null);
+ final BGPMessage open = new BGPOpenMessage(new AsNumber((long) 100), (short) 180, new IPv4Address(InetAddress.getByName("20.20.20.20")), null);
final byte[] bytes = this.factory.put(open);
assertArrayEquals(openBMsg, bytes);
final BGPMessage m = this.factory.parse(bytes).get(0);
assertTrue(m instanceof BGPOpenMessage);
- assertEquals(new ASNumber(100), ((BGPOpenMessage) m).getMyAS());
+ assertEquals(new AsNumber((long) 100), ((BGPOpenMessage) m).getMyAS());
assertEquals((short) 180, ((BGPOpenMessage) m).getHoldTime());
assertEquals(new IPv4Address(InetAddress.getByName("20.20.20.20")), ((BGPOpenMessage) m).getBgpId());
assertTrue(((BGPOpenMessage) m).getOptParams().isEmpty());
tableTypes.put(t1, true);
tableTypes.put(t2, true);
tlvs.add(new GracefulCapability(true, 0, tableTypes));
- final BGPOpenMessage open = new BGPOpenMessage(new ASNumber(72), (short) 180, new IPv4Address(InetAddress.getByName("172.20.160.170")), tlvs);
-
- // System.out.println(Arrays.toString(this.factory.put(open)));
+ final BGPOpenMessage open = new BGPOpenMessage(new AsNumber((long) 72), (short) 180, new IPv4Address(InetAddress.getByName("172.20.160.170")), tlvs);
this.factory.put(open);
import org.opendaylight.protocol.bgp.rib.impl.BGPDispatcherImpl;
import org.opendaylight.protocol.bgp.rib.impl.BGPSessionProposalImpl;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.framework.NeverReconnectStrategy;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
InetSocketAddress address = null;
short holdTimerValue = 90;
- ASNumber as = null;
+ AsNumber as = null;
int i = 0;
while (i < args.length) {
holdTimerValue = Short.valueOf(args[i + 1]);
i++;
} else if (args[i].equalsIgnoreCase("-as")) {
- as = new ASNumber(Long.valueOf(args[i + 1]));
+ as = new AsNumber(Long.valueOf(args[i + 1]));
i++;
} else {
System.out.println("WARNING: Unrecognized argument: " + args[i]);
import org.opendaylight.protocol.bgp.rib.impl.BGPSessionNegotiatorFactory;
import org.opendaylight.protocol.bgp.rib.impl.BGPSessionProposalImpl;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.framework.AbstractDispatcher;
import org.opendaylight.protocol.framework.ProtocolHandlerFactory;
import org.opendaylight.protocol.framework.SessionListener;
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import com.google.common.base.Preconditions;
}
};
- final BGPSessionPreferences prefs = new BGPSessionProposalImpl((short) 90, new ASNumber(25), IPv4.FAMILY.addressForString("127.0.0.2")).getProposal();
+ final BGPSessionPreferences prefs = new BGPSessionProposalImpl((short) 90, new AsNumber((long) 25), IPv4.FAMILY.addressForString("127.0.0.2")).getProposal();
final SessionNegotiatorFactory<BGPMessage, BGPSessionImpl, BGPSessionListener> snf = new BGPSessionNegotiatorFactory(new HashedWheelTimer(), prefs);
import org.opendaylight.protocol.bgp.linkstate.NodeIdentifier;
import org.opendaylight.protocol.bgp.linkstate.OSPFRouterIdentifier;
import org.opendaylight.protocol.bgp.linkstate.RouteTag;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.concepts.IPv6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
import com.google.common.collect.Lists;
public class PrefixTest {
final BaseBGPObjectState base = new BaseBGPObjectState(BgpOrigin.Egp, null);
- final NetworkObjectState state = new NetworkObjectState(new ASPath(Lists.newArrayList(new ASNumber(10L))), Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
+ final NetworkObjectState state = new NetworkObjectState(new ASPath(Lists.newArrayList(new AsNumber(10L))), Collections.<Community> emptySet(), Collections.<ExtendedCommunity> emptySet());
final NetworkPrefixState prefixState = new NetworkPrefixState(this.state, Sets.<RouteTag> newTreeSet(), null);
final BGPIPv4PrefixImpl r4 = new BGPIPv4PrefixImpl(this.base, new IPv4PrefixIdentifier(new NodeIdentifier(null, null, null, new OSPFRouterIdentifier(new byte[] {
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.concepts;
-
-import javax.annotation.concurrent.Immutable;
-
-import org.opendaylight.protocol.concepts.Identifier;
-
-/**
- * Autonomous System (AS) Number. This is an Internet-level concept, where each
- * AS number identifies an administrative domain.
- * @see <a href="http://en.wikipedia.org/wiki/Autonomous_System_%28Internet%29">Wikipedia article</a>
- */
-@Immutable
-public final class ASNumber implements Comparable<ASNumber>, Identifier {
- /**
- * AS_TRANS as defined by RFC4893 and RFC6793.
- */
- public static final ASNumber TRANS = new ASNumber(23456);
- private static final long serialVersionUID = 7654204313238963136L;
- private final int highValue, lowValue;
-
- /**
- * Create an AS number representation from a pair of 16bit integers,
- * representing high/low components, for example as carried in ASDOT+
- * notation.
- *
- * @param highValue Value of high-order 16 bits
- * @param lowValue Value of low-order 16 bits
- * @throws
- * @li IllegalArgumentException when either highValue or lowValue
- * out of allowed range (0-65535)
- */
- public ASNumber(final int highValue, final int lowValue) {
- if (highValue < 0 || highValue > 65535)
- throw new IllegalArgumentException("Invalid high-order value");
- if (lowValue < 0 || lowValue > 65535)
- throw new IllegalArgumentException("Invalid low-order value");
-
- this.highValue = highValue;
- this.lowValue = lowValue;
- }
-
- /**
- * Create an AS number representation from a single integer. The
- * integer is the 'raw' AS number value, with unsigned 32bit range,
- * for example as carried in PLAIN notation.
- *
- * @param asn Raw AS number
- * @throws
- * @li IllegalArgumentException when asn is out of allowed range
- * (0-4294967295)
- */
- public ASNumber(final long asn) {
- if (asn < 0 || asn > 4294967295L)
- throw new IllegalArgumentException("Invalid AS number");
-
- this.highValue = (int) (asn / 65536);
- this.lowValue = (int) (asn % 65536);
- }
-
- /**
- * Get the AS number as a single integer. For 2-octet AS numbers,
- * only low 1 bits are used.
- *
- * @return Raw AS number
- */
- public long getAsn() {
- return highValue * 65536L + lowValue;
- }
-
- /**
- * Get the high-valued part of the AS number. For 2-octet AS numbers,
- * this will always be 0.
- *
- * @return High-order bits, guaranteed to be in 0-65535 range.
- */
- public int getHighValue() {
- return highValue;
- }
-
- /**
- * Get the low-valued part of the AS number. For 2-octet AS numbers,
- * this value is equal to the AS number.
- *
- * @return Low-order bits, guaranteed to be in 0-65535 range.
- */
- public int getLowValue() {
- return lowValue;
- }
-
- @Override
- public boolean equals(final Object o) {
- if (!(o instanceof ASNumber))
- return false;
-
- final ASNumber as = (ASNumber)o;
- return lowValue == as.lowValue && highValue == as.highValue;
- }
-
- @Override
- public int hashCode() {
- return 7 * lowValue + 13 * highValue;
- }
-
- @Override
- public int compareTo(final ASNumber as) {
- if (highValue != as.highValue)
- return highValue - as.highValue;
- if (lowValue != as.lowValue)
- return lowValue - as.lowValue;
- return 0;
- }
-
- /**
- * {@inheritDoc}
- *
- * Output string is formated according in ASDOT notation.
- * @see <a href="http://tools.ietf.org/html/rfc5396">RFC5396</a>
- */
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
-
- if (highValue != 0) {
- sb.append(highValue);
- sb.append('.');
- }
- sb.append(lowValue);
- return sb.toString();
- }
-}
-
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import java.util.HashSet;
import java.util.Set;
-import java.util.TreeSet;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.*;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
public class ASNumberTest {
- private ASNumber asn1, asn2, asn3, asn4;
+ private AsNumber asn1, asn2, asn3, asn4;
@Before
public void setUp() {
- asn1 = new ASNumber(100, 200);
- asn2 = new ASNumber(6553800);
- asn3 = new ASNumber(0, 200);
- asn4 = new ASNumber(100, 199);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testHighValueUnderflow() {
- new ASNumber(-1, 0);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testHighValueOverflow() {
- new ASNumber(65536, 0);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testLowValueUnderflow() {
- new ASNumber(0, -1);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testLowValueOverflow() {
- new ASNumber(0, 65536);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testAsnUnderflow() {
- new ASNumber(0, -1);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testAsnOverflow() {
- new ASNumber(4294967296L);
+ this.asn1 = new AsNumber(429496729800L);
+ this.asn3 = new AsNumber((long) 200);
+ this.asn4 = new AsNumber(429496729799L);
}
@Test
public void testHashCode() {
- final Set<ASNumber> set = new HashSet<ASNumber>();
+ final Set<AsNumber> set = new HashSet<>();
- set.add(asn1);
+ set.add(this.asn1);
assertEquals(1, set.size());
- set.add(asn2);
- assertEquals(1, set.size());
-
- set.add(asn3);
- assertEquals(2, set.size());
- }
-
- @Test
- public void testCompareTo() {
- final Set<ASNumber> set = new TreeSet<ASNumber>();
-
- set.add(asn1);
- assertEquals(1, set.size());
-
- set.add(asn2);
- assertEquals(1, set.size());
-
- set.add(asn3);
+ set.add(this.asn3);
assertEquals(2, set.size());
-
- set.add(asn4);
- assertEquals(3, set.size());
}
@Test
public void testGetters() {
- assertEquals(100, asn1.getHighValue());
- assertEquals(200, asn1.getLowValue());
- assertEquals(6553800, asn1.getAsn());
+ assertEquals(429496729800L, this.asn1.getValue().longValue());
}
@Test
public void testEquals() {
- assertThat(asn1, equalTo(asn2));
- assertThat(asn1, not(equalTo(asn3)));
- assertThat(asn1, not(equalTo(asn4)));
- assertThat(asn1, not(equalTo(new Object())));
- assertFalse(asn1.equals(new Object()));
+ assertThat(this.asn1, not(equalTo(this.asn3)));
+ assertThat(this.asn1, not(equalTo(this.asn4)));
+ assertThat(this.asn1, not(equalTo(new Object())));
+ assertFalse(this.asn1.equals(new Object()));
}
@Test
public void testToString() {
- assertEquals("100.200", asn1.toString());
- assertEquals("200", asn3.toString());
+ assertEquals("AsNumber [_value=429496729800]", this.asn1.toString());
+ assertEquals("AsNumber [_value=200]", this.asn3.toString());
}
}
-
package org.opendaylight.protocol.pcep.subobject;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+
import com.google.common.base.Objects.ToStringHelper;
/**
* Structure of Autonomous System Number Subobject.
- *
- * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.4">Section
- * 4.3.3.4.: Subobject 32: Autonomous System Number</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.4">Section 4.3.3.4.: Subobject 32: Autonomous System
+ * Number</a>
*/
public class EROAsNumberSubobject extends ExplicitRouteSubobject {
- private final ASNumber asnumber;
+ private final AsNumber asnumber;
/**
* Constructs new ASNumber Subobject.
- *
- * @param asnumber
- * ASNumber
- * @param loose
- * boolean
+ *
+ * @param asnumber ASNumber
+ * @param loose boolean
*/
- public EROAsNumberSubobject(ASNumber asnumber, boolean loose) {
+ public EROAsNumberSubobject(final AsNumber asnumber, final boolean loose) {
super(loose);
this.asnumber = asnumber;
}
/**
- * Gets {@link ASNumber}.
- *
+ * Gets {@link AsNumber}.
+ *
* @return ASNumber
*/
- public ASNumber getASNumber() {
+ public AsNumber getASNumber() {
return this.asnumber;
}
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return true;
}
- @Override
- protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
+ @Override
+ protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
toStringHelper.add("asnumber", this.asnumber);
return super.addToStringAttributes(toStringHelper);
}
package org.opendaylight.protocol.pcep.subobject;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
* Structure of Autonomous System Number Subobject.
- *
- * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.4">Section
- * 4.3.3.4.: Subobject 32: Autonomous System Number</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.4">Section 4.3.3.4.: Subobject 32: Autonomous System
+ * Number</a>
*/
public class RROAsNumberSubobject extends ReportedRouteSubobject {
- private final ASNumber asnumber;
+ private final AsNumber asnumber;
- /**
- * Constructs new ASNumber Subobject.
- *
- * @param asnumber
- * ASNumber
- */
- public RROAsNumberSubobject(ASNumber asnumber) {
- super();
- this.asnumber = asnumber;
- }
+ /**
+ * Constructs new ASNumber Subobject.
+ *
+ * @param asnumber ASNumber
+ */
+ public RROAsNumberSubobject(final AsNumber asnumber) {
+ super();
+ this.asnumber = asnumber;
+ }
- /**
- * Gets {@link ASNumber}.
- *
- * @return ASNumber
- */
- public ASNumber getASNumber() {
- return this.asnumber;
- }
+ /**
+ * Gets {@link AsNumber}.
+ *
+ * @return ASNumber
+ */
+ public AsNumber getASNumber() {
+ return this.asnumber;
+ }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((this.asnumber == null) ? 0 : this.asnumber.hashCode());
- return result;
- }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((this.asnumber == null) ? 0 : this.asnumber.hashCode());
+ return result;
+ }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (this.getClass() != obj.getClass())
- return false;
- final RROAsNumberSubobject other = (RROAsNumberSubobject) obj;
- if (this.asnumber == null) {
- if (other.asnumber != null)
- return false;
- } else if (!this.asnumber.equals(other.asnumber))
- return false;
- return true;
- }
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (this.getClass() != obj.getClass())
+ return false;
+ final RROAsNumberSubobject other = (RROAsNumberSubobject) obj;
+ if (this.asnumber == null) {
+ if (other.asnumber != null)
+ return false;
+ } else if (!this.asnumber.equals(other.asnumber))
+ return false;
+ return true;
+ }
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("RROAsNumberSubobject [asnumber=");
- builder.append(this.asnumber);
- builder.append("]");
- return builder.toString();
- }
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("RROAsNumberSubobject [asnumber=");
+ builder.append(this.asnumber);
+ builder.append("]");
+ return builder.toString();
+ }
}
*/
package org.opendaylight.protocol.pcep.subobject;
-import org.opendaylight.protocol.concepts.ASNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
* Structure of Autonomous System Number Subobject. Defined in RFC5521.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route
- * Object definition</a>
+ *
+ * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route Object definition</a>
*/
public class XROAsNumberSubobject extends ExcludeRouteSubobject {
- private final ASNumber asnumber;
+ private final AsNumber asnumber;
/**
* Constructs new ASNumber Subobject.
- *
- * @param asnumber
- * ASNumber
- * @param mandatory
- * boolean
+ *
+ * @param asnumber ASNumber
+ * @param mandatory boolean
*/
- public XROAsNumberSubobject(ASNumber asnumber, boolean mandatory) {
+ public XROAsNumberSubobject(final AsNumber asnumber, final boolean mandatory) {
super(mandatory);
this.asnumber = asnumber;
}
/**
- * Gets {@link ASNumber}.
- *
+ * Gets {@link AsNumber}.
+ *
* @return ASNumber
*/
- public ASNumber getASNumber() {
+ public AsNumber getASNumber() {
return this.asnumber;
}
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
reference "https://tools.ietf.org/html/rfc2205";
}
- // FIXME: BGP module
- typedef as-number {
- type uint32;
- }
-
typedef attribute-filter {
type uint32;
}
grouping as-number-subobject {
leaf as-number {
reference "http://tools.ietf.org/html/rfc3209#section-4.3.3.4";
- type as-number;
+ type inet:as-number;
mandatory true;
}
}
import java.util.List;
import org.junit.Test;
-
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
import org.opendaylight.protocol.pcep.subobject.EROAsNumberSubobject;
import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
*
private static final long serialVersionUID = 1L;
};
- assertNotSame(msg1, msg2); //not same because they are anonymous classes
+ assertNotSame(msg1, msg2); // not same because they are anonymous classes
assertEquals(msg1.hashCode(), msg2.hashCode());
assertEquals(msg1.toString(), msg2.toString());
}
@Test
public void testSubobject() {
- final ExplicitRouteSubobject sub1 = new EROAsNumberSubobject(new ASNumber(100), true);
+ final ExplicitRouteSubobject sub1 = new EROAsNumberSubobject(new AsNumber((long) 100), true);
final ExplicitRouteSubobject sub2 = new ExplicitRouteSubobject(false) {
};
final ExplicitRouteSubobject sub3 = new ExplicitRouteSubobject(false) {
};
- final ExplicitRouteSubobject sub4 = new EROAsNumberSubobject(new ASNumber(100), true);
+ final ExplicitRouteSubobject sub4 = new EROAsNumberSubobject(new AsNumber((long) 100), true);
assertNotSame(sub1, sub2);
assertNotSame(sub2, sub3);
import java.util.List;
import org.junit.Test;
-
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.Bandwidth;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.pcep.subobject.XROSubobjectAttribute;
import org.opendaylight.protocol.pcep.subobject.XROUnnumberedInterfaceSubobject;
import org.opendaylight.protocol.pcep.tlv.OrderTlv;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+
import com.google.common.collect.Lists;
/**
*/
public class ObjectsTest {
- @Test
- public void compositeErrorObjectTest() {
-
- final List<PCEPErrorObject> errorObjects = new ArrayList<PCEPErrorObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPErrorObject(PCEPErrors.ATTEMPT_2ND_SESSION));
- }
- };
-
- final List<PCEPRequestParameterObject> errorParams = new ArrayList<PCEPRequestParameterObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false, (short) 1, 1, true, true));
- }
- };
- final CompositeErrorObject m = new CompositeErrorObject(errorParams, errorObjects);
- final CompositeErrorObject m2 = new CompositeErrorObject(errorParams, errorObjects);
- final CompositeErrorObject m3 = new CompositeErrorObject(errorObjects);
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
- assertEquals(m.getErrors(), m2.getErrors());
- assertEquals(m.getRequestParameters(), m2.getRequestParameters());
- assertEquals(m, CompositeErrorObject.getCompositeFromList(m.getCompositeAsList()));
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
- }
-
- @Test
- public void compositeNotifyObjectTest() {
-
- final List<PCEPNotificationObject> notifications = new ArrayList<PCEPNotificationObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPNotificationObject((short) 2, (short) 3));
- }
- };
-
- final List<PCEPRequestParameterObject> reqParams = new ArrayList<PCEPRequestParameterObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false, (short) 1, 1, true, true));
- }
- };
- final CompositeNotifyObject m = new CompositeNotifyObject(reqParams, notifications);
- final CompositeNotifyObject m2 = new CompositeNotifyObject(reqParams, notifications);
- final CompositeNotifyObject m3 = new CompositeNotifyObject(notifications);
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
- assertEquals(m.getNotificationObjects(), m2.getNotificationObjects());
- assertEquals(m.getRequestParameters(), m2.getRequestParameters());
- assertEquals(m, CompositeNotifyObject.getCompositeFromList(m.getCompositeAsList()));
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
- }
-
- @Test
- public void compositePathObjectTest() {
-
- final List<ExplicitRouteSubobject> subobjects = new ArrayList<ExplicitRouteSubobject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new EROAsNumberSubobject(new ASNumber(2555), false));
- }
- };
-
- final CompositePathObject m = new CompositePathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2,
- true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
- }, new PCEPIncludeRouteObject(subobjects, true, true));
- final CompositePathObject m2 = new CompositePathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2,
- true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
- }, new PCEPIncludeRouteObject(subobjects, true, true));
- final CompositePathObject m3 = new CompositePathObject(new PCEPExplicitRouteObject(subobjects, false));
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
- assertEquals(m.getBandwidth(), m2.getBandwidth());
- assertEquals(m.getExcludedRoute(), m2.getExcludedRoute());
- assertEquals(m.getIncludeRoute(), m2.getIncludeRoute());
- assertEquals(m.getLspa(), m2.getLspa());
- assertEquals(m.getMetrics(), m2.getMetrics());
- assertEquals(m, CompositePathObject.getCompositeFromList(m.getCompositeAsList()));
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
- }
-
- @Test
- public void compositeRptPathObjectTest() {
-
- final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new EROUnnumberedInterfaceSubobject(new IPv4Address(
- new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new UnnumberedInterfaceIdentifier(2), true));
- this.add(new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(
- new byte[] { (byte) 12, (byte) 122, (byte) 125, (byte) 2 }), 22), false));
- }
- };
-
- final List<ReportedRouteSubobject> rroSubobjects = new ArrayList<ReportedRouteSubobject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new RROUnnumberedInterfaceSubobject(new IPv4Address(
- new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new UnnumberedInterfaceIdentifier(2)));
- this.add(new RROIPAddressSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(
- new byte[] { (byte) 12, (byte) 122, (byte) 125, (byte) 2 }), 22), true, false));
- }
- };
-
- final CompositeRptPathObject m = new CompositeRptPathObject(new PCEPExplicitRouteObject(eroSubobjects, false), new PCEPLspaObject(2, 2, 2, (short) 2,
- (short) 2, true, true, true, true), new PCEPExistingPathBandwidthObject(new Bandwidth((float) 0.222), true, true),
- new PCEPReportedRouteObject(rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
+ private final AsNumber as = new AsNumber((long) 2555);
+
+ @Test
+ public void compositeErrorObjectTest() {
+
+ final List<PCEPErrorObject> errorObjects = new ArrayList<PCEPErrorObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPErrorObject(PCEPErrors.ATTEMPT_2ND_SESSION));
+ }
+ };
+
+ final List<PCEPRequestParameterObject> errorParams = new ArrayList<PCEPRequestParameterObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false, (short) 1, 1, true, true));
+ }
+ };
+ final CompositeErrorObject m = new CompositeErrorObject(errorParams, errorObjects);
+ final CompositeErrorObject m2 = new CompositeErrorObject(errorParams, errorObjects);
+ final CompositeErrorObject m3 = new CompositeErrorObject(errorObjects);
+
+ assertEquals(m, m2);
+ assertEquals(m.toString(), m2.toString());
+ assertEquals(m.hashCode(), m2.hashCode());
+ assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
+ assertEquals(m.getErrors(), m2.getErrors());
+ assertEquals(m.getRequestParameters(), m2.getRequestParameters());
+ assertEquals(m, CompositeErrorObject.getCompositeFromList(m.getCompositeAsList()));
+ assertFalse(m.equals(null));
+ assertFalse(m.equals(m3));
+ assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(m.equals(m));
+ }
+
+ @Test
+ public void compositeNotifyObjectTest() {
+
+ final List<PCEPNotificationObject> notifications = new ArrayList<PCEPNotificationObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPNotificationObject((short) 2, (short) 3));
+ }
+ };
+
+ final List<PCEPRequestParameterObject> reqParams = new ArrayList<PCEPRequestParameterObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false, (short) 1, 1, true, true));
+ }
+ };
+ final CompositeNotifyObject m = new CompositeNotifyObject(reqParams, notifications);
+ final CompositeNotifyObject m2 = new CompositeNotifyObject(reqParams, notifications);
+ final CompositeNotifyObject m3 = new CompositeNotifyObject(notifications);
+
+ assertEquals(m, m2);
+ assertEquals(m.toString(), m2.toString());
+ assertEquals(m.hashCode(), m2.hashCode());
+ assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
+ assertEquals(m.getNotificationObjects(), m2.getNotificationObjects());
+ assertEquals(m.getRequestParameters(), m2.getRequestParameters());
+ assertEquals(m, CompositeNotifyObject.getCompositeFromList(m.getCompositeAsList()));
+ assertFalse(m.equals(null));
+ assertFalse(m.equals(m3));
+ assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(m.equals(m));
+ }
+
+ @Test
+ public void compositePathObjectTest() {
+
+ final List<ExplicitRouteSubobject> subobjects = new ArrayList<ExplicitRouteSubobject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new EROAsNumberSubobject(ObjectsTest.this.as, false));
+ }
+ };
+
+ final CompositePathObject m = new CompositePathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
+ }, new PCEPIncludeRouteObject(subobjects, true, true));
+ final CompositePathObject m2 = new CompositePathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
+ }, new PCEPIncludeRouteObject(subobjects, true, true));
+ final CompositePathObject m3 = new CompositePathObject(new PCEPExplicitRouteObject(subobjects, false));
+
+ assertEquals(m, m2);
+ assertEquals(m.toString(), m2.toString());
+ assertEquals(m.hashCode(), m2.hashCode());
+ assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
+ assertEquals(m.getBandwidth(), m2.getBandwidth());
+ assertEquals(m.getExcludedRoute(), m2.getExcludedRoute());
+ assertEquals(m.getIncludeRoute(), m2.getIncludeRoute());
+ assertEquals(m.getLspa(), m2.getLspa());
+ assertEquals(m.getMetrics(), m2.getMetrics());
+ assertEquals(m, CompositePathObject.getCompositeFromList(m.getCompositeAsList()));
+ assertFalse(m.equals(null));
+ assertFalse(m.equals(m3));
+ assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(m.equals(m));
+ }
+
+ @Test
+ public void compositeRptPathObjectTest() {
+
+ final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new EROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new UnnumberedInterfaceIdentifier(2), true));
+ this.add(new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 12, (byte) 122,
+ (byte) 125, (byte) 2 }), 22), false));
+ }
+ };
+
+ final List<ReportedRouteSubobject> rroSubobjects = new ArrayList<ReportedRouteSubobject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new RROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new UnnumberedInterfaceIdentifier(2)));
+ this.add(new RROIPAddressSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 12, (byte) 122,
+ (byte) 125, (byte) 2 }), 22), true, false));
+ }
+ };
+
+ final CompositeRptPathObject m = new CompositeRptPathObject(new PCEPExplicitRouteObject(eroSubobjects, false), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPExistingPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new PCEPReportedRouteObject(rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
});
- final CompositeRptPathObject m2 = new CompositeRptPathObject(new PCEPExplicitRouteObject(eroSubobjects, false), new PCEPLspaObject(2, 2, 2, (short) 2,
- (short) 2, true, true, true, true), new PCEPExistingPathBandwidthObject(new Bandwidth((float) 0.222), true, true),
- new PCEPReportedRouteObject(rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
+ final CompositeRptPathObject m2 = new CompositeRptPathObject(new PCEPExplicitRouteObject(eroSubobjects, false), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPExistingPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new PCEPReportedRouteObject(rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
});
- final CompositePathObject m3 = new CompositePathObject(new PCEPExplicitRouteObject(eroSubobjects, false));
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
- assertEquals(m.getBandwidth(), m2.getBandwidth());
- assertEquals(m.getExcludedRoute(), m2.getExcludedRoute());
- assertEquals(m.getLspa(), m2.getLspa());
- assertEquals(m.getMetrics(), m2.getMetrics());
- assertEquals(m, CompositeRptPathObject.getCompositeFromList(m.getCompositeAsList()));
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
- }
-
- @Test
- public void compositeUpdPathObjectTest() {
-
- final List<ExplicitRouteSubobject> subobjects = new ArrayList<ExplicitRouteSubobject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new EROAsNumberSubobject(new ASNumber(2555), false));
- }
- };
-
- final CompositeUpdPathObject m = new CompositeUpdPathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2,
- (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true),
- new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
+ final CompositePathObject m3 = new CompositePathObject(new PCEPExplicitRouteObject(eroSubobjects, false));
+ assertEquals(m, m2);
+ assertEquals(m.toString(), m2.toString());
+ assertEquals(m.hashCode(), m2.hashCode());
+ assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
+ assertEquals(m.getBandwidth(), m2.getBandwidth());
+ assertEquals(m.getExcludedRoute(), m2.getExcludedRoute());
+ assertEquals(m.getLspa(), m2.getLspa());
+ assertEquals(m.getMetrics(), m2.getMetrics());
+ assertEquals(m, CompositeRptPathObject.getCompositeFromList(m.getCompositeAsList()));
+ assertFalse(m.equals(null));
+ assertFalse(m.equals(m3));
+ assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(m.equals(m));
+ }
+
+ @Test
+ public void compositeUpdPathObjectTest() {
+
+ final List<ExplicitRouteSubobject> subobjects = new ArrayList<ExplicitRouteSubobject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new EROAsNumberSubobject(ObjectsTest.this.as, false));
+ }
+ };
+
+ final CompositeUpdPathObject m = new CompositeUpdPathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
});
- final CompositeUpdPathObject m2 = new CompositeUpdPathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2,
- (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true),
- new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
+ final CompositeUpdPathObject m2 = new CompositeUpdPathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
});
- final CompositeUpdPathObject m3 = new CompositeUpdPathObject(new PCEPExplicitRouteObject(subobjects, false));
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
- assertEquals(m.getBandwidth(), m2.getBandwidth());
- assertEquals(m.getExcludedRoute(), m2.getExcludedRoute());
- assertEquals(m.getLspa(), m2.getLspa());
- assertEquals(m.getMetrics(), m2.getMetrics());
- assertEquals(m, CompositeUpdPathObject.getCompositeFromList(m.getCompositeAsList()));
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
- }
-
- @Test
- public void compositeRequestedObjectTest() {
-
- final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new EROAsNumberSubobject(new ASNumber(2555), false));
- }
- };
-
- final List<ReportedRouteSubobject> rroSubobjects = new ArrayList<ReportedRouteSubobject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new RROAsNumberSubobject(new ASNumber(2555)));
- }
- };
-
- final CompositeRequestObject m = new CompositeRequestObject(new PCEPRequestParameterObject(true, true, true, true, true, true, false, false, false,
- (short) 1, 1, new ArrayList<PCEPTlv>() {
- private static final long serialVersionUID = 1L;
- {
- this.add(new OrderTlv(1L, 2L));
- }
- }, true, true), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(
- new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new IPv4Address(
- new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 1 })), new PCEPClassTypeObject((short) 2), new PCEPLspObject((short) 1, true, true, true,
- true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth(
- (float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
- }, new PCEPReportedRouteObject(rroSubobjects, true), new PCEPExistingPathBandwidthObject(new Bandwidth((float) 0.222), true, true),
- new PCEPIncludeRouteObject(eroSubobjects, true, true), new PCEPLoadBalancingObject(2, new Bandwidth((float) 0.2), true));
- final CompositeRequestObject m2 = new CompositeRequestObject(new PCEPRequestParameterObject(true, true, true, true, true, true, false, false, false,
- (short) 1, 1, new ArrayList<PCEPTlv>() {
- private static final long serialVersionUID = 1L;
- {
- this.add(new OrderTlv(1L, 2L));
- }
- }, true, true), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(
- new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new IPv4Address(
- new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 1 })), new PCEPClassTypeObject((short) 2), new PCEPLspObject((short) 1, true, true, true,
- true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth(
- (float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
- }, new PCEPReportedRouteObject(rroSubobjects, true), new PCEPExistingPathBandwidthObject(new Bandwidth((float) 0.222), true, true),
- new PCEPIncludeRouteObject(eroSubobjects, true, true), new PCEPLoadBalancingObject(2, new Bandwidth((float) 0.2), true));
- final CompositeRequestObject m3 = new CompositeRequestObject(new PCEPRequestParameterObject(true, true, true, true, true, true, false, false, false,
- (short) 1, 1, new ArrayList<PCEPTlv>() {
- private static final long serialVersionUID = 1L;
- {
- this.add(new OrderTlv(1L, 2L));
- }
- }, true, true), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(
- new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new IPv4Address(
- new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 1 })));
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
- assertEquals(m.getBandwidth(), m2.getBandwidth());
- assertEquals(m.getLspa(), m2.getLspa());
- assertEquals(m.getMetrics(), m2.getMetrics());
- assertEquals(m.getClassType(), m2.getClassType());
- assertEquals(m.getEndPoints(), m2.getEndPoints());
- assertEquals(m.getIncludeRoute(), m2.getIncludeRoute());
- assertEquals(m.getLsp(), m2.getLsp());
- assertEquals(m.getRroBandwidth(), m2.getRroBandwidth());
- assertEquals(m, CompositeRequestObject.getCompositeFromList(m.getCompositeAsList()));
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
- }
-
- @Test
- public void compositeResponseObjectTest() {
-
- final List<ExplicitRouteSubobject> subobjects = new ArrayList<ExplicitRouteSubobject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new EROAsNumberSubobject(new ASNumber(2555), false));
- }
- };
-
- final List<CompositePathObject> paths = new ArrayList<CompositePathObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositePathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true,
- true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
- }, new PCEPIncludeRouteObject(subobjects, true, true)));
- }
- };
-
- final CompositeResponseObject m = new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false,
- (short) 1, 1, true, true), new PCEPNoPathObject((short) 2, true, false), new PCEPLspObject((short) 1, true, true, true, true),
- new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222),
- true, true), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
+ final CompositeUpdPathObject m3 = new CompositeUpdPathObject(new PCEPExplicitRouteObject(subobjects, false));
+
+ assertEquals(m, m2);
+ assertEquals(m.toString(), m2.toString());
+ assertEquals(m.hashCode(), m2.hashCode());
+ assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
+ assertEquals(m.getBandwidth(), m2.getBandwidth());
+ assertEquals(m.getExcludedRoute(), m2.getExcludedRoute());
+ assertEquals(m.getLspa(), m2.getLspa());
+ assertEquals(m.getMetrics(), m2.getMetrics());
+ assertEquals(m, CompositeUpdPathObject.getCompositeFromList(m.getCompositeAsList()));
+ assertFalse(m.equals(null));
+ assertFalse(m.equals(m3));
+ assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(m.equals(m));
+ }
+
+ @Test
+ public void compositeRequestedObjectTest() {
+
+ final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new EROAsNumberSubobject(ObjectsTest.this.as, false));
+ }
+ };
+
+ final List<ReportedRouteSubobject> rroSubobjects = new ArrayList<ReportedRouteSubobject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new RROAsNumberSubobject(ObjectsTest.this.as));
+ }
+ };
+
+ final CompositeRequestObject m = new CompositeRequestObject(new PCEPRequestParameterObject(true, true, true, true, true, true, false, false, false, (short) 1, 1, new ArrayList<PCEPTlv>() {
+ private static final long serialVersionUID = 1L;
+ {
+ this.add(new OrderTlv(1L, 2L));
+ }
+ }, true, true), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new IPv4Address(new byte[] {
+ (byte) 127, (byte) 0, (byte) 0, (byte) 1 })), new PCEPClassTypeObject((short) 2), new PCEPLspObject((short) 1, true, true, true, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
+ }, new PCEPReportedRouteObject(rroSubobjects, true), new PCEPExistingPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new PCEPIncludeRouteObject(eroSubobjects, true, true), new PCEPLoadBalancingObject(2, new Bandwidth((float) 0.2), true));
+ final CompositeRequestObject m2 = new CompositeRequestObject(new PCEPRequestParameterObject(true, true, true, true, true, true, false, false, false, (short) 1, 1, new ArrayList<PCEPTlv>() {
+ private static final long serialVersionUID = 1L;
+ {
+ this.add(new OrderTlv(1L, 2L));
+ }
+ }, true, true), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new IPv4Address(new byte[] {
+ (byte) 127, (byte) 0, (byte) 0, (byte) 1 })), new PCEPClassTypeObject((short) 2), new PCEPLspObject((short) 1, true, true, true, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
+ }, new PCEPReportedRouteObject(rroSubobjects, true), new PCEPExistingPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new PCEPIncludeRouteObject(eroSubobjects, true, true), new PCEPLoadBalancingObject(2, new Bandwidth((float) 0.2), true));
+ final CompositeRequestObject m3 = new CompositeRequestObject(new PCEPRequestParameterObject(true, true, true, true, true, true, false, false, false, (short) 1, 1, new ArrayList<PCEPTlv>() {
+ private static final long serialVersionUID = 1L;
+ {
+ this.add(new OrderTlv(1L, 2L));
+ }
+ }, true, true), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new IPv4Address(new byte[] {
+ (byte) 127, (byte) 0, (byte) 0, (byte) 1 })));
+
+ assertEquals(m, m2);
+ assertEquals(m.toString(), m2.toString());
+ assertEquals(m.hashCode(), m2.hashCode());
+ assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
+ assertEquals(m.getBandwidth(), m2.getBandwidth());
+ assertEquals(m.getLspa(), m2.getLspa());
+ assertEquals(m.getMetrics(), m2.getMetrics());
+ assertEquals(m.getClassType(), m2.getClassType());
+ assertEquals(m.getEndPoints(), m2.getEndPoints());
+ assertEquals(m.getIncludeRoute(), m2.getIncludeRoute());
+ assertEquals(m.getLsp(), m2.getLsp());
+ assertEquals(m.getRroBandwidth(), m2.getRroBandwidth());
+ assertEquals(m, CompositeRequestObject.getCompositeFromList(m.getCompositeAsList()));
+ assertFalse(m.equals(null));
+ assertFalse(m.equals(m3));
+ assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(m.equals(m));
+ }
+
+ @Test
+ public void compositeResponseObjectTest() {
+
+ final List<ExplicitRouteSubobject> subobjects = new ArrayList<ExplicitRouteSubobject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new EROAsNumberSubobject(ObjectsTest.this.as, false));
+ }
+ };
+
+ final List<CompositePathObject> paths = new ArrayList<CompositePathObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new CompositePathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
+ }, new PCEPIncludeRouteObject(subobjects, true, true)));
+ }
+ };
+
+ final CompositeResponseObject m = new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false, (short) 1, 1, true, true), new PCEPNoPathObject((short) 2, true, false), new PCEPLspObject((short) 1, true, true, true, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
}, new PCEPIncludeRouteObject(subobjects, true, true), paths);
- final CompositeResponseObject m2 = new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false,
- (short) 1, 1, true, true), new PCEPNoPathObject((short) 2, true, false), new PCEPLspObject((short) 1, true, true, true, true),
- new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222),
- true, true), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
+ final CompositeResponseObject m2 = new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false, (short) 1, 1, true, true), new PCEPNoPathObject((short) 2, true, false), new PCEPLspObject((short) 1, true, true, true, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
}, new PCEPIncludeRouteObject(subobjects, true, true), paths);
- final CompositeResponseObject m3 = new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false,
- (short) 1, 1, true, true));
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
- assertEquals(m.getBandwidth(), m2.getBandwidth());
- assertEquals(m.getLspa(), m2.getLspa());
- assertEquals(m.getMetrics(), m2.getMetrics());
- assertEquals(m.getIncludeRoute(), m2.getIncludeRoute());
- assertEquals(m.getLsp(), m2.getLsp());
- assertEquals(m.getPaths(), m2.getPaths());
- assertEquals(m.getRequestParameter(), m2.getRequestParameter());
- assertEquals(m, CompositeResponseObject.getCompositeFromList(m.getCompositeAsList()));
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
- }
-
- @Test
- public void compositeStateReportObjectTest() {
-
- final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new EROAsNumberSubobject(new ASNumber(2555), false));
- }
- };
-
- final List<ReportedRouteSubobject> rroSubobjects = new ArrayList<ReportedRouteSubobject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new RROAsNumberSubobject(new ASNumber(2555)));
- }
- };
-
- final List<CompositeRptPathObject> paths = new ArrayList<CompositeRptPathObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(eroSubobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true,
- true, true, true), new PCEPExistingPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new PCEPReportedRouteObject(
- rroSubobjects, true), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
- }));
- }
- };
-
- final CompositeStateReportObject m = new CompositeStateReportObject(new PCEPLspObject((short) 1, true, true, true, true), paths);
- final CompositeStateReportObject m2 = new CompositeStateReportObject(new PCEPLspObject((short) 1, true, true, true, true), paths);
- final CompositeStateReportObject m3 = new CompositeStateReportObject(new PCEPLspObject((short) 1, true, true, true, true));
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
- assertEquals(m.getLsp(), m2.getLsp());
- assertEquals(m.getPaths(), m2.getPaths());
- assertEquals(m, CompositeStateReportObject.getCompositeFromList(m.getCompositeAsList()));
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
- }
-
- @Test
- public void compositeUpdateRequestObjectTest() {
-
- final List<ExplicitRouteSubobject> subobjects = new ArrayList<ExplicitRouteSubobject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new EROAsNumberSubobject(new ASNumber(2555), false));
- }
- };
-
- final List<CompositeUpdPathObject> paths = new ArrayList<CompositeUpdPathObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true,
- true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
- }
- }));
- }
- };
-
- final CompositeUpdateRequestObject m = new CompositeUpdateRequestObject(new PCEPLspObject((short) 1, true, true, true, true), paths);
- final CompositeUpdateRequestObject m2 = new CompositeUpdateRequestObject(new PCEPLspObject((short) 1, true, true, true, true), paths);
- final CompositeUpdateRequestObject m3 = new CompositeUpdateRequestObject(new PCEPLspObject((short) 1, true, true, true, true));
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
- assertEquals(m.getLsp(), m2.getLsp());
- assertEquals(m.getPaths(), m2.getPaths());
- assertEquals(m, CompositeUpdateRequestObject.getCompositeFromList(m.getCompositeAsList()));
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
- }
-
- @Test
- public void compositeRequestSVECObjectTest() {
-
- final List<ExcludeRouteSubobject> subobjects = new ArrayList<ExcludeRouteSubobject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new XROAsNumberSubobject(new ASNumber(2555), false));
- }
- };
-
- final List<Long> requestIds = new ArrayList<Long>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(0x12345678L);
- }
- };
-
- final CompositeRequestSvecObject m = new CompositeRequestSvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true),
- new PCEPObjectiveFunctionObject(PCEPOFCodes.MBC, true, false), new PCEPGlobalConstraintsObject((short) 2, (short) 2, (short) 2, (short) 2,
- true, false), new PCEPExcludeRouteObject(subobjects, true, true, false), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(0x123456), true, false));
- }
+ final CompositeResponseObject m3 = new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false, (short) 1, 1, true, true));
+
+ assertEquals(m, m2);
+ assertEquals(m.toString(), m2.toString());
+ assertEquals(m.hashCode(), m2.hashCode());
+ assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
+ assertEquals(m.getBandwidth(), m2.getBandwidth());
+ assertEquals(m.getLspa(), m2.getLspa());
+ assertEquals(m.getMetrics(), m2.getMetrics());
+ assertEquals(m.getIncludeRoute(), m2.getIncludeRoute());
+ assertEquals(m.getLsp(), m2.getLsp());
+ assertEquals(m.getPaths(), m2.getPaths());
+ assertEquals(m.getRequestParameter(), m2.getRequestParameter());
+ assertEquals(m, CompositeResponseObject.getCompositeFromList(m.getCompositeAsList()));
+ assertFalse(m.equals(null));
+ assertFalse(m.equals(m3));
+ assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(m.equals(m));
+ }
+
+ @Test
+ public void compositeStateReportObjectTest() {
+
+ final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new EROAsNumberSubobject(ObjectsTest.this.as, false));
+ }
+ };
+
+ final List<ReportedRouteSubobject> rroSubobjects = new ArrayList<ReportedRouteSubobject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new RROAsNumberSubobject(ObjectsTest.this.as));
+ }
+ };
+
+ final List<CompositeRptPathObject> paths = new ArrayList<CompositeRptPathObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(eroSubobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPExistingPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new PCEPReportedRouteObject(rroSubobjects, true), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
+ }));
+ }
+ };
+
+ final CompositeStateReportObject m = new CompositeStateReportObject(new PCEPLspObject((short) 1, true, true, true, true), paths);
+ final CompositeStateReportObject m2 = new CompositeStateReportObject(new PCEPLspObject((short) 1, true, true, true, true), paths);
+ final CompositeStateReportObject m3 = new CompositeStateReportObject(new PCEPLspObject((short) 1, true, true, true, true));
+
+ assertEquals(m, m2);
+ assertEquals(m.toString(), m2.toString());
+ assertEquals(m.hashCode(), m2.hashCode());
+ assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
+ assertEquals(m.getLsp(), m2.getLsp());
+ assertEquals(m.getPaths(), m2.getPaths());
+ assertEquals(m, CompositeStateReportObject.getCompositeFromList(m.getCompositeAsList()));
+ assertFalse(m.equals(null));
+ assertFalse(m.equals(m3));
+ assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(m.equals(m));
+ }
+
+ @Test
+ public void compositeUpdateRequestObjectTest() {
+
+ final List<ExplicitRouteSubobject> subobjects = new ArrayList<ExplicitRouteSubobject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new EROAsNumberSubobject(ObjectsTest.this.as, false));
+ }
+ };
+
+ final List<CompositeUpdPathObject> paths = new ArrayList<CompositeUpdPathObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(subobjects, true), new PCEPLspaObject(2, 2, 2, (short) 2, (short) 2, true, true, true, true), new PCEPRequestedPathBandwidthObject(new Bandwidth((float) 0.222), true, true), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(255), true, false));
+ }
+ }));
+ }
+ };
+
+ final CompositeUpdateRequestObject m = new CompositeUpdateRequestObject(new PCEPLspObject((short) 1, true, true, true, true), paths);
+ final CompositeUpdateRequestObject m2 = new CompositeUpdateRequestObject(new PCEPLspObject((short) 1, true, true, true, true), paths);
+ final CompositeUpdateRequestObject m3 = new CompositeUpdateRequestObject(new PCEPLspObject((short) 1, true, true, true, true));
+
+ assertEquals(m, m2);
+ assertEquals(m.toString(), m2.toString());
+ assertEquals(m.hashCode(), m2.hashCode());
+ assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
+ assertEquals(m.getLsp(), m2.getLsp());
+ assertEquals(m.getPaths(), m2.getPaths());
+ assertEquals(m, CompositeUpdateRequestObject.getCompositeFromList(m.getCompositeAsList()));
+ assertFalse(m.equals(null));
+ assertFalse(m.equals(m3));
+ assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(m.equals(m));
+ }
+
+ @Test
+ public void compositeRequestSVECObjectTest() {
+
+ final List<ExcludeRouteSubobject> subobjects = new ArrayList<ExcludeRouteSubobject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new XROAsNumberSubobject(ObjectsTest.this.as, false));
+ }
+ };
+
+ final List<Long> requestIds = new ArrayList<Long>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(0x12345678L);
+ }
+ };
+
+ final CompositeRequestSvecObject m = new CompositeRequestSvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true), new PCEPObjectiveFunctionObject(PCEPOFCodes.MBC, true, false), new PCEPGlobalConstraintsObject((short) 2, (short) 2, (short) 2, (short) 2, true, false), new PCEPExcludeRouteObject(subobjects, true, true, false), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(0x123456), true, false));
+ }
});
- final CompositeRequestSvecObject m2 = new CompositeRequestSvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true),
- new PCEPObjectiveFunctionObject(PCEPOFCodes.MBC, true, false), new PCEPGlobalConstraintsObject((short) 2, (short) 2, (short) 2, (short) 2,
- true, false), new PCEPExcludeRouteObject(subobjects, true, true, false), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(0x123456), true, false));
- }
+ final CompositeRequestSvecObject m2 = new CompositeRequestSvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true), new PCEPObjectiveFunctionObject(PCEPOFCodes.MBC, true, false), new PCEPGlobalConstraintsObject((short) 2, (short) 2, (short) 2, (short) 2, true, false), new PCEPExcludeRouteObject(subobjects, true, true, false), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(0x123456), true, false));
+ }
});
- final CompositeRequestSvecObject m3 = new CompositeRequestSvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true));
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
- assertEquals(m.getExcludeRoute(), m2.getExcludeRoute());
- assertEquals(m.getGlobalConstraints(), m2.getGlobalConstraints());
- assertEquals(m.getObjectiveFunction(), m2.getObjectiveFunction());
- assertEquals(m.getSvec(), m2.getSvec());
- assertEquals(m, CompositeRequestSvecObject.getCompositeFromList(m.getCompositeAsList()));
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
- }
-
- @Test
- public void compositeRplySVECObjectTest() {
-
- final List<Long> requestIds = new ArrayList<Long>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(0x12345678L);
- }
- };
-
- final CompositeReplySvecObject m = new CompositeReplySvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true),
- new PCEPObjectiveFunctionObject(PCEPOFCodes.MBC, true, false), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
-
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(0x123456), true, false));
- }
+ final CompositeRequestSvecObject m3 = new CompositeRequestSvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true));
+
+ assertEquals(m, m2);
+ assertEquals(m.toString(), m2.toString());
+ assertEquals(m.hashCode(), m2.hashCode());
+ assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
+ assertEquals(m.getExcludeRoute(), m2.getExcludeRoute());
+ assertEquals(m.getGlobalConstraints(), m2.getGlobalConstraints());
+ assertEquals(m.getObjectiveFunction(), m2.getObjectiveFunction());
+ assertEquals(m.getSvec(), m2.getSvec());
+ assertEquals(m, CompositeRequestSvecObject.getCompositeFromList(m.getCompositeAsList()));
+ assertFalse(m.equals(null));
+ assertFalse(m.equals(m3));
+ assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(m.equals(m));
+ }
+
+ @Test
+ public void compositeRplySVECObjectTest() {
+
+ final List<Long> requestIds = new ArrayList<Long>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(0x12345678L);
+ }
+ };
+
+ final CompositeReplySvecObject m = new CompositeReplySvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true), new PCEPObjectiveFunctionObject(PCEPOFCodes.MBC, true, false), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
+
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(0x123456), true, false));
+ }
});
- final CompositeReplySvecObject m2 = new CompositeReplySvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true),
- new PCEPObjectiveFunctionObject(PCEPOFCodes.MBC, true, false), new ArrayList<PCEPMetricObject>() {
- private static final long serialVersionUID = 1L;
+ final CompositeReplySvecObject m2 = new CompositeReplySvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true), new PCEPObjectiveFunctionObject(PCEPOFCodes.MBC, true, false), new ArrayList<PCEPMetricObject>() {
+ private static final long serialVersionUID = 1L;
- {
- this.add(new PCEPMetricObject(true, true, new TEMetric(0x123456), true, false));
- }
+ {
+ this.add(new PCEPMetricObject(true, true, new TEMetric(0x123456), true, false));
+ }
});
- final CompositeReplySvecObject m3 = new CompositeReplySvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true));
-
- assertEquals(m, m2);
- assertEquals(m.toString(), m2.toString());
- assertEquals(m.hashCode(), m2.hashCode());
- assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
- assertEquals(m.getObjectiveFunction(), m2.getObjectiveFunction());
- assertEquals(m.getSvec(), m2.getSvec());
- assertEquals(m, CompositeReplySvecObject.getCompositeFromList(m.getCompositeAsList()));
- assertFalse(m.equals(null));
- assertFalse(m.equals(m3));
- assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(m.equals(m));
- }
-
- @Test
- public void subobjectsTest() {
- final EROAsNumberSubobject as = new EROAsNumberSubobject(new ASNumber(2555), false);
- final EROUnnumberedInterfaceSubobject uis = new EROUnnumberedInterfaceSubobject(new IPv4Address(
- new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new UnnumberedInterfaceIdentifier(2), true);
- final EROIPPrefixSubobject<IPv4Prefix> ips = new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 12, (byte) 122, (byte) 125, (byte) 2 }), 22), false);
-
- assertEquals(as.getASNumber().getAsn(), 2555);
- assertEquals(as.isLoose(), false);
- assertFalse(as.equals(null));
- assertFalse(as.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(as.equals(as));
-
- assertEquals(uis.getInterfaceID().getInterfaceId(), 2);
- assertEquals(uis.getRouterID(),
- new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }));
- assertEquals(uis.isLoose(), true);
- assertFalse(uis.equals(null));
- assertFalse(uis.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(uis.equals(uis));
-
- assertEquals(
- ips.getPrefix(),
- new IPv4Prefix(new IPv4Address(new byte[] { (byte) 12, (byte) 122, (byte) 125, (byte) 2 }), 22));
- assertEquals(ips.isLoose(), false);
- assertFalse(ips.equals(null));
- assertFalse(ips.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(ips.equals(ips));
- }
-
- @Test
- public void xroSubobjectsTest() {
- final XROAsNumberSubobject as = new XROAsNumberSubobject(new ASNumber(2555), false);
- final XROUnnumberedInterfaceSubobject uis = new XROUnnumberedInterfaceSubobject(new IPv4Address(
- new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }), new UnnumberedInterfaceIdentifier(2), true, XROSubobjectAttribute.SRLG);
- final XROIPPrefixSubobject<IPv4Prefix> ips = new XROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 12, (byte) 122, (byte) 125, (byte) 2 }), 22), false, XROSubobjectAttribute.SRLG);
- final XROSRLGSubobject srlg = new XROSRLGSubobject(new SharedRiskLinkGroup(0x1234L), true);
-
- assertEquals(as.getASNumber().getAsn(), 2555);
- assertEquals(as.isMandatory(), false);
- assertFalse(as.equals(null));
- assertFalse(as.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(as.equals(as));
- assertEquals(as.toString(), "XROAsNumberSubobject [asnumber=2555, mandatory=false]");
-
- assertEquals(uis.getInterfaceID().getInterfaceId(), 2);
- assertEquals(uis.getRouterID(),
- new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }));
- assertEquals(uis.isMandatory(), true);
- assertFalse(uis.equals(null));
- assertFalse(uis.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(uis.equals(uis));
- assertEquals(uis.getAttribute(), XROSubobjectAttribute.SRLG);
- assertEquals(uis.toString(),
- "XROUnnumberedInterfaceSubobject [attribute=SRLG, interfaceID=UnnumberedInterfaceIdentifier [interfaceId=2], routerID=127.0.0.2, mandatory=true]");
-
- assertEquals(
- ips.getPrefix(),
- new IPv4Prefix(new IPv4Address(new byte[] { (byte) 12, (byte) 122, (byte) 125, (byte) 2 }), 22));
- assertEquals(ips.isMandatory(), false);
- assertFalse(ips.equals(null));
- assertFalse(ips.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(ips.equals(ips));
- assertEquals(ips.getAttribute(), XROSubobjectAttribute.SRLG);
- assertEquals(ips.toString(), "XROIPPrefixSubobject [attribute=SRLG, prefix=12.122.124.0/22, mandatory=false]");
-
- assertEquals(srlg.getSrlgId().getValue(), 0x1234L);
- assertEquals(srlg.getAttribute(), XROSubobjectAttribute.SRLG);
- assertFalse(srlg.equals(null));
- assertFalse(srlg.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
- assertTrue(srlg.equals(srlg));
- assertEquals(srlg.toString(), "XROSRLGSubobject [attribute=SRLG, srlgId=4660, mandatory=true]");
- }
-
- @Test
- public void testToString(){
- final List<PCEPObject> objects = Lists.newArrayList();
- objects.add(new PCEPExistingPathBandwidthObject(new Bandwidth(22.0), true, false));
- objects.add(new PCEPRequestedPathBandwidthObject(new Bandwidth(22.0), true, false));
- objects.add(new PCEPEndPointsObject<IPv4Address>(IPv4.FAMILY.addressForBytes(new byte[]{1,1,1,1}),
- IPv4.FAMILY.addressForBytes(new byte[]{1,1,1,2})));
- objects.add(new PCEPP2MPEndPointsObject<IPv4Address>(0, IPv4.FAMILY.addressForBytes(new byte[] { 1, 1, 1, 1 }),
- Lists.newArrayList(IPv4.FAMILY.addressForBytes(new byte[] { 1, 1, 1, 1 })), true, false));
-
- for (final PCEPObject o: objects) {
+ final CompositeReplySvecObject m3 = new CompositeReplySvecObject(new PCEPSvecObject(true, true, true, false, false, requestIds, true));
+
+ assertEquals(m, m2);
+ assertEquals(m.toString(), m2.toString());
+ assertEquals(m.hashCode(), m2.hashCode());
+ assertEquals(m.getCompositeAsList(), m2.getCompositeAsList());
+ assertEquals(m.getObjectiveFunction(), m2.getObjectiveFunction());
+ assertEquals(m.getSvec(), m2.getSvec());
+ assertEquals(m, CompositeReplySvecObject.getCompositeFromList(m.getCompositeAsList()));
+ assertFalse(m.equals(null));
+ assertFalse(m.equals(m3));
+ assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(m.equals(m));
+ }
+
+ @Test
+ public void subobjectsTest() {
+ final EROAsNumberSubobject xas = new EROAsNumberSubobject(this.as, false);
+ final EROUnnumberedInterfaceSubobject uis = new EROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] { (byte) 127, (byte) 0,
+ (byte) 0, (byte) 2 }), new UnnumberedInterfaceIdentifier(2), true);
+ final EROIPPrefixSubobject<IPv4Prefix> ips = new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] {
+ (byte) 12, (byte) 122, (byte) 125, (byte) 2 }), 22), false);
+
+ assertEquals(xas.getASNumber().getValue().longValue(), 2555);
+ assertEquals(xas.isLoose(), false);
+ assertFalse(xas.equals(null));
+ assertFalse(xas.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(xas.equals(xas));
+
+ assertEquals(uis.getInterfaceID().getInterfaceId(), 2);
+ assertEquals(uis.getRouterID(), new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }));
+ assertEquals(uis.isLoose(), true);
+ assertFalse(uis.equals(null));
+ assertFalse(uis.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(uis.equals(uis));
+
+ assertEquals(ips.getPrefix(), new IPv4Prefix(new IPv4Address(new byte[] { (byte) 12, (byte) 122, (byte) 125, (byte) 2 }), 22));
+ assertEquals(ips.isLoose(), false);
+ assertFalse(ips.equals(null));
+ assertFalse(ips.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(ips.equals(ips));
+ }
+
+ @Test
+ public void xroSubobjectsTest() {
+ final XROAsNumberSubobject xas = new XROAsNumberSubobject(this.as, false);
+ final XROUnnumberedInterfaceSubobject uis = new XROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] { (byte) 127, (byte) 0,
+ (byte) 0, (byte) 2 }), new UnnumberedInterfaceIdentifier(2), true, XROSubobjectAttribute.SRLG);
+ final XROIPPrefixSubobject<IPv4Prefix> ips = new XROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] {
+ (byte) 12, (byte) 122, (byte) 125, (byte) 2 }), 22), false, XROSubobjectAttribute.SRLG);
+ final XROSRLGSubobject srlg = new XROSRLGSubobject(new SharedRiskLinkGroup(0x1234L), true);
+
+ assertEquals(xas.getASNumber().getValue().longValue(), 2555);
+ assertEquals(xas.isMandatory(), false);
+ assertFalse(xas.equals(null));
+ assertFalse(xas.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(xas.equals(xas));
+ assertEquals(xas.toString(), "XROAsNumberSubobject [asnumber=AsNumber [_value=2555], mandatory=false]");
+
+ assertEquals(uis.getInterfaceID().getInterfaceId(), 2);
+ assertEquals(uis.getRouterID(), new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }));
+ assertEquals(uis.isMandatory(), true);
+ assertFalse(uis.equals(null));
+ assertFalse(uis.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(uis.equals(uis));
+ assertEquals(uis.getAttribute(), XROSubobjectAttribute.SRLG);
+ assertEquals(
+ uis.toString(),
+ "XROUnnumberedInterfaceSubobject [attribute=SRLG, interfaceID=UnnumberedInterfaceIdentifier [interfaceId=2], routerID=127.0.0.2, mandatory=true]");
+
+ assertEquals(ips.getPrefix(), new IPv4Prefix(new IPv4Address(new byte[] { (byte) 12, (byte) 122, (byte) 125, (byte) 2 }), 22));
+ assertEquals(ips.isMandatory(), false);
+ assertFalse(ips.equals(null));
+ assertFalse(ips.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(ips.equals(ips));
+ assertEquals(ips.getAttribute(), XROSubobjectAttribute.SRLG);
+ assertEquals(ips.toString(), "XROIPPrefixSubobject [attribute=SRLG, prefix=12.122.124.0/22, mandatory=false]");
+
+ assertEquals(srlg.getSrlgId().getValue(), 0x1234L);
+ assertEquals(srlg.getAttribute(), XROSubobjectAttribute.SRLG);
+ assertFalse(srlg.equals(null));
+ assertFalse(srlg.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
+ assertTrue(srlg.equals(srlg));
+ assertEquals(srlg.toString(), "XROSRLGSubobject [attribute=SRLG, srlgId=4660, mandatory=true]");
+ }
+
+ @Test
+ public void testToString() {
+ final List<PCEPObject> objects = Lists.newArrayList();
+ objects.add(new PCEPExistingPathBandwidthObject(new Bandwidth(22.0), true, false));
+ objects.add(new PCEPRequestedPathBandwidthObject(new Bandwidth(22.0), true, false));
+ objects.add(new PCEPEndPointsObject<IPv4Address>(IPv4.FAMILY.addressForBytes(new byte[] { 1, 1, 1, 1 }), IPv4.FAMILY.addressForBytes(new byte[] {
+ 1, 1, 1, 2 })));
+ objects.add(new PCEPP2MPEndPointsObject<IPv4Address>(0, IPv4.FAMILY.addressForBytes(new byte[] { 1, 1, 1, 1 }), Lists.newArrayList(IPv4.FAMILY.addressForBytes(new byte[] {
+ 1, 1, 1, 1 })), true, false));
+
+ for (final PCEPObject o : objects) {
assertThat(o.toString(), containsString("processed=true"));
assertThat(o.toString(), containsString("ignored=false"));
- if(o instanceof PCEPBandwidthObject)
+ if (o instanceof PCEPBandwidthObject)
assertThat(o.toString(), containsString("bandwidth=Bandwidth [bytesPerSecond=22.0]"));
- if(o instanceof PCEPEndPoints)
+ if (o instanceof PCEPEndPoints)
assertThat(o.toString(), containsString("sourceAddress=1.1.1.1"));
- if(o instanceof PCEPP2MPEndPointsObject)
+ if (o instanceof PCEPP2MPEndPointsObject)
assertThat(o.toString(), containsString("destinationAddresses=[1.1.1.1]"));
}
- }
+ }
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.subobject.EROAsNumberSubobject;
import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject.EROAsNumberSubobject
- * EROAsNumberSubobject}
+ * Parser for {@link org.opendaylight.protocol.pcep.subobject.EROAsNumberSubobject EROAsNumberSubobject}
*/
public class EROAsNumberSubobjectParser {
public static final int CONTENT_LENGTH = AS_NUMBER_LENGTH + AS_NUMBER_OFFSET;
- public static EROAsNumberSubobject parse(byte[] soContentsBytes, boolean loose) throws PCEPDeserializerException {
+ public static EROAsNumberSubobject parse(final byte[] soContentsBytes, final boolean loose) throws PCEPDeserializerException {
if (soContentsBytes == null || soContentsBytes.length == 0)
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
if (soContentsBytes.length != CONTENT_LENGTH)
- throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: " + CONTENT_LENGTH + ".");
+ throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
+ + CONTENT_LENGTH + ".");
- return new EROAsNumberSubobject(new ASNumber((ByteArray.bytesToShort(soContentsBytes) & 0xFFFF)), loose);
+ return new EROAsNumberSubobject(new AsNumber((long) (ByteArray.bytesToShort(soContentsBytes) & 0xFFFF)), loose);
}
- public static byte[] put(ExplicitRouteSubobject objToSerialize) {
+ public static byte[] put(final ExplicitRouteSubobject objToSerialize) {
if (!(objToSerialize instanceof EROAsNumberSubobject))
throw new IllegalArgumentException("Unknown ExplicitRouteSubobject instance. Passed " + objToSerialize.getClass()
+ ". Needed EROAsNumberSubobject.");
final byte[] retBytes = new byte[CONTENT_LENGTH];
- System.arraycopy(ByteArray.longToBytes(((EROAsNumberSubobject) objToSerialize).getASNumber().getAsn()), Long.SIZE / Byte.SIZE - AS_NUMBER_LENGTH,
- retBytes, AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
+ System.arraycopy(ByteArray.longToBytes(((EROAsNumberSubobject) objToSerialize).getASNumber().getValue()), Long.SIZE / Byte.SIZE
+ - AS_NUMBER_LENGTH, retBytes, AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
return retBytes;
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.subobject.RROAsNumberSubobject;
import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject.RROAsNumberSubobject
- * RROAsNumberSubobject}
+ * Parser for {@link org.opendaylight.protocol.pcep.subobject.RROAsNumberSubobject RROAsNumberSubobject}
*/
public class RROAsNumberSubobjectParser {
public static final int CONTENT_LENGTH = AS_NUMBER_LENGTH + AS_NUMBER_OFFSET;
- public static RROAsNumberSubobject parse(byte[] soContentsBytes) throws PCEPDeserializerException {
+ public static RROAsNumberSubobject parse(final byte[] soContentsBytes) throws PCEPDeserializerException {
if (soContentsBytes == null || soContentsBytes.length == 0)
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
if (soContentsBytes.length != CONTENT_LENGTH)
- throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: " + CONTENT_LENGTH + ".");
+ throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
+ + CONTENT_LENGTH + ".");
- return new RROAsNumberSubobject(new ASNumber((ByteArray.bytesToShort(soContentsBytes) & 0xFFFF)));
+ return new RROAsNumberSubobject(new AsNumber((long) (ByteArray.bytesToShort(soContentsBytes) & 0xFFFF)));
}
- public static byte[] put(ReportedRouteSubobject objToSerialize) {
+ public static byte[] put(final ReportedRouteSubobject objToSerialize) {
if (!(objToSerialize instanceof RROAsNumberSubobject))
throw new IllegalArgumentException("Unknown ReportedRouteSubobject instance. Passed " + objToSerialize.getClass()
+ ". Needed RROAsNumberSubobject.");
final byte[] retBytes = new byte[CONTENT_LENGTH];
- System.arraycopy(ByteArray.longToBytes(((RROAsNumberSubobject) objToSerialize).getASNumber().getAsn()), Long.SIZE / Byte.SIZE - AS_NUMBER_LENGTH,
- retBytes, AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
+ System.arraycopy(ByteArray.longToBytes(((RROAsNumberSubobject) objToSerialize).getASNumber().getValue()), Long.SIZE / Byte.SIZE
+ - AS_NUMBER_LENGTH, retBytes, AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
return retBytes;
}
*/
package org.opendaylight.protocol.pcep.impl.subobject;
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
import org.opendaylight.protocol.pcep.subobject.XROAsNumberSubobject;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject.XROAsNumberSubobject
- * XROAsNumberSubobject}
+ * Parser for {@link org.opendaylight.protocol.pcep.subobject.XROAsNumberSubobject XROAsNumberSubobject}
*/
public class XROAsNumberSubobjectParser {
public static final int CONTENT_LENGTH = AS_NUMBER_LENGTH + AS_NUMBER_OFFSET;
- public static XROAsNumberSubobject parse(byte[] soContentsBytes, boolean mandatory) throws PCEPDeserializerException {
+ public static XROAsNumberSubobject parse(final byte[] soContentsBytes, final boolean mandatory) throws PCEPDeserializerException {
if (soContentsBytes == null || soContentsBytes.length == 0)
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
if (soContentsBytes.length != CONTENT_LENGTH)
- throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: " + CONTENT_LENGTH + ".");
+ throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
+ + CONTENT_LENGTH + ".");
- return new XROAsNumberSubobject(new ASNumber((ByteArray.bytesToShort(soContentsBytes) & 0xFFFF)), mandatory);
+ return new XROAsNumberSubobject(new AsNumber((long) (ByteArray.bytesToShort(soContentsBytes) & 0xFFFF)), mandatory);
}
- public static byte[] put(ExcludeRouteSubobject objToSerialize) {
+ public static byte[] put(final ExcludeRouteSubobject objToSerialize) {
if (!(objToSerialize instanceof XROAsNumberSubobject))
- throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + objToSerialize.getClass() + ". Needed XROAsNumberSubobject.");
+ throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + objToSerialize.getClass()
+ + ". Needed XROAsNumberSubobject.");
final byte[] retBytes = new byte[CONTENT_LENGTH];
- System.arraycopy(ByteArray.longToBytes(((XROAsNumberSubobject) objToSerialize).getASNumber().getAsn()), Long.SIZE / Byte.SIZE - AS_NUMBER_LENGTH,
- retBytes, AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
+ System.arraycopy(ByteArray.longToBytes(((XROAsNumberSubobject) objToSerialize).getASNumber().getValue()), Long.SIZE / Byte.SIZE
+ - AS_NUMBER_LENGTH, retBytes, AS_NUMBER_OFFSET, AS_NUMBER_LENGTH);
return retBytes;
}
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.Bandwidth;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.concepts.TEMetric;
import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
import org.opendaylight.protocol.pcep.tlv.LSPCleanupTlv;
import org.opendaylight.protocol.pcep.tlv.PCEStatefulCapabilityTlv;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
public class CompositeTest {
private static final long serialVersionUID = 1L;
{
- this.add(new EROAsNumberSubobject(new ASNumber(0L), true));
+ this.add(new EROAsNumberSubobject(new AsNumber(0L), true));
}
}, false, false);
public PCEPRequestParameterObject requestParameter;
private static final long serialVersionUID = 1L;
{
- this.add(new RROAsNumberSubobject(new ASNumber(0L)));
+ this.add(new RROAsNumberSubobject(new AsNumber(0L)));
}
}, false);
private static final long serialVersionUID = 1L;
{
- this.add(new EROAsNumberSubobject(new ASNumber(0L), true));
+ this.add(new EROAsNumberSubobject(new AsNumber(0L), true));
}
}, false);
this.ct = new PCEPClassTypeObject((short) 5);
this.notifications.add(this.notification);
final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>();
- eroSubobjects.add(new EROAsNumberSubobject(new ASNumber(0x0L), false));
- eroSubobjects.add(new EROAsNumberSubobject(new ASNumber(0x0L), false));
- eroSubobjects.add(new EROAsNumberSubobject(new ASNumber(0x0L), false));
+ eroSubobjects.add(new EROAsNumberSubobject(new AsNumber(0x0L), false));
+ eroSubobjects.add(new EROAsNumberSubobject(new AsNumber(0x0L), false));
+ eroSubobjects.add(new EROAsNumberSubobject(new AsNumber(0x0L), false));
final List<ReportedRouteSubobject> rroSubobjects = new ArrayList<ReportedRouteSubobject>();
- rroSubobjects.add(new RROAsNumberSubobject(new ASNumber(0x0L)));
- rroSubobjects.add(new RROAsNumberSubobject(new ASNumber(0x0L)));
- rroSubobjects.add(new RROAsNumberSubobject(new ASNumber(0x0L)));
+ rroSubobjects.add(new RROAsNumberSubobject(new AsNumber(0x0L)));
+ rroSubobjects.add(new RROAsNumberSubobject(new AsNumber(0x0L)));
+ rroSubobjects.add(new RROAsNumberSubobject(new AsNumber(0x0L)));
this.reportedRoute = new PCEPReportedRouteObject(rroSubobjects, true);
this.rroBandwidth = new PCEPExistingPathBandwidthObject(new Bandwidth(Float.intBitsToFloat(0xFF)), true, false);
this.endPoints = new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipbytes), new IPv4Address(ipbytes));
this.lsp = new PCEPLspObject(0, false, false, true, true, null);
- this.compositePaths.add(new CompositePathObject(new PCEPExplicitRouteObject(eroSubobjects, true), this.lspa, this.bandwidth, this.metrics,
- this.includeRoute));
+ this.compositePaths.add(new CompositePathObject(new PCEPExplicitRouteObject(eroSubobjects, true), this.lspa, this.bandwidth, this.metrics, this.includeRoute));
this.compositePaths.add(new CompositePathObject(new PCEPExplicitRouteObject(eroSubobjects, true)));
this.compositeUpdPaths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(eroSubobjects, true), this.lspa, this.bandwidth, this.metrics));
objects.addAll(this.requestParameters);
objects.addAll(this.errors);
- compositeErrors = new CompositeErrorObject(this.requestParameters.subList(0, this.requestParameters.size()), this.errors.subList(0, this.errors.size()));
+ compositeErrors = new CompositeErrorObject(this.requestParameters.subList(0, this.requestParameters.size()), this.errors.subList(0,
+ this.errors.size()));
assertEquals(compositeErrors, CompositeErrorObject.getCompositeFromList(objects));
objects.clear();
objects.addAll(this.requestParameters);
objects.addAll(this.notifications);
- compositeNotifications = new CompositeNotifyObject(this.requestParameters.subList(0, this.requestParameters.size()), this.notifications.subList(0,
- this.notifications.size()));
+ compositeNotifications = new CompositeNotifyObject(this.requestParameters.subList(0, this.requestParameters.size()), this.notifications.subList(
+ 0, this.notifications.size()));
assertEquals(compositeNotifications, CompositeNotifyObject.getCompositeFromList(objects));
objects.clear();
objects.add(this.includeRoute);
objects.add(this.loadBalancing);
- compositeRequest = new CompositeRequestObject(this.requestParameter, this.endPoints, this.ct, this.lsp, this.lspa, this.bandwidth,
- this.metrics.subList(0, this.metrics.size()), this.reportedRoute, this.rroBandwidth, this.includeRoute, this.loadBalancing);
+ compositeRequest = new CompositeRequestObject(this.requestParameter, this.endPoints, this.ct, this.lsp, this.lspa, this.bandwidth, this.metrics.subList(
+ 0, this.metrics.size()), this.reportedRoute, this.rroBandwidth, this.includeRoute, this.loadBalancing);
assertEquals(compositeRequest, CompositeRequestObject.getCompositeFromList(objects));
objects.clear();
import org.junit.Ignore;
import org.junit.Test;
-
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.Bandwidth;
import org.opendaylight.protocol.concepts.IGPMetric;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.pcep.tlv.OrderTlv;
import org.opendaylight.protocol.pcep.tlv.OverloadedDurationTlv;
import org.opendaylight.protocol.pcep.tlv.PCEStatefulCapabilityTlv;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
* Used resources<br/>
* - PCE currently unavailable: false<br/>
* - unknown destination: true<br/>
* - unknown source: false<br/>
- *
+ *
* <br/>
* NoPathObject2WithoutTLV.bin<br/>
* objClass: 3 (RP)<br/>
IPv4Address ipv4addr = new IPv4Address(new byte[] { (byte) 192, (byte) 168, 1, 8 });
- IPv6Address ipv6addr = new IPv6Address(new byte[] { (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168,
- 2, 1, (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1 });
+ IPv6Address ipv6addr = new IPv6Address(new byte[] { (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168,
+ 2, 1, (byte) 192, (byte) 168, 2, 1 });
@SuppressWarnings("unchecked")
private static <T extends PCEPObject> void serDeserTest(final String srcFile, final T specObject) throws IOException,
* Standard serialization test<br/>
* Used resources:<br/>
* - PCEPOpenObject1.bin<br/>
- *
+ *
* @throws PCEPDeserializerException
* @throws IOException
* @throws PCEPDocumentedException
*/
@Test
- @Ignore //FIXME: temporary
- public void testObjectDeserialization() throws PCEPDeserializerException, IOException,
- PCEPDocumentedException {
+ @Ignore
+ // FIXME: temporary
+ public void testObjectDeserialization() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
}
@Test
public void testUnknownClass() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
- final PCEPObject obj = PCEPObjectFactory.parseObjects(
- ByteArray.fileToBytes("src/test/resources/PCEPObject1UnknownClass.bin")).get(0);
+ final PCEPObject obj = PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPObject1UnknownClass.bin")).get(
+ 0);
assertTrue(obj instanceof UnknownObject);
assertEquals(((UnknownObject) obj).getError(), PCEPErrors.UNRECOGNIZED_OBJ_CLASS);
@Test
public void testUnknownType() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
- final PCEPObject obj = PCEPObjectFactory.parseObjects(
- ByteArray.fileToBytes("src/test/resources/PCEPObject2UnknownType.bin")).get(0);
+ final PCEPObject obj = PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPObject2UnknownType.bin")).get(0);
assertTrue(obj instanceof UnknownObject);
assertEquals(((UnknownObject) obj).getError(), PCEPErrors.UNRECOGNIZED_OBJ_TYPE);
@Test
public void testCloseObjSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- serDeserTest("src/test/resources/PCEPCloseObject1.bin", new PCEPCloseObject(
- Reason.TOO_MANY_UNKNOWN_MSG));
+ serDeserTest("src/test/resources/PCEPCloseObject1.bin", new PCEPCloseObject(Reason.TOO_MANY_UNKNOWN_MSG));
}
@Test
- public void testLoadBalancingObjSerDeser() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
- serDeserTest("src/test/resources/PCEPLoadBalancingObject1.bin", new PCEPLoadBalancingObject(0xF1,
- new Bandwidth(Float.intBitsToFloat(0xFFFFFFFF)), true));
+ public void testLoadBalancingObjSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+ serDeserTest("src/test/resources/PCEPLoadBalancingObject1.bin",
+ new PCEPLoadBalancingObject(0xF1, new Bandwidth(Float.intBitsToFloat(0xFFFFFFFF)), true));
}
@Test
- public void testLspObjectSerDeser() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
- serDeserTest("src/test/resources/PCEPLspObject1NoTlvsUpperBounds.bin", new PCEPLspObject(0xFFFFF,
- true, false, true, false, null));
+ public void testLspObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+ serDeserTest("src/test/resources/PCEPLspObject1NoTlvsUpperBounds.bin", new PCEPLspObject(0xFFFFF, true, false, true, false, null));
}
@Test
public void testERObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- final byte[] bytesFromFile = ByteArray
- .fileToBytes("src/test/resources/PCEPExplicitRouteObject1PackOfSubobjects.bin");
+ final byte[] bytesFromFile = ByteArray.fileToBytes("src/test/resources/PCEPExplicitRouteObject1PackOfSubobjects.bin");
- final PCEPExplicitRouteObject specObj = (PCEPExplicitRouteObject) PCEPObjectFactory.parseObjects(
- bytesFromFile).get(0);
+ final PCEPExplicitRouteObject specObj = (PCEPExplicitRouteObject) PCEPObjectFactory.parseObjects(bytesFromFile).get(0);
assertEquals(8, specObj.getSubobjects().size());
@Test
public void testIRObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- final byte[] bytesFromFile = ByteArray
- .fileToBytes("src/test/resources/PCEPIncludeRouteObject1PackOfSubobjects.bin");
+ final byte[] bytesFromFile = ByteArray.fileToBytes("src/test/resources/PCEPIncludeRouteObject1PackOfSubobjects.bin");
- final PCEPIncludeRouteObject specObj = (PCEPIncludeRouteObject) PCEPObjectFactory.parseObjects(
- bytesFromFile).get(0);
+ final PCEPIncludeRouteObject specObj = (PCEPIncludeRouteObject) PCEPObjectFactory.parseObjects(bytesFromFile).get(0);
assertEquals(8, specObj.getSubobjects().size());
@Test
public void tesRRObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- final byte[] bytesFromFile = ByteArray
- .fileToBytes("src/test/resources/PCEPReportedRouteObject1PackOfSubobjects.bin");
+ final byte[] bytesFromFile = ByteArray.fileToBytes("src/test/resources/PCEPReportedRouteObject1PackOfSubobjects.bin");
- final PCEPReportedRouteObject specObj = (PCEPReportedRouteObject) PCEPObjectFactory.parseObjects(
- bytesFromFile).get(0);
+ final PCEPReportedRouteObject specObj = (PCEPReportedRouteObject) PCEPObjectFactory.parseObjects(bytesFromFile).get(0);
assertEquals(6, specObj.getSubobjects().size());
* Used resources:<br/>
* - PCEPBandwidthObject2UpperBounds.bin<br/>
* - PCEPBandwidthObject1LowerBounds.bin<br/>
- *
+ *
* @throws IOException
* @throws PCEPDeserializerException
* @throws PCEPDocumentedException
*/
@Test
- public void testBandwidthObjectBounds() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
+ public void testBandwidthObjectBounds() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
final byte[] bytesFloat = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
serDeserTest("src/test/resources/PCEPBandwidthObject2UpperBounds.bin",
- new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.bytesToFloat(bytesFloat)), true,
- true));
+ new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.bytesToFloat(bytesFloat)), true, true));
serDeserTest("src/test/resources/PCEPBandwidthObject1LowerBounds.bin",
new PCEPRequestedPathBandwidthObject(new Bandwidth(0), true, true));
}
/**
- * Test for upper/lower bounds of IPv4 EndPoints
- * (Serialization/Deserialization)<br/>
+ * Test for upper/lower bounds of IPv4 EndPoints (Serialization/Deserialization)<br/>
* Used resources:<br/>
* - PCEPEndPointsObject1IPv4.bin<br/>
- *
+ *
* @throws IOException
* @throws PCEPDeserializerException
* @throws PCEPDocumentedException
*/
@Test
- public void testEndPointsObjectSerDeserIPv4() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
+ public void testEndPointsObjectSerDeserIPv4() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
final byte[] destIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- serDeserTest("src/test/resources/PCEPEndPointsObject1IPv4.bin", new PCEPEndPointsObject<IPv4Address>(
- new IPv4Address(srcIPBytes), new IPv4Address(destIPBytes)));
+ serDeserTest("src/test/resources/PCEPEndPointsObject1IPv4.bin",
+ new PCEPEndPointsObject<IPv4Address>(new IPv4Address(srcIPBytes), new IPv4Address(destIPBytes)));
}
/**
- * Test for upper/lower bounds of IPv6 EndPoints
- * (Serialization/Deserialization)<br/>
+ * Test for upper/lower bounds of IPv6 EndPoints (Serialization/Deserialization)<br/>
* Used resources:<br/>
* - PCEPEndPointsObject2IPv6.bin<br/>
- *
+ *
* @throws IOException
* @throws PCEPDeserializerException
* @throws PCEPDocumentedException
*/
@Test
- public void testEndPointsObjectSerDeserIPv6() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
- final byte[] destIPBytes = { (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2, (byte) 0xFF,
- (byte) 0xEC, (byte) 0xA1, (byte) 0xB6, (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, };
- final byte[] srcIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+ public void testEndPointsObjectSerDeserIPv6() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+ final byte[] destIPBytes = { (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2, (byte) 0xFF, (byte) 0xEC, (byte) 0xA1,
+ (byte) 0xB6, (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, };
+ final byte[] srcIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- serDeserTest("src/test/resources/PCEPEndPointsObject2IPv6.bin", new PCEPEndPointsObject<IPv6Address>(
- new IPv6Address(srcIPBytes), new IPv6Address(destIPBytes)));
+ serDeserTest("src/test/resources/PCEPEndPointsObject2IPv6.bin",
+ new PCEPEndPointsObject<IPv6Address>(new IPv6Address(srcIPBytes), new IPv6Address(destIPBytes)));
}
/**
* Used resources:<br/>
* - PCEPErrorObject1.bin<br/>
* - PCEPErrorObject3.bin<br/>
- *
+ *
* @throws PCEPDeserializerException
* @throws IOException
* @throws PCEPDocumentedException
*/
@Test
- public void testErrorObjectSerDeserWithTlv() throws PCEPDeserializerException, IOException,
- PCEPDocumentedException {
- serDeserTest("src/test/resources/PCEPErrorObject1.bin", new PCEPErrorObject(
- PCEPErrors.NON_OR_INVALID_OPEN_MSG));
- serDeserTest("src/test/resources/PCEPErrorObject3.bin", new PCEPErrorObject(
- PCEPErrors.CAPABILITY_NOT_SUPPORTED));
+ public void testErrorObjectSerDeserWithTlv() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
+ serDeserTest("src/test/resources/PCEPErrorObject1.bin", new PCEPErrorObject(PCEPErrors.NON_OR_INVALID_OPEN_MSG));
+ serDeserTest("src/test/resources/PCEPErrorObject3.bin", new PCEPErrorObject(PCEPErrors.CAPABILITY_NOT_SUPPORTED));
}
/**
- * Test of validity of PCEPErrorObjectParser. Expect throwed
- * NoSuchElementException.<br/>
+ * Test of validity of PCEPErrorObjectParser. Expect throwed NoSuchElementException.<br/>
* <br/>
* Used resources:<br/>
* - PCEPErrorObject2Invalid.bin<br/>
- *
+ *
* @throws NoSuchElementException
* @throws IOException
* @throws PCEPDocumentedException
*/
@Test(expected = PCEPDeserializerException.class)
public void testUnknownError() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
- PCEPObjectFactory.parseObjects(
- ByteArray.fileToBytes("src/test/resources/PCEPErrorObject2Invalid.bin")).get(0);
+ PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject2Invalid.bin")).get(0);
}
/**
- * Test for upper/lower bounds of PCEPLspaObject
- * (Serialization/Deserialization)<br/>
+ * Test for upper/lower bounds of PCEPLspaObject (Serialization/Deserialization)<br/>
* Used resources:<br/>
* - PCEPLspaObject1LowerBounds.bin<br/>
* - PCEPLspaObject2UpperBounds.bin<br/>
* - PCEPLspaObject3RandVals.bin<br/>
- *
+ *
* @throws IOException
* @throws PCEPDeserializerException
* @throws PCEPDocumentedException
*/
@Test
- public void testLspaObjectSerDeser() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
- serDeserTest("src/test/resources/PCEPLspaObject2UpperBounds.bin", new PCEPLspaObject(0xFFFFFFFFL,
- 0xFFFFFFFFL, 0xFFFFFFFFL, (short) 0xFF, (short) 0xFF, false, true, true, true));
- serDeserTest("src/test/resources/PCEPLspaObject1LowerBounds.bin", new PCEPLspaObject(0x00000000L,
- 0x00000000L, 0x00000000L, (short) 0x00, (short) 0x00, false, false, true, true));
- serDeserTest("src/test/resources/PCEPLspaObject3RandVals.bin", new PCEPLspaObject(0x20A1FEE3L,
- 0x1A025CC7L, 0x2BB66532L, (short) 0x03, (short) 0x02, false, true, true, true));
+ public void testLspaObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+ serDeserTest("src/test/resources/PCEPLspaObject2UpperBounds.bin",
+ new PCEPLspaObject(0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, (short) 0xFF, (short) 0xFF, false, true, true, true));
+ serDeserTest("src/test/resources/PCEPLspaObject1LowerBounds.bin",
+ new PCEPLspaObject(0x00000000L, 0x00000000L, 0x00000000L, (short) 0x00, (short) 0x00, false, false, true, true));
+ serDeserTest("src/test/resources/PCEPLspaObject3RandVals.bin",
+ new PCEPLspaObject(0x20A1FEE3L, 0x1A025CC7L, 0x2BB66532L, (short) 0x03, (short) 0x02, false, true, true, true));
}
@Test
- public void testMetricObjectSerDeserBounds() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
- final byte[] bytesFromFileUB = ByteArray
- .fileToBytes("src/test/resources/PCEPMetricObject2UpperBounds.bin");
- final byte[] bytesFromFileLB = ByteArray
- .fileToBytes("src/test/resources/PCEPMetricObject1LowerBounds.bin");
+ public void testMetricObjectSerDeserBounds() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+ final byte[] bytesFromFileUB = ByteArray.fileToBytes("src/test/resources/PCEPMetricObject2UpperBounds.bin");
+ final byte[] bytesFromFileLB = ByteArray.fileToBytes("src/test/resources/PCEPMetricObject1LowerBounds.bin");
- final PCEPMetricObject metricObjectLB = (PCEPMetricObject) PCEPObjectFactory.parseObjects(
- bytesFromFileLB).get(0);
- final PCEPMetricObject metricObjectUB = (PCEPMetricObject) PCEPObjectFactory.parseObjects(
- bytesFromFileUB).get(0);
+ final PCEPMetricObject metricObjectLB = (PCEPMetricObject) PCEPObjectFactory.parseObjects(bytesFromFileLB).get(0);
+ final PCEPMetricObject metricObjectUB = (PCEPMetricObject) PCEPObjectFactory.parseObjects(bytesFromFileUB).get(0);
assertEquals(new PCEPMetricObject(false, false, new IGPMetric(0), true, true), metricObjectLB);
assertEquals(new PCEPMetricObject(false, true, new TEMetric(4026531840L), true, true), metricObjectUB);
* Used resources:<br/>
* - NoPathObject1WithTLV.bin<br/>
* - NoPathObject2WithoutTLV.bin<br/>
- *
+ *
* @throws PCEPDeserializerException
* @throws IOException
* @throws PCEPDocumentedException
*/
@Test
- public void testNoPathObjectDeserialization() throws PCEPDeserializerException, IOException,
- PCEPDocumentedException {
+ public void testNoPathObjectDeserialization() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>(1);
tlvs.add(new NoPathVectorTlv(false, false, true, false, false, false));
- serDeserTest("src/test/resources/NoPathObject1WithTLV.bin", new PCEPNoPathObject((short) 2, true,
- tlvs, false));
- serDeserTest("src/test/resources/NoPathObject2WithoutTLV.bin", new PCEPNoPathObject((short) 0x10,
- false, true));
+ serDeserTest("src/test/resources/NoPathObject1WithTLV.bin", new PCEPNoPathObject((short) 2, true, tlvs, false));
+ serDeserTest("src/test/resources/NoPathObject2WithoutTLV.bin", new PCEPNoPathObject((short) 0x10, false, true));
}
* Used resources:<br/>
* - NoPathObject1WithTLV.bin<br/>
* - NoPathObject2WithoutTLV.bin<br/>
- *
+ *
* @throws PCEPDeserializerException
* @throws IOException
* @throws PCEPDocumentedException
*/
@Test
- public void testNoPathObjectSerialization() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
+ public void testNoPathObjectSerialization() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
byte[] bytesFromFile = ByteArray.fileToBytes("src/test/resources/NoPathObject2WithoutTLV.bin");
- PCEPNoPathObject noPathObject = (PCEPNoPathObject) PCEPObjectFactory.parseObjects(bytesFromFile).get(
- 0);
+ PCEPNoPathObject noPathObject = (PCEPNoPathObject) PCEPObjectFactory.parseObjects(bytesFromFile).get(0);
byte[] bytesActual = PCEPObjectFactory.put(Arrays.asList((PCEPObject) noPathObject));
assertArrayEquals(bytesFromFile, bytesActual);
/**
* Specific test with/without tlvs (Ser/Deser)<br/>
* Used resources:<br/>
- * - PCEPNotificationObject1WithTlv.bin -
- * PCEPNotificationObject2WithoutTlv.bin
- *
+ * - PCEPNotificationObject1WithTlv.bin - PCEPNotificationObject2WithoutTlv.bin
+ *
* @throws PCEPDeserializerException
* @throws IOException
* @throws PCEPDocumentedException
*/
@Test
- public void testNotifyObjectSerDeserWithTlv() throws PCEPDeserializerException, IOException,
- PCEPDocumentedException {
+ public void testNotifyObjectSerDeserWithTlv() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>(1);
tlvs.add(new OverloadedDurationTlv(0xFF0000A2));
- serDeserTest("src/test/resources/PCEPNotificationObject1WithTlv.bin", new PCEPNotificationObject(
- (short) 1, (short) 1, tlvs));
- serDeserTest("src/test/resources/PCEPNotificationObject2WithoutTlv.bin", new PCEPNotificationObject(
- (short) 0xFF, (short) 0xFF));
+ serDeserTest("src/test/resources/PCEPNotificationObject1WithTlv.bin", new PCEPNotificationObject((short) 1, (short) 1, tlvs));
+ serDeserTest("src/test/resources/PCEPNotificationObject2WithoutTlv.bin", new PCEPNotificationObject((short) 0xFF, (short) 0xFF));
}
/**
* Standard ser deser test<br/>
* used resources:<br/>
* - PCEPOpenObject1.bin
- *
+ *
* @throws PCEPDeserializerException
* @throws IOException
* @throws PCEPDocumentedException
*/
@Test
- @Ignore //FIXME: temporary
- public void testOpenObjectSerDeser() throws PCEPDeserializerException, IOException,
- PCEPDocumentedException {
+ @Ignore
+ // FIXME: temporary
+ public void testOpenObjectSerDeser() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
tlvs.add(new PCEStatefulCapabilityTlv(false, true, true));
tlvs.add(new LSPStateDBVersionTlv(0x80));
- final byte[] valueBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A,
- (byte) 0xBC, (byte) 0xDE, (byte) 0xF0 };
+ final byte[] valueBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0xF0 };
tlvs.add(new NodeIdentifierTlv(valueBytes));
final PCEPOpenObject specObject = new PCEPOpenObject(30, 120, 1, tlvs);
* Specific test for upper bounds and without tlvs<br/>
* Used resources:<br/>
* - PCEPOpenObject2UpperBoundsNoTlv.bin
- *
+ *
* @throws PCEPDeserializerException
* @throws IOException
* @throws PCEPDocumentedException
*/
@Test
- public void testOpenObjectBoundsWithoutTlvs() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
+ public void testOpenObjectBoundsWithoutTlvs() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
- serDeserTest("src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin", new PCEPOpenObject(0xFF, 0xFF,
- 0xFF, tlvs));
- serDeserTest("src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin", new PCEPOpenObject(0xFF, 0xFF,
- 0xFF, null));
+ serDeserTest("src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin", new PCEPOpenObject(0xFF, 0xFF, 0xFF, tlvs));
+ serDeserTest("src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin", new PCEPOpenObject(0xFF, 0xFF, 0xFF, null));
}
/**
* Standard deserialization test<br/>
* Used resources:<br/>
* - PCEPRPObject1.bin
- *
+ *
* @throws PCEPDeserializerException
* @throws IOException
* @throws PCEPDocumentedException
*/
@Test
public void testRPObjectSerDeser() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
- serDeserTest("src/test/resources/PCEPRPObject1.bin", new PCEPRequestParameterObject(true, false,
- true, true, false, false, false, false, (short) 5, 0xdeadbeefL, false, false));
- serDeserTest("src/test/resources/PCEPRPObject2.bin", new PCEPRequestParameterObject(true, false,
- false, false, true, false, true, false, true, (short) 5, 0xdeadbeefL,
- new ArrayList<PCEPTlv>() {
+ serDeserTest("src/test/resources/PCEPRPObject1.bin",
+ new PCEPRequestParameterObject(true, false, true, true, false, false, false, false, (short) 5, 0xdeadbeefL, false, false));
+ serDeserTest(
+ "src/test/resources/PCEPRPObject2.bin",
+ new PCEPRequestParameterObject(true, false, false, false, true, false, true, false, true, (short) 5, 0xdeadbeefL, new ArrayList<PCEPTlv>() {
private static final long serialVersionUID = 1L;
{
}
/**
- * Test for upper/lower bounds of PCEPSvecObject
- * (Serialization/Deserialization)<br/>
+ * Test for upper/lower bounds of PCEPSvecObject (Serialization/Deserialization)<br/>
* Used resources:<br/>
* - PCEPSvecObject1_10ReqIDs.bin<br/>
- *
+ *
* @throws IOException
* @throws PCEPDeserializerException
* @throws PCEPDocumentedException
*/
@Test
- public void testSvecObjectSerDeser() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
+ public void testSvecObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
final List<Long> requestIDs = new ArrayList<Long>(10);
requestIDs.add(0xFFFFFFFFL);
requestIDs.add(0x00000000L);
requestIDs.add(0x25FB7E52L);
requestIDs.add(0xB2F2546BL);
- serDeserTest("src/test/resources/PCEPSvecObject1_10ReqIDs.bin", new PCEPSvecObject(true, false, true,
- false, true, requestIDs, true));
+ serDeserTest("src/test/resources/PCEPSvecObject1_10ReqIDs.bin",
+ new PCEPSvecObject(true, false, true, false, true, requestIDs, true));
}
/**
* Test for lowest bounds of PCEPSvecObject (Serialization/Deserialization)<br/>
* Used resources:<br/>
* - PCEPSvecObject2.bin<br/>
- *
+ *
* @throws IOException
* @throws PCEPDeserializerException
* @throws PCEPDocumentedException
*/
@Test
- public void testSvecObjectSerDeserNoReqIDs() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
+ public void testSvecObjectSerDeserNoReqIDs() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
final List<Long> requestIDs = new ArrayList<Long>();
requestIDs.add(0xFFL);
- serDeserTest("src/test/resources/PCEPSvecObject2.bin", new PCEPSvecObject(false, false, false, false,
- false, requestIDs, false));
+ serDeserTest("src/test/resources/PCEPSvecObject2.bin", new PCEPSvecObject(false, false, false, false, false, requestIDs, false));
}
@Test
* Test PCEPExcludeRouteObjectObject (Serialization/Deserialization)<br/>
* Used resources:<br/>
* - PCEPExcludeRouteObject.1.bin<br/>
- *
+ *
* @throws IOException
* @throws PCEPDeserializerException
* @throws PCEPDocumentedException
*/
@Test
- public void testExcludeRouteObject() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
+ public void testExcludeRouteObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
final List<ExcludeRouteSubobject> xroSubobjects = new ArrayList<ExcludeRouteSubobject>();
- xroSubobjects.add(new XROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] {
- (byte) 192, (byte) 168, (byte) 100, (byte) 100 }), 16), true, XROSubobjectAttribute.NODE));
- xroSubobjects.add(new XROAsNumberSubobject(new ASNumber(0x1234L), false));
+ xroSubobjects.add(new XROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 192, (byte) 168,
+ (byte) 100, (byte) 100 }), 16), true, XROSubobjectAttribute.NODE));
+ xroSubobjects.add(new XROAsNumberSubobject(new AsNumber(0x1234L), false));
}
@Test
- public void tesObjectiveFunctionObject() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
- serDeserTest("src/test/resources/PCEPObjectiveFunctionObject.1.bin", new PCEPObjectiveFunctionObject(
- PCEPOFCodes.MBC, true, false));
+ public void tesObjectiveFunctionObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+ serDeserTest("src/test/resources/PCEPObjectiveFunctionObject.1.bin", new PCEPObjectiveFunctionObject(PCEPOFCodes.MBC, true, false));
}
@Test
- public void tesGlobalConstraintsObject() throws IOException, PCEPDeserializerException,
- PCEPDocumentedException {
- serDeserTest("src/test/resources/PCEPGlobalConstraintsObject.1.bin", new PCEPGlobalConstraintsObject(
- (short) 1, (short) 0, (short) 100, (short) 0xFF, true, false));
+ public void tesGlobalConstraintsObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+ serDeserTest("src/test/resources/PCEPGlobalConstraintsObject.1.bin",
+ new PCEPGlobalConstraintsObject((short) 1, (short) 0, (short) 100, (short) 0xFF, true, false));
}
// FIXME: add at least one test with true value
this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, true, true));
}
- private void testOpenObjectWithSpecTlv(final PCEPTlv tlv) throws PCEPDeserializerException,
- PCEPDocumentedException {
+ private void testOpenObjectWithSpecTlv(final PCEPTlv tlv) throws PCEPDeserializerException, PCEPDocumentedException {
final List<PCEPObject> objs = new ArrayList<PCEPObject>();
final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
tlvs.add(tlv);
@Test
public void testErrorsMapping() {
- final PCEPErrorObjectParser.PCEPErrorsMaping mapper = PCEPErrorObjectParser.PCEPErrorsMaping
- .getInstance();
+ final PCEPErrorObjectParser.PCEPErrorsMaping mapper = PCEPErrorObjectParser.PCEPErrorsMaping.getInstance();
for (final PCEPErrors error : PCEPErrors.values()) {
final PCEPErrorIdentifier errorId = mapper.getFromErrorsEnum(error);
}
@SuppressWarnings("unchecked")
- private static <T extends PCEPObject> void serDeserTestWithoutBin(final T object)
- throws PCEPDeserializerException, PCEPDocumentedException {
+ private static <T extends PCEPObject> void serDeserTestWithoutBin(final T object) throws PCEPDeserializerException,
+ PCEPDocumentedException {
final byte[] serBytes = PCEPObjectFactory.put(Arrays.asList((PCEPObject) object));
final T deserObj = (T) PCEPObjectFactory.parseObjects(serBytes).get(0);
@Test
public void testBranchNodeObjects() throws PCEPDocumentedException, PCEPDeserializerException {
final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>();
- eroSubobjects.add(new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] {
- (byte) 192, (byte) 168, 1, 8 }), 16), false));
- eroSubobjects.add(new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(new byte[] {
- (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1,
- (byte) 192, (byte) 168, 2, 1 }), 64), false));
+ eroSubobjects.add(new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 192, (byte) 168, 1, 8 }), 16), false));
+ eroSubobjects.add(new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(new byte[] { (byte) 192, (byte) 168, 2, 1,
+ (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1 }), 64), false));
serDeserTestWithoutBin(new PCEPBranchNodeListObject(eroSubobjects, true, false));
serDeserTestWithoutBin(new PCEPNonBranchNodeListObject(eroSubobjects, true, false));
@Test
public void testSERObjects() throws PCEPDocumentedException, PCEPDeserializerException {
final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>();
- eroSubobjects.add(new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] {
- (byte) 192, (byte) 168, 1, 8 }), 16), false));
- eroSubobjects.add(new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(new byte[] {
- (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1,
- (byte) 192, (byte) 168, 2, 1 }), 64), false));
+ eroSubobjects.add(new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 192, (byte) 168, 1, 8 }), 16), false));
+ eroSubobjects.add(new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(new byte[] { (byte) 192, (byte) 168, 2, 1,
+ (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1 }), 64), false));
serDeserTestWithoutBin(new PCEPSecondaryExplicitRouteObject(eroSubobjects, true, false));
}
@Test
public void testSRRObject() throws PCEPDocumentedException, PCEPDeserializerException {
final List<ReportedRouteSubobject> rroSubobjects = new ArrayList<ReportedRouteSubobject>();
- rroSubobjects.add(new RROIPAddressSubobject<IPv4Prefix>(new IPv4Prefix(this.ipv4addr, 16), true,
- false));
- rroSubobjects.add(new RROIPAddressSubobject<IPv6Prefix>(new IPv6Prefix(this.ipv6addr, 64), false,
- true));
+ rroSubobjects.add(new RROIPAddressSubobject<IPv4Prefix>(new IPv4Prefix(this.ipv4addr, 16), true, false));
+ rroSubobjects.add(new RROIPAddressSubobject<IPv6Prefix>(new IPv6Prefix(this.ipv6addr, 64), false, true));
serDeserTestWithoutBin(new PCEPSecondaryRecordRouteObject(rroSubobjects, true, false));
}
@Test
public void testP2MPEndpointsObjects() throws PCEPDeserializerException, PCEPDocumentedException {
- serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv4Address>(2, this.ipv4addr, Arrays.asList(
- this.ipv4addr, this.ipv4addr, this.ipv4addr), true, false));
- serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv4Address>(1, this.ipv4addr,
- Arrays.asList(this.ipv4addr), true, false));
- serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv6Address>(2, this.ipv6addr, Arrays.asList(
- this.ipv6addr, this.ipv6addr, this.ipv6addr), true, false));
- serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv6Address>(1, this.ipv6addr,
- Arrays.asList(this.ipv6addr), true, false));
+ serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv4Address>(2, this.ipv4addr, Arrays.asList(this.ipv4addr, this.ipv4addr,
+ this.ipv4addr), true, false));
+ serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv4Address>(1, this.ipv4addr, Arrays.asList(this.ipv4addr), true, false));
+ serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv6Address>(2, this.ipv6addr, Arrays.asList(this.ipv6addr, this.ipv6addr,
+ this.ipv6addr), true, false));
+ serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv6Address>(1, this.ipv6addr, Arrays.asList(this.ipv6addr), true, false));
}
@Test
public void testUnreachedDestinationObjects() throws PCEPDeserializerException, PCEPDocumentedException {
- serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv4Address>(Arrays.asList(this.ipv4addr,
- this.ipv4addr, this.ipv4addr), true, false));
- serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv4Address>(Arrays.asList(this.ipv4addr),
- true, false));
- serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv6Address>(Arrays.asList(this.ipv6addr,
- this.ipv6addr, this.ipv6addr), true, false));
- serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv6Address>(Arrays.asList(this.ipv6addr),
- true, false));
+ serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv4Address>(Arrays.asList(this.ipv4addr, this.ipv4addr, this.ipv4addr), true, false));
+ serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv4Address>(Arrays.asList(this.ipv4addr), true, false));
+ serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv6Address>(Arrays.asList(this.ipv6addr, this.ipv6addr, this.ipv6addr), true, false));
+ serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv6Address>(Arrays.asList(this.ipv6addr), true, false));
}
}
import java.util.List;
import org.junit.Test;
-
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.concepts.IPv4Prefix;
import org.opendaylight.protocol.concepts.IPv6Address;
import org.opendaylight.protocol.pcep.subobject.XROSRLGSubobject;
import org.opendaylight.protocol.pcep.subobject.XROSubobjectAttribute;
import org.opendaylight.protocol.pcep.subobject.XROUnnumberedInterfaceSubobject;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
/**
* Tests for subobjects
*/
public class PCEPSubobjectParserTest {
- final byte[] ipv6bytes1 = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- final byte[] ipv6bytes2 = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0x12, (byte) 0x34,
- (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
-
- final byte[] ipv4bytes1 = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- final byte[] ipv4bytes2 = { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 };
-
- @Test
- public void testSerDeser() throws PCEPDeserializerException, IOException {
- final byte[] bytesFromFile = ByteArray.fileToBytes("src/test/resources/PackOfSubobjects.bin");
- final List<ExplicitRouteSubobject> objsToTest = PCEPEROSubobjectParser.parse(bytesFromFile);
-
- assertEquals(8, objsToTest.size());
-
- assertEquals(objsToTest.get(0), new EROAsNumberSubobject(new ASNumber(0xFFFFL), true));
- assertEquals(objsToTest.get(1), new EROAsNumberSubobject(new ASNumber(0x0010L), false));
- assertEquals(objsToTest.get(2),
- new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(this.ipv4bytes1), 0x20),
- true));
-
- assertEquals(objsToTest.get(3),
- new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(this.ipv4bytes2), 0x15),
- false));
- assertEquals(objsToTest.get(4),
- new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(this.ipv6bytes1), 0x80),
- true));
-
- assertEquals(objsToTest.get(5),
- new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(this.ipv6bytes2), 0x16),
- false));
- final byte[] addr1 = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- assertEquals(objsToTest.get(6), new EROUnnumberedInterfaceSubobject(new IPv4Address(addr1),
- new UnnumberedInterfaceIdentifier(0xFFFFFFFFL), true));
-
- final byte[] addr2 = { (byte) 0x01, (byte) 0x24, (byte) 0x56, (byte) 0x78 };
- assertEquals(objsToTest.get(7), new EROUnnumberedInterfaceSubobject(new IPv4Address(addr2),
- new UnnumberedInterfaceIdentifier(0x9ABCDEF0L), false));
-
- assertArrayEquals(bytesFromFile, PCEPEROSubobjectParser.put(objsToTest));
-
- }
-
- @Test
- public void testEROSubojectsSerDeserWithoutBin() throws PCEPDeserializerException {
- final List<ExplicitRouteSubobject> objsToTest = new ArrayList<ExplicitRouteSubobject>();
- objsToTest.add(new EROType1LabelSubobject(0xFFFF51F2L, true, false));
- objsToTest.add(new EROType1LabelSubobject(0x12345648L, false, true));
- objsToTest.add(new EROGeneralizedLabelSubobject(new byte[] { (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte) 0xFF }, true, true));
- objsToTest.add(new EROWavebandSwitchingLabelSubobject(0x12345678L, 0x87654321L, 0xFFFFFFFFL, false, false));
- objsToTest.add(new EROProtectionType1Subobject(true, (byte) 0x05, true));
- objsToTest.add(new EROProtectionType2Subobject(true, false, true, true, (byte) 0x06, (byte) 0x3f, true, false, (byte) 0x00, false));
- objsToTest.add(new EROPathKeyWith32PCEIDSubobject(0x1235, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }, true));
- objsToTest.add(new EROPathKeyWith128PCEIDSubobject(0x5432, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55,
- (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }, true));
- objsToTest.add(new EROExplicitExclusionRouteSubobject(Arrays.asList((ExcludeRouteSubobject) new XROAsNumberSubobject(new ASNumber(2588), true))));
-
- assertEquals(objsToTest, PCEPEROSubobjectParser.parse(PCEPEROSubobjectParser.put(objsToTest)));
- }
-
- @Test
- public void testRROSubojectsSerDeserWithoutBin() throws PCEPDeserializerException {
- final List<ReportedRouteSubobject> objsToTest = new ArrayList<ReportedRouteSubobject>();
- objsToTest.add(new RROIPAddressSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(this.ipv6bytes2),
- 0x16), true, false));
- objsToTest.add(new RROIPAddressSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(this.ipv4bytes1),
- 0x16), true, false));
- objsToTest.add(new RROType1LabelSubobject(0xFFFF51F2L, true));
- objsToTest.add(new RROType1LabelSubobject(0x12345648L, false));
- objsToTest.add(new RROGeneralizedLabelSubobject(new byte[] { (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte) 0xFF }, true));
- objsToTest.add(new RROWavebandSwitchingLabelSubobject(0x12345678L, 0x87654321L, 0xFFFFFFFFL, false));
- objsToTest.add(new RROProtectionType1Subobject(true, (byte) 0x05));
- objsToTest.add(new RROProtectionType2Subobject(true, false, true, true, (byte) 0x06, (byte) 0x3f, true, false, (byte) 0x00));
- objsToTest.add(new RROPathKeyWith32PCEIDSubobject(0x1235, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }));
- objsToTest.add(new RROPathKeyWith128PCEIDSubobject(0x5432, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55,
- (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }));
- objsToTest.add(new RROAttributesSubobject(new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF,
- (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }));
-
- assertEquals(objsToTest, PCEPRROSubobjectParser.parse(PCEPRROSubobjectParser.put(objsToTest)));
- }
-
- @Test
- public void testXROSubojectsSerDeserWithoutBin() throws PCEPDeserializerException {
- final List<ExcludeRouteSubobject> objsToTest = new ArrayList<ExcludeRouteSubobject>();
- objsToTest.add(new XROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(this.ipv6bytes2),
- 0x16), true, XROSubobjectAttribute.INTERFACE));
- objsToTest.add(new XROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(this.ipv4bytes1),
- 0x16), false, XROSubobjectAttribute.INTERFACE));
- objsToTest.add(new XROAsNumberSubobject(new ASNumber(0x1234), true));
- objsToTest.add(new XROUnnumberedInterfaceSubobject(new IPv4Address(this.ipv4bytes1),
- new UnnumberedInterfaceIdentifier(0xFFFFFFFFL), true, XROSubobjectAttribute.SRLG));
- objsToTest.add(new XROSRLGSubobject(new SharedRiskLinkGroup(0x12345678L), false));
-
- assertEquals(objsToTest, PCEPXROSubobjectParser.parse(PCEPXROSubobjectParser.put(objsToTest)));
- }
-
- @Test
- public void testDifferentLengthExceptions() {
- final byte[] bytes = { (byte) 0x00 }; // not empty but not enought data
- // for parsing subobjects
-
- try {
- EROAsNumberSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final PCEPDeserializerException e) {
- }
+ final byte[] ipv6bytes1 = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+ final byte[] ipv6bytes2 = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0x12,
+ (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
- try {
- EROUnnumberedInterfaceSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final PCEPDeserializerException e) {
- }
+ final byte[] ipv4bytes1 = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+ final byte[] ipv4bytes2 = { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 };
- try {
- EROIPv4PrefixSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final PCEPDeserializerException e) {
- }
+ @Test
+ public void testSerDeser() throws PCEPDeserializerException, IOException {
+ final byte[] bytesFromFile = ByteArray.fileToBytes("src/test/resources/PackOfSubobjects.bin");
+ final List<ExplicitRouteSubobject> objsToTest = PCEPEROSubobjectParser.parse(bytesFromFile);
- try {
- EROIPv6PrefixSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final PCEPDeserializerException e) {
- }
- }
+ assertEquals(8, objsToTest.size());
- @Test
- public void testNullExceptions() throws PCEPDeserializerException {
- final byte[] bytes = null; // not empty but not enought data for parsing
- // subobjects
+ assertEquals(objsToTest.get(0), new EROAsNumberSubobject(new AsNumber(0xFFFFL), true));
+ assertEquals(objsToTest.get(1), new EROAsNumberSubobject(new AsNumber(0x0010L), false));
+ assertEquals(objsToTest.get(2), new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(this.ipv4bytes1), 0x20), true));
- try {
- EROAsNumberSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final IllegalArgumentException e) {
- }
+ assertEquals(objsToTest.get(3), new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(this.ipv4bytes2), 0x15), false));
+ assertEquals(objsToTest.get(4), new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(this.ipv6bytes1), 0x80), true));
- try {
- EROUnnumberedInterfaceSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final IllegalArgumentException e) {
- }
+ assertEquals(objsToTest.get(5), new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(this.ipv6bytes2), 0x16), false));
+ final byte[] addr1 = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+ assertEquals(objsToTest.get(6),
+ new EROUnnumberedInterfaceSubobject(new IPv4Address(addr1), new UnnumberedInterfaceIdentifier(0xFFFFFFFFL), true));
- try {
- EROIPv4PrefixSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final IllegalArgumentException e) {
- }
-
- try {
- EROIPv6PrefixSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final IllegalArgumentException e) {
- }
- }
-
- @Test
- public void testUnknownInstanceExceptions() {
+ final byte[] addr2 = { (byte) 0x01, (byte) 0x24, (byte) 0x56, (byte) 0x78 };
+ assertEquals(objsToTest.get(7),
+ new EROUnnumberedInterfaceSubobject(new IPv4Address(addr2), new UnnumberedInterfaceIdentifier(0x9ABCDEF0L), false));
- final ExplicitRouteSubobject instance = new ExplicitRouteSubobject() {
- };
+ assertArrayEquals(bytesFromFile, PCEPEROSubobjectParser.put(objsToTest));
- try {
- EROAsNumberSubobjectParser.put(instance);
- fail("");
- } catch (final IllegalArgumentException e) {
}
- try {
- EROUnnumberedInterfaceSubobjectParser.put(instance);
- fail("");
- } catch (final IllegalArgumentException e) {
+ @Test
+ public void testEROSubojectsSerDeserWithoutBin() throws PCEPDeserializerException {
+ final List<ExplicitRouteSubobject> objsToTest = new ArrayList<ExplicitRouteSubobject>();
+ objsToTest.add(new EROType1LabelSubobject(0xFFFF51F2L, true, false));
+ objsToTest.add(new EROType1LabelSubobject(0x12345648L, false, true));
+ objsToTest.add(new EROGeneralizedLabelSubobject(new byte[] { (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte) 0xFF }, true, true));
+ objsToTest.add(new EROWavebandSwitchingLabelSubobject(0x12345678L, 0x87654321L, 0xFFFFFFFFL, false, false));
+ objsToTest.add(new EROProtectionType1Subobject(true, (byte) 0x05, true));
+ objsToTest.add(new EROProtectionType2Subobject(true, false, true, true, (byte) 0x06, (byte) 0x3f, true, false, (byte) 0x00, false));
+ objsToTest.add(new EROPathKeyWith32PCEIDSubobject(0x1235, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }, true));
+ objsToTest.add(new EROPathKeyWith128PCEIDSubobject(0x5432, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1,
+ (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00,
+ (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }, true));
+ objsToTest.add(new EROExplicitExclusionRouteSubobject(Arrays.asList((ExcludeRouteSubobject) new XROAsNumberSubobject(new AsNumber((long) 2588), true))));
+
+ assertEquals(objsToTest, PCEPEROSubobjectParser.parse(PCEPEROSubobjectParser.put(objsToTest)));
}
- try {
- EROIPv4PrefixSubobjectParser.put(instance);
- fail("");
- } catch (final IllegalArgumentException e) {
+ @Test
+ public void testRROSubojectsSerDeserWithoutBin() throws PCEPDeserializerException {
+ final List<ReportedRouteSubobject> objsToTest = new ArrayList<ReportedRouteSubobject>();
+ objsToTest.add(new RROIPAddressSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(this.ipv6bytes2), 0x16), true, false));
+ objsToTest.add(new RROIPAddressSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(this.ipv4bytes1), 0x16), true, false));
+ objsToTest.add(new RROType1LabelSubobject(0xFFFF51F2L, true));
+ objsToTest.add(new RROType1LabelSubobject(0x12345648L, false));
+ objsToTest.add(new RROGeneralizedLabelSubobject(new byte[] { (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte) 0xFF }, true));
+ objsToTest.add(new RROWavebandSwitchingLabelSubobject(0x12345678L, 0x87654321L, 0xFFFFFFFFL, false));
+ objsToTest.add(new RROProtectionType1Subobject(true, (byte) 0x05));
+ objsToTest.add(new RROProtectionType2Subobject(true, false, true, true, (byte) 0x06, (byte) 0x3f, true, false, (byte) 0x00));
+ objsToTest.add(new RROPathKeyWith32PCEIDSubobject(0x1235, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }));
+ objsToTest.add(new RROPathKeyWith128PCEIDSubobject(0x5432, new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1,
+ (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00,
+ (byte) 0x55, (byte) 0xFF, (byte) 0xF1 }));
+ objsToTest.add(new RROAttributesSubobject(new byte[] { (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00,
+ (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55, (byte) 0xFF, (byte) 0xF1, (byte) 0x00, (byte) 0x55,
+ (byte) 0xFF, (byte) 0xF1 }));
+
+ assertEquals(objsToTest, PCEPRROSubobjectParser.parse(PCEPRROSubobjectParser.put(objsToTest)));
}
- try {
- final byte[] ipv6addr = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
- EROIPv4PrefixSubobjectParser.put(new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(ipv6addr), 1), false));
- fail("");
- } catch (final IllegalArgumentException e) {
- }
+ @Test
+ public void testXROSubojectsSerDeserWithoutBin() throws PCEPDeserializerException {
+ final List<ExcludeRouteSubobject> objsToTest = new ArrayList<ExcludeRouteSubobject>();
+ objsToTest.add(new XROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(this.ipv6bytes2), 0x16), true, XROSubobjectAttribute.INTERFACE));
+ objsToTest.add(new XROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(this.ipv4bytes1), 0x16), false, XROSubobjectAttribute.INTERFACE));
+ objsToTest.add(new XROAsNumberSubobject(new AsNumber((long) 0x1234), true));
+ objsToTest.add(new XROUnnumberedInterfaceSubobject(new IPv4Address(this.ipv4bytes1), new UnnumberedInterfaceIdentifier(0xFFFFFFFFL), true, XROSubobjectAttribute.SRLG));
+ objsToTest.add(new XROSRLGSubobject(new SharedRiskLinkGroup(0x12345678L), false));
- try {
- EROIPv6PrefixSubobjectParser.put(instance);
- fail("");
- } catch (final IllegalArgumentException e) {
+ assertEquals(objsToTest, PCEPXROSubobjectParser.parse(PCEPXROSubobjectParser.put(objsToTest)));
}
- try {
- final byte[] ipv4addr = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
- EROIPv6PrefixSubobjectParser.put(new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(ipv4addr), 1), false));
- fail("");
- } catch (final IllegalArgumentException e) {
+ @Test
+ public void testDifferentLengthExceptions() {
+ final byte[] bytes = { (byte) 0x00 }; // not empty but not enought data
+ // for parsing subobjects
+
+ try {
+ EROAsNumberSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final PCEPDeserializerException e) {
+ }
+
+ try {
+ EROUnnumberedInterfaceSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final PCEPDeserializerException e) {
+ }
+
+ try {
+ EROIPv4PrefixSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final PCEPDeserializerException e) {
+ }
+
+ try {
+ EROIPv6PrefixSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final PCEPDeserializerException e) {
+ }
}
- }
-
- @Test
- public void testEmptyExceptions() throws PCEPDeserializerException {
- final byte[] bytes = {}; // not empty but not enought data for parsing
- // subobjects
-
- try {
- EROAsNumberSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final IllegalArgumentException e) {
+ @Test
+ public void testNullExceptions() throws PCEPDeserializerException {
+ final byte[] bytes = null; // not empty but not enought data for parsing
+ // subobjects
+
+ try {
+ EROAsNumberSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
+
+ try {
+ EROUnnumberedInterfaceSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
+
+ try {
+ EROIPv4PrefixSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
+
+ try {
+ EROIPv6PrefixSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
}
- try {
- EROUnnumberedInterfaceSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final IllegalArgumentException e) {
- }
+ @Test
+ public void testUnknownInstanceExceptions() {
+
+ final ExplicitRouteSubobject instance = new ExplicitRouteSubobject() {
+ };
+
+ try {
+ EROAsNumberSubobjectParser.put(instance);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
+
+ try {
+ EROUnnumberedInterfaceSubobjectParser.put(instance);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
+
+ try {
+ EROIPv4PrefixSubobjectParser.put(instance);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
+
+ try {
+ final byte[] ipv6addr = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
+ EROIPv4PrefixSubobjectParser.put(new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(ipv6addr), 1), false));
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
+
+ try {
+ EROIPv6PrefixSubobjectParser.put(instance);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
+
+ try {
+ final byte[] ipv4addr = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
+ EROIPv6PrefixSubobjectParser.put(new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(ipv4addr), 1), false));
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
- try {
- EROIPv4PrefixSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final IllegalArgumentException e) {
}
- try {
- EROIPv6PrefixSubobjectParser.parse(bytes, true);
- fail("");
- } catch (final IllegalArgumentException e) {
+ @Test
+ public void testEmptyExceptions() throws PCEPDeserializerException {
+ final byte[] bytes = {}; // not empty but not enought data for parsing
+ // subobjects
+
+ try {
+ EROAsNumberSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
+
+ try {
+ EROUnnumberedInterfaceSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
+
+ try {
+ EROIPv4PrefixSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
+
+ try {
+ EROIPv6PrefixSubobjectParser.parse(bytes, true);
+ fail("");
+ } catch (final IllegalArgumentException e) {
+ }
}
- }
}
import java.util.List;
import org.junit.Test;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.Bandwidth;
import org.opendaylight.protocol.concepts.IGPMetric;
import org.opendaylight.protocol.concepts.IPv4;
import org.opendaylight.protocol.pcep.tlv.LSPSymbolicNameTlv;
import org.opendaylight.protocol.pcep.tlv.PCEStatefulCapabilityTlv;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
public class PCEPValidatorTest {
private static final PCEPLspaObject lspa = new PCEPLspaObject(0L, 0L, 0L, (short) 0, (short) 0, false, false, false, false);
private final List<ExplicitRouteSubobject> eroSubobjects = asList(
- new EROAsNumberSubobject(new ASNumber(0xFFFFL), false),
+ new EROAsNumberSubobject(new AsNumber(0xFFFFL), false),
new EROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] { (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte) 0x33 }), new UnnumberedInterfaceIdentifier(0x00FF00FF), false));
private final List<ReportedRouteSubobject> rroSubobjects = asList((ReportedRouteSubobject) new RROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] {
private static final long serialVersionUID = 1L;
{
- this.add(new XROAsNumberSubobject(new ASNumber(0x12), true));
+ this.add(new XROAsNumberSubobject(new AsNumber((long) 0x12), true));
}
}, true, true, false), new ArrayList<PCEPMetricObject>() {
private static final long serialVersionUID = 1L;
public void testPCCreateMessage() throws DeserializerException, DocumentedException, PCEPDeserializerException {
final List<CompositeInstantiationObject> insts = new ArrayList<CompositeInstantiationObject>();
final List<ExplicitRouteSubobject> subs = new ArrayList<ExplicitRouteSubobject>();
- subs.add(new EROAsNumberSubobject(new ASNumber(10), false));
+ subs.add(new EROAsNumberSubobject(new AsNumber((long) 10), false));
final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
final LSPSymbolicNameTlv tlv = new LSPSymbolicNameTlv(new LSPSymbolicName(new byte[] { 5, 4 }));
tlvs.add(tlv);
import java.util.List;
import org.junit.Test;
-
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.concepts.IPv4Prefix;
import org.opendaylight.protocol.concepts.IPv6Address;
import org.opendaylight.protocol.pcep.subobject.XROSRLGSubobject;
import org.opendaylight.protocol.pcep.subobject.XROSubobjectAttribute;
import org.opendaylight.protocol.pcep.subobject.XROUnnumberedInterfaceSubobject;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
public class PCEPXROSubobjectParserTest {
assertEquals(5, objsToTest.size());
- assertEquals(
- objsToTest.get(0),
- new XROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(
- new byte[] { (byte) 192, (byte) 168, (byte) 0, (byte) 0 }), 16), true, XROSubobjectAttribute.NODE));
- assertEquals(
- objsToTest.get(1),
- new XROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(
- new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x90, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
- (byte) 0x90, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0, (byte) 0 }), 112), true,
- XROSubobjectAttribute.INTERFACE));
- assertEquals(
- objsToTest.get(2),
- new XROUnnumberedInterfaceSubobject(new IPv4Address(
- new byte[] { (byte) 0, (byte) 0, (byte) 0, (byte) 0x20 }), new UnnumberedInterfaceIdentifier(0x1234L), false,
- XROSubobjectAttribute.SRLG));
- assertEquals(objsToTest.get(3), new XROAsNumberSubobject(new ASNumber(0x1234), false));
+ assertEquals(objsToTest.get(0), new XROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 192,
+ (byte) 168, (byte) 0, (byte) 0 }), 16), true, XROSubobjectAttribute.NODE));
+ assertEquals(objsToTest.get(1), new XROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(new byte[] { (byte) 0x12,
+ (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x90, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x90,
+ (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0, (byte) 0 }), 112), true, XROSubobjectAttribute.INTERFACE));
+ assertEquals(objsToTest.get(2), new XROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] { (byte) 0, (byte) 0, (byte) 0,
+ (byte) 0x20 }), new UnnumberedInterfaceIdentifier(0x1234L), false, XROSubobjectAttribute.SRLG));
+ assertEquals(objsToTest.get(3), new XROAsNumberSubobject(new AsNumber((long) 0x1234), false));
assertEquals(objsToTest.get(4), new XROSRLGSubobject(new SharedRiskLinkGroup(0x12345678L), false));
assertArrayEquals(bytesFromFile, PCEPXROSubobjectParser.put(objsToTest));
@Test
public void testDifferentLengthExceptions() {
- final byte[] bytes = { (byte) 0x00 }; //not empty but not enought data for parsing subobjects
+ final byte[] bytes = { (byte) 0x00 }; // not empty but not enought data for parsing subobjects
try {
XROAsNumberSubobjectParser.parse(bytes, true);
@Test
public void testNullExceptions() throws PCEPDeserializerException {
- final byte[] bytes = null; //not empty but not enought data for parsing subobjects
+ final byte[] bytes = null; // not empty but not enought data for parsing subobjects
try {
XROAsNumberSubobjectParser.parse(bytes, true);
}
try {
- final byte[] ipv6addr = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
+ final byte[] ipv6addr = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
+ (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
XROIPv4PrefixSubobjectParser.put(new XROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(ipv6addr), 1), false, XROSubobjectAttribute.INTERFACE));
fail("");
} catch (final IllegalArgumentException e) {
@Test
public void testEmptyExceptions() throws PCEPDeserializerException {
- final byte[] bytes = {}; //not empty but not enought data for parsing subobjects
+ final byte[] bytes = {}; // not empty but not enought data for parsing subobjects
try {
XROAsNumberSubobjectParser.parse(bytes, true);
import org.apache.commons.codec.binary.Hex;
/**
- *
+ *
* Util class for methods working with byte array.
- *
+ *
*/
public final class ByteArray {
private ByteArray() {
}
/**
- * Returns a new byte array from given byte array, starting at start index
- * with the size of the length parameter. Byte array given as parameter
- * stays untouched.
- *
- * @param bytes
- * original byte array
- * @param startIndex
- * beginning index, inclusive
- * @param length
- * how many bytes should be in the sub-array
+ * Returns a new byte array from given byte array, starting at start index with the size of the length parameter.
+ * Byte array given as parameter stays untouched.
+ *
+ * @param bytes original byte array
+ * @param startIndex beginning index, inclusive
+ * @param length how many bytes should be in the sub-array
* @return a new byte array that is a sub-array of the original
*/
- public static byte[] subByte(final byte[] bytes, int startIndex, int length) {
- if (bytes.length == 0 || length < 0 || length > bytes.length || startIndex < 0 || startIndex > bytes.length || startIndex + length > bytes.length) {
+ public static byte[] subByte(final byte[] bytes, final int startIndex, final int length) {
+ if (bytes.length == 0 || length < 0 || length > bytes.length || startIndex < 0 || startIndex > bytes.length
+ || startIndex + length > bytes.length) {
throw new IllegalArgumentException("Cannot create subByte, invalid arguments: Length: " + length + " startIndex: " + startIndex);
}
final byte[] res = new byte[length];
}
/**
- * Converts byte array to Integer. If there are less bytes in the array as
- * required (4), the method will push adequate number of zero bytes
- * prepending given byte array.
- *
- * @param bytes
- * array to be converted to int
+ * Converts byte array to Integer. If there are less bytes in the array as required (4), the method will push
+ * adequate number of zero bytes prepending given byte array.
+ *
+ * @param bytes array to be converted to int
* @return int
*/
- public static int bytesToInt(byte[] bytes) {
+ public static int bytesToInt(final byte[] bytes) {
if (bytes.length > Integer.SIZE / 8) {
throw new IllegalArgumentException("Cannot convert bytes to integer. Byte array too big.");
}
}
/**
- * Converts byte array to long. If there are less bytes in the array as
- * required (Long.Size), the method will push adequate number of zero bytes
- * prepending given byte array.
- *
- * @param bytes
- * array to be converted to long
+ * Converts byte array to long. If there are less bytes in the array as required (Long.Size), the method will push
+ * adequate number of zero bytes prepending given byte array.
+ *
+ * @param bytes array to be converted to long
* @return long
*/
- public static long bytesToLong(byte[] bytes) {
+ public static long bytesToLong(final byte[] bytes) {
if (bytes.length > Long.SIZE / 8) {
throw new IllegalArgumentException("Cannot convert bytes to long.Byte array too big.");
}
}
/**
- * Converts byte array to float IEEE 754 format. If there are less bytes in
- * the array as required (Float.Size), the method will push adequate number
- * of zero bytes prepending given byte array.
- *
- * @param bytes
- * array to be converted to float
+ * Converts byte array to float IEEE 754 format. If there are less bytes in the array as required (Float.Size), the
+ * method will push adequate number of zero bytes prepending given byte array.
+ *
+ * @param bytes array to be converted to float
* @return float
*/
- public static float bytesToFloat(byte[] bytes) {
+ public static float bytesToFloat(final byte[] bytes) {
if (bytes.length > Float.SIZE / 8) {
throw new IllegalArgumentException("Cannot convert bytes to float.Byte array too big.");
}
/**
* Cuts 'count' number of bytes from the beginning of given byte array.
- *
- * @param bytes
- * array to be cut, cannot be null
- * @param count
- * how many bytes needed to be cut, needs to be > 0
+ *
+ * @param bytes array to be cut, cannot be null
+ * @param count how many bytes needed to be cut, needs to be > 0
* @return bytes array without first 'count' bytes
*/
- public static byte[] cutBytes(byte[] bytes, int count) {
+ public static byte[] cutBytes(final byte[] bytes, final int count) {
if (bytes.length == 0 || count > bytes.length || count <= 0) {
throw new IllegalArgumentException("Cannot cut bytes, invalid arguments: Count: " + count + " bytes.length: " + bytes.length);
}
/**
* Parse byte to bits, from the leftmost bit.
- *
- * @param b
- * byte to be parsed
+ *
+ * @param b byte to be parsed
* @return array of booleans with size of 8
*/
- public static boolean[] parseBits(byte b) {
+ public static boolean[] parseBits(final byte b) {
final boolean[] bits = new boolean[Byte.SIZE];
int j = 0;
for (int i = Byte.SIZE - 1; i >= 0; i--) {
/**
* Parses array of bytes to BitSet, from left most bit.
- *
- * @param bytes
- * array of bytes to be parsed
+ *
+ * @param bytes array of bytes to be parsed
* @return BitSet with length = bytes.length * Byte.SIZE
*/
- public static BitSet bytesToBitSet(byte[] bytes) {
+ public static BitSet bytesToBitSet(final byte[] bytes) {
final BitSet bitSet = new BitSet(bytes.length * Byte.SIZE);
for (int bytes_iter = 0; bytes_iter < bytes.length; bytes_iter++) {
final int offset = bytes_iter * Byte.SIZE;
/**
* Parses BitSet to bytes, from most left bit.
- *
- * @param bitSet
- * BitSet to be parsed
- * @param returnedLength
- * Length of returned array. Overlapping flags are truncated.
+ *
+ * @param bitSet BitSet to be parsed
+ * @param returnedLength Length of returned array. Overlapping flags are truncated.
* @return parsed array of bytes with length of bitSet.length / Byte.SIZE
*/
- public static byte[] bitSetToBytes(BitSet bitSet, int returnedLength) {
+ public static byte[] bitSetToBytes(final BitSet bitSet, final int returnedLength) {
final byte[] bytes = new byte[returnedLength];
for (int bytes_iter = 0; bytes_iter < bytes.length; bytes_iter++) {
/**
* Parses file to array of bytes
- *
- * @param name
- * path to file to by parsed
+ *
+ * @param name path to file to by parsed
* @return parsed array of bytes
*/
- public static byte[] fileToBytes(String name) throws IOException {
+ public static byte[] fileToBytes(final String name) throws IOException {
final File file = new File(name);
int offset = 0;
int numRead = 0;
/**
* Parses integer to array of bytes
- *
- * @param num
- * integer to be parsed
+ *
+ * @param num integer to be parsed
* @return parsed array of bytes with length of Integer.SIZE/Byte.SIZE
*/
- public static byte[] intToBytes(int num) {
+ public static byte[] intToBytes(final int num) {
final ByteBuffer bytesBuffer = ByteBuffer.allocate(Integer.SIZE / Byte.SIZE);
bytesBuffer.putInt(num);
}
/**
- * Parses integer to array of bytes
- *
- * @param num
- * integer to be parsed
+ * Parses long to array of bytes
+ *
+ * @param num long to be parsed
* @return parsed array of bytes with length of Long.SIZE/Byte.SIZE
*/
- public static byte[] longToBytes(long num) {
+ public static byte[] longToBytes(final long num) {
final ByteBuffer bytesBuffer = ByteBuffer.allocate(Long.SIZE / Byte.SIZE);
bytesBuffer.putLong(num);
/**
* Copies range of bits from passed byte and align to right.<br/>
- *
- * @param src
- * source byte to copy from
- * @param fromBit
- * bit from which will copy (inclusive) - numbered from 0
- * @param length
- * of bits to by copied - <1,8>
+ *
+ * @param src source byte to copy from
+ * @param fromBit bit from which will copy (inclusive) - numbered from 0
+ * @param length of bits to by copied - <1,8>
* @return copied value aligned to right
*/
- public static byte copyBitsRange(byte src, int fromBit, int length) {
+ public static byte copyBitsRange(final byte src, final int fromBit, final int length) {
if (fromBit < 0 | fromBit > Byte.SIZE - 1 | length < 1 | length > Byte.SIZE) {
throw new IllegalArgumentException("fromBit or toBit is out of range.");
}
/**
* Copies whole source byte array to destination from offset.<br/>
* Length of src can't be bigger than dest length minus offset
- *
- * @param src
- * byte[]
- * @param dest
- * byte[]
- * @param offset
- * int
+ *
+ * @param src byte[]
+ * @param dest byte[]
+ * @param offset int
*/
- public static void copyWhole(byte[] src, byte[] dest, int offset) {
+ public static void copyWhole(final byte[] src, final byte[] dest, final int offset) {
if (dest.length - offset < src.length) {
throw new ArrayIndexOutOfBoundsException("Can't copy whole array.");
}
/**
* Convert array of bytes to java short.<br/>
* Size can't be bigger than size of short in bytes.
- *
- * @param bytes
- * byte[]
+ *
+ * @param bytes byte[]
* @return array of bytes
*/
- public static short bytesToShort(byte[] bytes) {
+ public static short bytesToShort(final byte[] bytes) {
if (bytes.length > Short.SIZE / Byte.SIZE) {
throw new IllegalArgumentException("Cannot convert bytes to short. Byte array too big.");
}
/**
* Convert short java representation to array of bytes.
- *
- * @param num
- * short
+ *
+ * @param num short
* @return short represented as array of bytes
*/
- public static byte[] shortToBytes(short num) {
+ public static byte[] shortToBytes(final short num) {
final ByteBuffer bytesBuffer = ByteBuffer.allocate(Short.SIZE / Byte.SIZE);
bytesBuffer.putShort(num);
/**
* Convert float java representation to array of bytes.
- *
- * @param num
- * float
+ *
+ * @param num float
* @return float represented as array of bytes
*/
- public static byte[] floatToBytes(float num) {
+ public static byte[] floatToBytes(final float num) {
final ByteBuffer bytesBuffer = ByteBuffer.allocate(Float.SIZE / Byte.SIZE);
bytesBuffer.putFloat(num);
}
/**
- * Pretty print array of bytes as hex encoded string with 16 bytes per line.
- * Each byte is separated by space, after first 8 bytes there are 2 spaces
- * instead of one.
+ * Pretty print array of bytes as hex encoded string with 16 bytes per line. Each byte is separated by space, after
+ * first 8 bytes there are 2 spaces instead of one.
*/
- public static String bytesToHexString(byte[] array) {
+ public static String bytesToHexString(final byte[] array) {
return bytesToHexString(array, 16, " ", 8, " ");
}
/**
- * Pretty-print an array of bytes as hex-encoded string. Separate them
- * with specified separator.
+ * Pretty-print an array of bytes as hex-encoded string. Separate them with specified separator.
*/
public static String toHexString(final byte[] array, final String separator) {
final StringBuilder sb = new StringBuilder();
/**
* Convert array of bytes to hexadecimal String.
- *
+ *
* @param array
- * @param bytesOnLine
- * number of bytes that should by displayed in one line
- * @param byteSeparator
- * string that will be placed after each byte
- * @param wordCount
- * number of bytes that make a 'word' (group of bytes)
- * @param wordSeparator
- * string that will be placed after each word
+ * @param bytesOnLine number of bytes that should by displayed in one line
+ * @param byteSeparator string that will be placed after each byte
+ * @param wordCount number of bytes that make a 'word' (group of bytes)
+ * @param wordSeparator string that will be placed after each word
* @return Hexadecimal string representation of given byte array
*/
- public static String bytesToHexString(byte[] array, int bytesOnLine, String byteSeparator, int wordCount, String wordSeparator) {
+ public static String bytesToHexString(final byte[] array, final int bytesOnLine, final String byteSeparator, final int wordCount,
+ final String wordSeparator) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < array.length; i++) {
sb.append(Hex.encodeHexString(new byte[] { array[i] }));
}
/**
- * Decodes bytes to human readable UTF-8 string. If bytes are not valid
- * UTF-8, they are represented as raw binary.
- *
- * @param bytes
- * bytes to be decoded to string
+ * Decodes bytes to human readable UTF-8 string. If bytes are not valid UTF-8, they are represented as raw binary.
+ *
+ * @param bytes bytes to be decoded to string
* @return String representation of passed bytes
*/
- public static String bytesToHRString(byte[] bytes) {
+ public static String bytesToHRString(final byte[] bytes) {
try {
return Charset.forName("UTF-8").newDecoder().decode(ByteBuffer.wrap(bytes)).toString();
} catch (final CharacterCodingException e) {
}
/**
- * Searches for byte sequence in given array. Returns the index of first occurrence of
- * this sequence (where it starts).
+ * Searches for byte sequence in given array. Returns the index of first occurrence of this sequence (where it
+ * starts).
+ *
* @param bytes byte array where to search for sequence
* @param sequence to be searched in given byte array
- * @return -1 if the sequence could not be found in given byte array
- * int index of first occurrence of the sequence in bytes
+ * @return -1 if the sequence could not be found in given byte array int index of first occurrence of the sequence
+ * in bytes
*/
- public static int findByteSequence(byte[] bytes, byte[] sequence) {
+ public static int findByteSequence(final byte[] bytes, final byte[] sequence) {
if (bytes.length < sequence.length)
throw new IllegalArgumentException("Sequence to be found is longer than the given byte array.");
if (bytes.length == sequence.length)
}
private static final byte maskBits[] = new byte[] { 0, -128, -64, -32, -16, -8, -4, -2 };
- public static final byte[] maskBytes(final byte[] original,
- final int bits) {
+
+ public static final byte[] maskBytes(final byte[] original, final int bits) {
if (original.length * 8 < bits)
throw new IllegalArgumentException("Attempted to apply invalid mask (too long)");
- final int needbytes = (bits +7) / 8;
+ final int needbytes = (bits + 7) / 8;
// We need to have a new copy of the underlying byte array, so that
// the original bytes stay untouched
final byte[] bytes = Arrays.copyOf(original, original.length);
final int needmask = bits % 8;
if (needmask != 0)
- bytes[needbytes-1] &= maskBits[needmask];
+ bytes[needbytes - 1] &= maskBits[needmask];
- // zero-out the rest of the bytes
- for (int i = needbytes ; i < bytes.length; i++) {
+ // zero-out the rest of the bytes
+ for (int i = needbytes; i < bytes.length; i++) {
bytes[i] = 0;
}
return bytes;