From 8f92448e4f2f5d9c98036097bdabd1c40166908a Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Sat, 7 Nov 2015 09:43:53 -0800 Subject: Updated ONOS sources to commit ID 3f28c6803193d493b636dd3c43e08a3e6b35acca Change-Id: I08d1eb7ee31b38491b046933c502894d133b2a2d Signed-off-by: Ashlee Young --- .../bgpio/types/attr/BgpPrefixAttrIGPFlags.java | 180 ------------ .../bgpio/types/attr/BgpPrefixAttrIgpFlags.java | 198 +++++++++++++ .../test/java/org/onosproject/bgp/AreaIdTest.java | 40 --- .../test/java/org/onosproject/bgp/As4PathTest.java | 56 ---- .../test/java/org/onosproject/bgp/AsPathTest.java | 56 ---- .../org/onosproject/bgp/AutonomousSystemTest.java | 40 --- .../org/onosproject/bgp/BGPKeepaliveMsgTest.java | 70 ----- .../org/onosproject/bgp/BGPLSIdentifierTest.java | 40 --- .../java/org/onosproject/bgp/BGPOpenMsgTest.java | 318 --------------------- .../onosproject/bgp/BgpAttrNodeFlagBitTlvTest.java | 51 ---- .../org/onosproject/bgp/BgpAttrRouterIdV6Test.java | 50 ---- .../onosproject/bgp/BgpLinkAttrIgpMetricTest.java | 44 --- .../bgp/BgpLinkAttrMplsProtocolMaskTest.java | 43 --- .../bgp/BgpLinkAttrProtectionTypeTest.java | 57 ---- .../onosproject/bgp/BgpNotificationMsgTest.java | 228 --------------- .../onosproject/bgp/BgpPrefixAttrMetricTest.java | 40 --- .../bgp/BgpPrefixAttrOspfFwdAddrTest.java | 52 ---- .../bgp/IPReachabilityInformationTest.java | 41 --- .../java/org/onosproject/bgp/IPv4AddressTest.java | 41 --- .../java/org/onosproject/bgp/IPv6AddressTest.java | 41 --- .../org/onosproject/bgp/IsIsNonPseudonodeTest.java | 40 --- .../org/onosproject/bgp/IsIsPseudonodeTest.java | 40 --- .../bgp/LinkLocalRemoteIdentifiersTest.java | 40 --- .../test/java/org/onosproject/bgp/NextHopTest.java | 41 --- .../test/java/org/onosproject/bgp/OriginTest.java | 40 --- .../org/onosproject/bgp/OspfNonPseudonodeTest.java | 40 --- .../org/onosproject/bgp/OspfPseudonodeTest.java | 43 --- .../org/onosproject/bgp/OspfRouteTypeTest.java | 40 --- .../bgpio/protocol/BGPKeepaliveMsgTest.java | 66 +++++ .../onosproject/bgpio/protocol/BGPOpenMsgTest.java | 314 ++++++++++++++++++++ .../bgpio/protocol/BgpNotificationMsgTest.java | 224 +++++++++++++++ .../org/onosproject/bgpio/types/AreaIdTest.java | 77 +++++ .../org/onosproject/bgpio/types/As4PathTest.java | 55 ++++ .../org/onosproject/bgpio/types/AsPathTest.java | 55 ++++ .../bgpio/types/AutonomousSystemTest.java | 39 +++ .../bgpio/types/BGPLSIdentifierTest.java | 39 +++ .../bgpio/types/IPReachabilityInformationTest.java | 40 +++ .../onosproject/bgpio/types/IPv4AddressTest.java | 40 +++ .../onosproject/bgpio/types/IPv6AddressTest.java | 40 +++ .../bgpio/types/IsIsPseudonodeTest.java | 39 +++ .../types/LinkLocalRemoteIdentifiersTest.java | 39 +++ .../org/onosproject/bgpio/types/NextHopTest.java | 40 +++ .../org/onosproject/bgpio/types/OriginTest.java | 39 +++ .../bgpio/types/OspfPseudonodeTest.java | 42 +++ .../onosproject/bgpio/types/OspfRouteTypeTest.java | 39 +++ .../types/attr/BgpAttrNodeFlagBitTlvTest.java | 50 ++++ .../bgpio/types/attr/BgpAttrRouterIdV6Test.java | 49 ++++ .../bgpio/types/attr/BgpLinkAttrIgpMetricTest.java | 43 +++ .../attr/BgpLinkAttrMplsProtocolMaskTest.java | 42 +++ .../types/attr/BgpLinkAttrProtectionTypeTest.java | 56 ++++ .../types/attr/BgpPrefixAttrIgpFlagsTest.java | 53 ++++ .../bgpio/types/attr/BgpPrefixAttrMetricTest.java | 39 +++ .../types/attr/BgpPrefixAttrOspfFwdAddrTest.java | 51 ++++ 53 files changed, 1808 insertions(+), 1812 deletions(-) delete mode 100755 framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIGPFlags.java create mode 100755 framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AreaIdTest.java delete mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/As4PathTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AsPathTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AutonomousSystemTest.java delete mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPKeepaliveMsgTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPLSIdentifierTest.java delete mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPOpenMsgTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpAttrNodeFlagBitTlvTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpAttrRouterIdV6Test.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrIgpMetricTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrMplsProtocolMaskTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrProtectionTypeTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpNotificationMsgTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrMetricTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrOspfFwdAddrTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPReachabilityInformationTest.java delete mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv4AddressTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv6AddressTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsNonPseudonodeTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsPseudonodeTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/LinkLocalRemoteIdentifiersTest.java delete mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/NextHopTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OriginTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfNonPseudonodeTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfPseudonodeTest.java delete mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfRouteTypeTest.java create mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BGPKeepaliveMsgTest.java create mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BGPOpenMsgTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpNotificationMsgTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AreaIdTest.java create mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/As4PathTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AsPathTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AutonomousSystemTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BGPLSIdentifierTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPReachabilityInformationTest.java create mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv4AddressTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv6AddressTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsPseudonodeTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTest.java create mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/NextHopTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OriginTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfPseudonodeTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfRouteTypeTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlvTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6Test.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetricTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMaskTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionTypeTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlagsTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetricTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddrTest.java (limited to 'framework/src/onos/bgp/bgpio/src') diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIGPFlags.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIGPFlags.java deleted file mode 100755 index 035d706c..00000000 --- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIGPFlags.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgpio.types.attr; - -import java.util.Objects; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.onosproject.bgpio.exceptions.BGPParseException; -import org.onosproject.bgpio.types.BGPErrorType; -import org.onosproject.bgpio.types.BGPValueType; -import org.onosproject.bgpio.util.Validation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.MoreObjects; - -/** - * Implements BGP prefix IGP Flag attribute. - */ -public class BgpPrefixAttrIGPFlags implements BGPValueType { - - protected static final Logger log = LoggerFactory - .getLogger(BgpPrefixAttrIGPFlags.class); - - public static final int ATTR_PREFIX_FLAGBIT = 1152; - public static final int ATTR_PREFIX_FLAG_LEN = 1; - - public static final int FIRST_BIT = 0x80; - public static final int SECOND_BIT = 0x40; - public static final int THIRD_BIT = 0x20; - public static final int FOURTH_BIT = 0x01; - - /* Prefix IGP flag bit TLV */ - private boolean bisisUpDownBit = false; - private boolean bOspfNoUnicastBit = false; - private boolean bOspfLclAddrBit = false; - private boolean bOspfNSSABit = false; - - /** - * Constructor to initialize the value. - * - * @param bisisUpDownBit IS-IS Up/Down Bit - * @param bOspfNoUnicastBit OSPF no unicast Bit - * @param bOspfLclAddrBit OSPF local address Bit - * @param bOspfNSSABit OSPF propagate NSSA Bit - */ - BgpPrefixAttrIGPFlags(boolean bisisUpDownBit, boolean bOspfNoUnicastBit, - boolean bOspfLclAddrBit, boolean bOspfNSSABit) { - this.bisisUpDownBit = bisisUpDownBit; - this.bOspfNoUnicastBit = bOspfNoUnicastBit; - this.bOspfLclAddrBit = bOspfLclAddrBit; - this.bOspfNSSABit = bOspfNSSABit; - } - - /** - * Reads the IGP Flags. - * - * @param cb ChannelBuffer - * @return object of BgpPrefixAttrIGPFlags - * @throws BGPParseException while parsing BgpPrefixAttrIGPFlags - */ - public static BgpPrefixAttrIGPFlags read(ChannelBuffer cb) - throws BGPParseException { - boolean bisisUpDownBit = false; - boolean bOspfNoUnicastBit = false; - boolean bOspfLclAddrBit = false; - boolean bOspfNSSABit = false; - - short lsAttrLength = cb.readShort(); - - if ((lsAttrLength != ATTR_PREFIX_FLAG_LEN) - || (cb.readableBytes() < lsAttrLength)) { - Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR, - BGPErrorType.ATTRIBUTE_LENGTH_ERROR, - lsAttrLength); - } - - byte nodeFlagBits = cb.readByte(); - - bisisUpDownBit = ((nodeFlagBits & (byte) FIRST_BIT) == FIRST_BIT); - bOspfNoUnicastBit = ((nodeFlagBits & (byte) SECOND_BIT) == SECOND_BIT); - bOspfLclAddrBit = ((nodeFlagBits & (byte) THIRD_BIT) == THIRD_BIT); - bOspfNSSABit = ((nodeFlagBits & (byte) FOURTH_BIT) == FOURTH_BIT); - - return new BgpPrefixAttrIGPFlags(bisisUpDownBit, bOspfNoUnicastBit, - bOspfLclAddrBit, bOspfNSSABit); - } - - /** - * Returns the IS-IS Up/Down Bit set or not. - * - * @return IS-IS Up/Down Bit set or not - */ - boolean getisisUpDownBit() { - return bisisUpDownBit; - } - - /** - * Returns the OSPF no unicast Bit set or not. - * - * @return OSPF no unicast Bit set or not - */ - boolean getOspfNoUnicastBit() { - return bOspfNoUnicastBit; - } - - /** - * Returns the OSPF local address Bit set or not. - * - * @return OSPF local address Bit set or not - */ - boolean getOspfLclAddrBit() { - return bOspfLclAddrBit; - } - - /** - * Returns the OSPF propagate NSSA Bit set or not. - * - * @return OSPF propagate NSSA Bit set or not - */ - boolean getOspfNSSABit() { - return bOspfNSSABit; - } - - @Override - public short getType() { - return ATTR_PREFIX_FLAGBIT; - } - - @Override - public int write(ChannelBuffer cb) { - // TODO This will be implemented in the next version - return 0; - } - - @Override - public int hashCode() { - return Objects.hash(bisisUpDownBit, bOspfNoUnicastBit, bOspfLclAddrBit, - bOspfNSSABit); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj instanceof BgpPrefixAttrIGPFlags) { - BgpPrefixAttrIGPFlags other = (BgpPrefixAttrIGPFlags) obj; - return Objects.equals(bisisUpDownBit, other.bisisUpDownBit) - && Objects.equals(bOspfNoUnicastBit, - other.bOspfNoUnicastBit) - && Objects.equals(bOspfLclAddrBit, other.bOspfLclAddrBit) - && Objects.equals(bOspfNSSABit, other.bOspfNSSABit); - } - return false; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(getClass()) - .add("bisisUpDownBit", bisisUpDownBit) - .add("bOspfNoUnicastBit", bOspfNoUnicastBit) - .add("bOspfLclAddrBit", bOspfLclAddrBit) - .add("bOspfNSSABit", bOspfNSSABit).toString(); - } -} diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java new file mode 100755 index 00000000..a215e6f1 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlags.java @@ -0,0 +1,198 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types.attr; + +import java.util.Objects; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onosproject.bgpio.exceptions.BGPParseException; +import org.onosproject.bgpio.types.BGPErrorType; +import org.onosproject.bgpio.types.BGPValueType; +import org.onosproject.bgpio.util.Validation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Implements BGP prefix IGP Flag attribute. + */ +public final class BgpPrefixAttrIgpFlags implements BGPValueType { + + protected static final Logger log = LoggerFactory + .getLogger(BgpPrefixAttrIgpFlags.class); + + public static final int ATTR_PREFIX_FLAGBIT = 1152; + public static final int ATTR_PREFIX_FLAG_LEN = 1; + + public static final byte FIRST_BIT = (byte) 0x80; + public static final byte SECOND_BIT = 0x40; + public static final byte THIRD_BIT = 0x20; + public static final byte FOURTH_BIT = 0x01; + + /* Prefix IGP flag bit TLV */ + private final boolean bisisUpDownBit; + private final boolean bOspfNoUnicastBit; + private final boolean bOspfLclAddrBit; + private final boolean bOspfNSSABit; + + /** + * Constructor to initialize the value. + * + * @param bisisUpDownBit IS-IS Up/Down Bit + * @param bOspfNoUnicastBit OSPF no unicast Bit + * @param bOspfLclAddrBit OSPF local address Bit + * @param bOspfNSSABit OSPF propagate NSSA Bit + */ + BgpPrefixAttrIgpFlags(boolean bisisUpDownBit, + boolean bOspfNoUnicastBit, + boolean bOspfLclAddrBit, boolean bOspfNSSABit) { + this.bisisUpDownBit = bisisUpDownBit; + this.bOspfNoUnicastBit = bOspfNoUnicastBit; + this.bOspfLclAddrBit = bOspfLclAddrBit; + this.bOspfNSSABit = bOspfNSSABit; + } + + /** + * Returns object of this class with specified values. + * + * @param bisisUpDownBit IS-IS Up/Down Bit + * @param bOspfNoUnicastBit OSPF no unicast Bit + * @param bOspfLclAddrBit OSPF local address Bit + * @param bOspfNSSABit OSPF propagate NSSA Bit + * @return object of BgpPrefixAttrIGPFlags + */ + public static BgpPrefixAttrIgpFlags of(final boolean bisisUpDownBit, + final boolean bOspfNoUnicastBit, + final boolean bOspfLclAddrBit, + final boolean bOspfNSSABit) { + return new BgpPrefixAttrIgpFlags(bisisUpDownBit, bOspfNoUnicastBit, + bOspfLclAddrBit, bOspfNSSABit); + } + + /** + * Reads the IGP Flags. + * + * @param cb ChannelBuffer + * @return object of BgpPrefixAttrIGPFlags + * @throws BGPParseException while parsing BgpPrefixAttrIGPFlags + */ + public static BgpPrefixAttrIgpFlags read(ChannelBuffer cb) + throws BGPParseException { + boolean bisisUpDownBit = false; + boolean bOspfNoUnicastBit = false; + boolean bOspfLclAddrBit = false; + boolean bOspfNSSABit = false; + + short lsAttrLength = cb.readShort(); + + if ((lsAttrLength != ATTR_PREFIX_FLAG_LEN) + || (cb.readableBytes() < lsAttrLength)) { + Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR, + BGPErrorType.ATTRIBUTE_LENGTH_ERROR, + lsAttrLength); + } + + byte nodeFlagBits = cb.readByte(); + + bisisUpDownBit = ((nodeFlagBits & FIRST_BIT) == FIRST_BIT); + bOspfNoUnicastBit = ((nodeFlagBits & SECOND_BIT) == SECOND_BIT); + bOspfLclAddrBit = ((nodeFlagBits & THIRD_BIT) == THIRD_BIT); + bOspfNSSABit = ((nodeFlagBits & FOURTH_BIT) == FOURTH_BIT); + + return BgpPrefixAttrIgpFlags.of(bisisUpDownBit, bOspfNoUnicastBit, + bOspfLclAddrBit, bOspfNSSABit); + } + + /** + * Returns the IS-IS Up/Down Bit set or not. + * + * @return IS-IS Up/Down Bit set or not + */ + public boolean isisUpDownBit() { + return bisisUpDownBit; + } + + /** + * Returns the OSPF no unicast Bit set or not. + * + * @return OSPF no unicast Bit set or not + */ + public boolean ospfNoUnicastBit() { + return bOspfNoUnicastBit; + } + + /** + * Returns the OSPF local address Bit set or not. + * + * @return OSPF local address Bit set or not + */ + public boolean ospfLclAddrBit() { + return bOspfLclAddrBit; + } + + /** + * Returns the OSPF propagate NSSA Bit set or not. + * + * @return OSPF propagate NSSA Bit set or not + */ + public boolean ospfNSSABit() { + return bOspfNSSABit; + } + + @Override + public short getType() { + return ATTR_PREFIX_FLAGBIT; + } + + @Override + public int write(ChannelBuffer cb) { + // TODO This will be implemented in the next version + return 0; + } + + @Override + public int hashCode() { + return Objects.hash(bisisUpDownBit, bOspfNoUnicastBit, bOspfLclAddrBit, + bOspfNSSABit); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof BgpPrefixAttrIgpFlags) { + BgpPrefixAttrIgpFlags other = (BgpPrefixAttrIgpFlags) obj; + return Objects.equals(bisisUpDownBit, other.bisisUpDownBit) + && Objects.equals(bOspfNoUnicastBit, + other.bOspfNoUnicastBit) + && Objects.equals(bOspfLclAddrBit, other.bOspfLclAddrBit) + && Objects.equals(bOspfNSSABit, other.bOspfNSSABit); + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("bisisUpDownBit", bisisUpDownBit) + .add("bOspfNoUnicastBit", bOspfNoUnicastBit) + .add("bOspfLclAddrBit", bOspfLclAddrBit) + .add("bOspfNSSABit", bOspfNSSABit).toString(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AreaIdTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AreaIdTest.java deleted file mode 100644 index 3e7c654e..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AreaIdTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.bgpio.types.AreaIDTlv; - -/** - * Test for AreaID Tlv. - */ -public class AreaIdTest { - private final int value1 = 10; - private final int value2 = 20; - private final AreaIDTlv tlv1 = AreaIDTlv.of(value1); - private final AreaIDTlv sameAsTlv1 = AreaIDTlv.of(value1); - private final AreaIDTlv tlv2 = AreaIDTlv.of(value2); - - @Test - public void testEquality() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/As4PathTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/As4PathTest.java deleted file mode 100755 index 96d05bf3..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/As4PathTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; -import org.onosproject.bgpio.types.As4Path; - -import com.google.common.testing.EqualsTester; - -/** - * Test for As4Path BGP Path Attribute. - */ -public class As4PathTest { - //Two scenarios as4path set and sequence - private final List as4pathSet1 = new ArrayList<>(); - private final List as4pathSeq1 = new ArrayList<>(); - private final List as4pathSet2 = new ArrayList<>(); - private final List as4pathSeq2 = new ArrayList<>(); - private final As4Path attr1 = new As4Path(as4pathSet1, null); - private final As4Path sameAsAttr1 = new As4Path(as4pathSet1, null); - private final As4Path attr2 = new As4Path(as4pathSet2, null); - private final As4Path attr3 = new As4Path(null, as4pathSeq1); - private final As4Path sameAsAttr3 = new As4Path(null, as4pathSeq1); - private final As4Path attr4 = new As4Path(null, as4pathSeq2); - - @Test - public void basics() { - as4pathSet1.add(197358); - as4pathSet1.add(12883); - as4pathSet2.add(2008989); - as4pathSeq1.add(3009009); - as4pathSeq2.add(409900); - new EqualsTester() - .addEqualityGroup(attr1, sameAsAttr1) - .addEqualityGroup(attr2) - .addEqualityGroup(attr3, sameAsAttr3) - .addEqualityGroup(attr4) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AsPathTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AsPathTest.java deleted file mode 100644 index 792164ea..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AsPathTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; -import org.onosproject.bgpio.types.AsPath; - -import com.google.common.testing.EqualsTester; - -/** - * Test for AsPath BGP Path Attribute. - */ -public class AsPathTest { - //Two scenarios aspath set and sequence - private final List aspathSet1 = new ArrayList<>(); - private final List aspathSet2 = new ArrayList<>(); - private final List aspathSeq1 = new ArrayList<>(); - private final List aspathSeq2 = new ArrayList<>(); - private final AsPath attr1 = new AsPath(aspathSet1, null); - private final AsPath sameAsAttr1 = new AsPath(aspathSet1, null); - private final AsPath attr2 = new AsPath(aspathSet2, null); - private final AsPath attr3 = new AsPath(null, aspathSeq1); - private final AsPath sameAsAttr3 = new AsPath(null, aspathSeq1); - private final AsPath attr4 = new AsPath(null, aspathSeq2); - - @Test - public void basics() { - aspathSet1.add((short) 100); - aspathSet1.add((short) 300); - aspathSet2.add((short) 200); - aspathSeq2.add((short) 400); - aspathSeq1.add((short) 300); - new EqualsTester() - .addEqualityGroup(attr1, sameAsAttr1) - .addEqualityGroup(attr2) - .addEqualityGroup(attr3, sameAsAttr3) - .addEqualityGroup(attr4) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AutonomousSystemTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AutonomousSystemTest.java deleted file mode 100644 index c41408de..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AutonomousSystemTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.bgpio.types.AutonomousSystemTlv; - -/** - * Test for AutonomousSystem Tlv. - */ -public class AutonomousSystemTest { - private final int value1 = 101; - private final int value2 = 201; - private final AutonomousSystemTlv tlv1 = AutonomousSystemTlv.of(value1); - private final AutonomousSystemTlv sameAsTlv1 = AutonomousSystemTlv.of(value1); - private final AutonomousSystemTlv tlv2 = AutonomousSystemTlv.of(value2); - - @Test - public void testEquality() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPKeepaliveMsgTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPKeepaliveMsgTest.java deleted file mode 100755 index 57ab9d90..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPKeepaliveMsgTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.core.Is.is; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Test; -import org.onosproject.bgpio.exceptions.BGPParseException; -import org.onosproject.bgpio.protocol.BGPFactories; -import org.onosproject.bgpio.protocol.BGPKeepaliveMsg; -import org.onosproject.bgpio.protocol.BGPMessage; -import org.onosproject.bgpio.protocol.BGPMessageReader; -import org.onosproject.bgpio.types.BGPHeader; - -/** - * Test case for BGP KEEPALIVE Message. - */ -public class BGPKeepaliveMsgTest { - - /** - * This test case checks BGP Keepalive message. - */ - @Test - public void keepaliveMessageTest1() throws BGPParseException { - - // BGP KEEPALIVE Message - byte[] keepaliveMsg = new byte[] {(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, - 0x00, 0x13, 0x04}; - - byte[] testKeepaliveMsg; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(keepaliveMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message; - BGPHeader bgpHeader = new BGPHeader(); - - message = reader.readFrom(buffer, bgpHeader); - - assertThat(message, instanceOf(BGPKeepaliveMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testKeepaliveMsg = new byte[readLen]; - buf.readBytes(testKeepaliveMsg, 0, readLen); - - assertThat(testKeepaliveMsg, is(keepaliveMsg)); - } -} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPLSIdentifierTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPLSIdentifierTest.java deleted file mode 100644 index 5f357815..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPLSIdentifierTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.BGPLSIdentifierTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test for BGPLSIdentifier Tlv. - */ -public class BGPLSIdentifierTest { - private final int value1 = 8738; - private final int value2 = 13107; - private final BGPLSIdentifierTlv tlv1 = BGPLSIdentifierTlv.of(value1); - private final BGPLSIdentifierTlv sameAsTlv1 = new BGPLSIdentifierTlv(value1); - private final BGPLSIdentifierTlv tlv2 = new BGPLSIdentifierTlv(value2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPOpenMsgTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPOpenMsgTest.java deleted file mode 100755 index d010857e..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPOpenMsgTest.java +++ /dev/null @@ -1,318 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.core.Is.is; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Test; -import org.onosproject.bgpio.exceptions.BGPParseException; -import org.onosproject.bgpio.protocol.BGPFactories; -import org.onosproject.bgpio.protocol.BGPMessage; -import org.onosproject.bgpio.protocol.BGPMessageReader; -import org.onosproject.bgpio.protocol.BGPOpenMsg; -import org.onosproject.bgpio.types.BGPHeader; - -/** - * Test cases for BGP Open Message. - */ -public class BGPOpenMsgTest { - - /** - * This test case checks open message without optional parameter. - */ - @Test - public void openMessageTest1() throws BGPParseException { - //Open message without optional parameter - byte[] openMsg = new byte[] {(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, - 0x00, 0x1d, 0x01, 0X04, (byte) 0xfe, 0x09, 0x00, - (byte) 0xb4, (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, - 0x00}; - - byte[] testOpenMsg; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message; - BGPHeader bgpHeader = new BGPHeader(); - message = reader.readFrom(buffer, bgpHeader); - - assertThat(message, instanceOf(BGPOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - } - - /** - * This test case checks open message with Multiprotocol extension - * capability. - */ - @Test - public void openMessageTest2() throws BGPParseException { - - // OPEN Message (MultiProtocolExtension-CAPABILITY). - byte[] openMsg = new byte[] {(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, 0x00, 0x25, - 0x01, //BGP Header - 0X04, //Version - (byte) 0x00, (byte) 0xc8, // AS Number - 0x00, (byte) 0xb4, // Hold time - (byte) 0xb6, (byte) 0x02, 0x5d, - (byte) 0xc8, // BGP Identifier - 0x08, 0x02, 0x06, // Opt Parameter length - 0x01, 0x04, 0x00, 0x00, 0x00, (byte) 0xc8}; // Multiprotocol CAPABILITY - - byte[] testOpenMsg; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message; - BGPHeader bgpHeader = new BGPHeader(); - - message = reader.readFrom(buffer, bgpHeader); - - assertThat(message, instanceOf(BGPOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - } - - /** - * This test case checks open message with Four-octet AS number - * capability. - */ - @Test - public void openMessageTest3() throws BGPParseException { - - // OPEN Message (Four-Octet AS number capability). - byte[] openMsg = new byte[] {(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, 0x00, 0x25, - 0x01, //BGPHeader - 0X04, //Version - (byte) 0x00, (byte) 0xc8, //AS Number - 0x00, (byte) 0xb4, //Hold Time - (byte) 0xb6, (byte) 0x02, 0x5d, - (byte) 0xc8, //BGP Identifier - 0x08, 0x02, 0x06, //Opt Parameter Length - 0x41, 0x04, 0x00, 0x01, 0x00, 0x01}; //Four Octet AS Number-CAPABILITY-TLV - - byte[] testOpenMsg; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message; - BGPHeader bgpHeader = new BGPHeader(); - - message = reader.readFrom(buffer, bgpHeader); - - assertThat(message, instanceOf(BGPOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - } - - /** - * This test case checks open message with capabilities. - */ - @Test - public void openMessageTest4() throws BGPParseException { - - // OPEN Message with capabilities. - byte[] openMsg = new byte[] {(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, 0x00, 0x2b, - 0x01, //BGPHeader - 0X04, //Version - (byte) 0x00, (byte) 0xc8, //AS Number - 0x00, (byte) 0xb4, //Hold Time - (byte) 0xb6, (byte) 0x02, 0x5d, (byte) 0xc8, //BGP Identifier - 0x0e, 0x02, 0x0c, //Opt Parameter Length - 0x01, 0x04, 0x00, 0x00, 0x00, (byte) 0xc8, // Multiprotocol extension capability - 0x41, 0x04, 0x00, 0x01, 0x00, 0x01}; //Four Octet AS Number-CAPABILITY-TLV - - byte[] testOpenMsg; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message; - BGPHeader bgpHeader = new BGPHeader(); - - message = reader.readFrom(buffer, bgpHeader); - - assertThat(message, instanceOf(BGPOpenMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - } - - /** - * In this test case, Invalid version is given as input and expecting - * an exception. - */ - @Test(expected = BGPParseException.class) - public void openMessageTest5() throws BGPParseException { - - // OPEN Message with invalid version number. - byte[] openMsg = new byte[] {(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, 0x00, 0x1d, 0x01, 0X05, - (byte) 0xfe, 0x09, 0x00, (byte) 0xb4, - (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, - 0x00}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message; - BGPHeader bgpHeader = new BGPHeader(); - message = reader.readFrom(buffer, bgpHeader); - - assertThat(message, instanceOf(BGPOpenMsg.class)); - } - - /** - * In this test case, Marker is set as 0 in input and expecting - * an exception. - */ - @Test(expected = BGPParseException.class) - public void openMessageTest6() throws BGPParseException { - - // OPEN Message with marker set to 0. - byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, - (byte) 0xff, (byte) 0xff, (byte) 0xff, - (byte) 0xff, (byte) 0xff, (byte) 0xff, - (byte) 0x00, (byte) 0xff, (byte) 0xff, - (byte) 0xff, (byte) 0xff, (byte) 0xff, - 0x00, 0x00, 0x1d, 0x01, 0X04, - (byte) 0xfe, 0x09, 0x00, (byte) 0xb4, - (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, - 0x00}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message; - BGPHeader bgpHeader = new BGPHeader(); - message = reader.readFrom(buffer, bgpHeader); - - assertThat(message, instanceOf(BGPOpenMsg.class)); - } - - /** - * In this test case, Invalid message length is given as input and expecting - * an exception. - */ - @Test(expected = BGPParseException.class) - public void openMessageTest7() throws BGPParseException { - - // OPEN Message with invalid header length. - byte[] openMsg = new byte[] {(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, 0x00, 0x1e, 0x01, 0X04, - (byte) 0xfe, 0x09, 0x00, (byte) 0xb4, - (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, - 0x00}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message; - BGPHeader bgpHeader = new BGPHeader(); - message = reader.readFrom(buffer, bgpHeader); - - assertThat(message, instanceOf(BGPOpenMsg.class)); - } - - /** - * In this test case, Invalid message type is given as input and expecting - * an exception. - */ - @Test(expected = BGPParseException.class) - public void openMessageTest8() throws BGPParseException { - - // OPEN Message with invalid message type. - byte[] openMsg = new byte[] {(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, 0x00, 0x1d, 0x05, 0X04, - (byte) 0xfe, 0x09, 0x00, (byte) 0xb4, - (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, - 0x00}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message; - BGPHeader bgpHeader = new BGPHeader(); - message = reader.readFrom(buffer, bgpHeader); - - assertThat(message, instanceOf(BGPOpenMsg.class)); - } -} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpAttrNodeFlagBitTlvTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpAttrNodeFlagBitTlvTest.java deleted file mode 100644 index 5f1411ff..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpAttrNodeFlagBitTlvTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.attr.BgpAttrNodeFlagBitTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test for BGP attribute node flag. - */ -public class BgpAttrNodeFlagBitTlvTest { - - private final boolean bOverloadBit = true; - private final boolean bAttachedBit = true; - private final boolean bExternalBit = true; - private final boolean bABRBit = true; - - private final boolean bOverloadBit1 = false; - private final boolean bAttachedBit1 = false; - private final boolean bExternalBit1 = false; - private final boolean bABRBit1 = false; - - private final BgpAttrNodeFlagBitTlv data = BgpAttrNodeFlagBitTlv - .of(bOverloadBit, bAttachedBit, bExternalBit, bABRBit); - private final BgpAttrNodeFlagBitTlv sameAsData = BgpAttrNodeFlagBitTlv - .of(bOverloadBit, bAttachedBit, bExternalBit, bABRBit); - private final BgpAttrNodeFlagBitTlv diffData = BgpAttrNodeFlagBitTlv - .of(bOverloadBit1, bAttachedBit1, bExternalBit1, bABRBit1); - - @Test - public void basics() { - - new EqualsTester().addEqualityGroup(data, sameAsData) - .addEqualityGroup(diffData).testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpAttrRouterIdV6Test.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpAttrRouterIdV6Test.java deleted file mode 100644 index 72ca5dbf..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpAttrRouterIdV6Test.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onlab.packet.Ip6Address; -import org.onosproject.bgpio.types.attr.BgpAttrRouterIdV6; - -import com.google.common.testing.EqualsTester; - -/** - * Test for BGP attribute node router ID. - */ -public class BgpAttrRouterIdV6Test { - - private final short sType = 1; - private final Ip6Address ip6RouterId = Ip6Address - .valueOf("2001:0db8:0a0b:12f0:0000:0000:0000:0001"); - - private final short sType1 = 2; - private final Ip6Address ip6RouterId1 = Ip6Address - .valueOf("2004:0db8:0a0b:12f0:0000:0000:0000:0004"); - - private final BgpAttrRouterIdV6 data = BgpAttrRouterIdV6.of(ip6RouterId, - sType); - private final BgpAttrRouterIdV6 sameAsData = BgpAttrRouterIdV6 - .of(ip6RouterId, sType); - private final BgpAttrRouterIdV6 diffData = BgpAttrRouterIdV6 - .of(ip6RouterId1, sType1); - - @Test - public void basics() { - - new EqualsTester().addEqualityGroup(data, sameAsData) - .addEqualityGroup(diffData).testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrIgpMetricTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrIgpMetricTest.java deleted file mode 100644 index 32280a79..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrIgpMetricTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.attr.BgpLinkAttrIgpMetric; - -import com.google.common.testing.EqualsTester; - -/** - * Test for BGP link IGP metric attribute. - */ -public class BgpLinkAttrIgpMetricTest { - private final int val = 0x010203; - private final int valLen = 3; - private final int val1 = 0x01020304; - private final int val1Len = 4; - - private final BgpLinkAttrIgpMetric data = BgpLinkAttrIgpMetric.of(val, - valLen); - private final BgpLinkAttrIgpMetric sameAsData = BgpLinkAttrIgpMetric - .of(val, valLen); - private final BgpLinkAttrIgpMetric diffData = BgpLinkAttrIgpMetric - .of(val1, val1Len); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(data, sameAsData) - .addEqualityGroup(diffData).testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrMplsProtocolMaskTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrMplsProtocolMaskTest.java deleted file mode 100644 index d218334b..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrMplsProtocolMaskTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.attr.BgpLinkAttrMplsProtocolMask; - -import com.google.common.testing.EqualsTester; - -/** - * Test for MPLS protocol mask attribute. - */ -public class BgpLinkAttrMplsProtocolMaskTest { - private final boolean val = true; - private final boolean val1 = false; - - private final BgpLinkAttrMplsProtocolMask data = BgpLinkAttrMplsProtocolMask - .of(val, val); - private final BgpLinkAttrMplsProtocolMask sameAsData = BgpLinkAttrMplsProtocolMask - .of(val, val); - private final BgpLinkAttrMplsProtocolMask diffData = BgpLinkAttrMplsProtocolMask - .of(val, val1); - - @Test - public void basics() { - - new EqualsTester().addEqualityGroup(data, sameAsData) - .addEqualityGroup(diffData).testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrProtectionTypeTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrProtectionTypeTest.java deleted file mode 100644 index 89f97a83..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrProtectionTypeTest.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.attr.BgpLinkAttrProtectionType; - -import com.google.common.testing.EqualsTester; - -/** - * Test for MPLS protocol mask attribute. - */ -public class BgpLinkAttrProtectionTypeTest { - boolean bExtraTraffic = true; - boolean bUnprotected = true; - boolean bShared = true; - boolean bDedOneIstoOne = true; - boolean bDedOnePlusOne = true; - boolean bEnhanced = true; - - boolean bExtraTraffic1 = false; - boolean bUnprotected1 = false; - boolean bShared1 = false; - boolean bDedOneIstoOne1 = false; - boolean bDedOnePlusOne1 = false; - boolean bEnhanced1 = false; - - private final BgpLinkAttrProtectionType data = BgpLinkAttrProtectionType - .of(bExtraTraffic, bUnprotected, bShared, bDedOneIstoOne, - bDedOnePlusOne, bEnhanced); - private final BgpLinkAttrProtectionType sameAsData = BgpLinkAttrProtectionType - .of(bExtraTraffic, bUnprotected, bShared, bDedOneIstoOne, - bDedOnePlusOne, bEnhanced); - private final BgpLinkAttrProtectionType diffData = BgpLinkAttrProtectionType - .of(bExtraTraffic1, bUnprotected1, bShared1, bDedOneIstoOne1, - bDedOnePlusOne1, bEnhanced1); - - @Test - public void basics() { - - new EqualsTester().addEqualityGroup(data, sameAsData) - .addEqualityGroup(diffData).testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpNotificationMsgTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpNotificationMsgTest.java deleted file mode 100644 index d3e6e49c..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpNotificationMsgTest.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.core.Is.is; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Test; -import org.onosproject.bgpio.exceptions.BGPParseException; -import org.onosproject.bgpio.protocol.BGPFactories; -import org.onosproject.bgpio.protocol.BGPMessage; -import org.onosproject.bgpio.protocol.BGPMessageReader; -import org.onosproject.bgpio.protocol.BGPNotificationMsg; -import org.onosproject.bgpio.types.BGPHeader; - -/** - * Test for Notification message. - */ -public class BgpNotificationMsgTest { - - /** - * Notification message with error code, error subcode and data. - * - * @throws BGPParseException while decoding and encoding notification message - */ - @Test - public void bgpNotificationMessageTest1() throws BGPParseException { - byte[] notificationMsg = new byte[] {(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, 0x00, - 0x17, 0x03, 0x02, 0x02, - (byte) 0xfe, (byte) 0xb0}; - - byte[] testNotificationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(notificationMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message = null; - BGPHeader bgpHeader = new BGPHeader(); - - message = reader.readFrom(buffer, bgpHeader); - assertThat(message, instanceOf(BGPNotificationMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testNotificationMsg = buf.array(); - - int iReadLen = buf.writerIndex() - 0; - testNotificationMsg = new byte[iReadLen]; - buf.readBytes(testNotificationMsg, 0, iReadLen); - assertThat(testNotificationMsg, is(notificationMsg)); - } - - /** - * Notification message without data. - * - * @throws BGPParseException while decoding and encoding notification message - */ - @Test - public void bgpNotificationMessageTest2() throws BGPParseException { - byte[] notificationMsg = new byte[] {(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, 0x00, - 0x15, 0x03, 0x02, 0x00}; - - byte[] testNotificationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(notificationMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message = null; - BGPHeader bgpHeader = new BGPHeader(); - - message = reader.readFrom(buffer, bgpHeader); - assertThat(message, instanceOf(BGPNotificationMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testNotificationMsg = buf.array(); - - int iReadLen = buf.writerIndex() - 0; - testNotificationMsg = new byte[iReadLen]; - buf.readBytes(testNotificationMsg, 0, iReadLen); - assertThat(testNotificationMsg, is(notificationMsg)); - } - - //Negative scenarios - /** - * Notification message with wrong maker value. - * - * @throws BGPParseException while decoding and encoding notification message - */ - @Test(expected = BGPParseException.class) - public void bgpNotificationMessageTest3() throws BGPParseException { - byte[] notificationMsg = new byte[] {(byte) 0xff, (byte) 0xff, - (byte) 0xff, (byte) 0xff, - (byte) 0xff, (byte) 0xff, - (byte) 0xff, (byte) 0xff, - (byte) 0xff, (byte) 0xff, - 0x01, (byte) 0xff, - (byte) 0xff, (byte) 0xff, - (byte) 0xff, (byte) 0xff, 0x00, - 0x15, 0x03, 0x02, 0x00}; - - byte[] testNotificationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(notificationMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message = null; - BGPHeader bgpHeader = new BGPHeader(); - - message = reader.readFrom(buffer, bgpHeader); - assertThat(message, instanceOf(BGPNotificationMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testNotificationMsg = buf.array(); - - int iReadLen = buf.writerIndex() - 0; - testNotificationMsg = new byte[iReadLen]; - buf.readBytes(testNotificationMsg, 0, iReadLen); - assertThat(testNotificationMsg, is(notificationMsg)); - } - - /** - * Notification message without error subcode. - * - * @throws BGPParseException while decoding and encoding notification message - */ - @Test(expected = BGPParseException.class) - public void bgpNotificationMessageTest4() throws BGPParseException { - byte[] notificationMsg = new byte[] {(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, 0x00, - 0x14, 0x03, 0x02}; - - byte[] testNotificationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(notificationMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message = null; - BGPHeader bgpHeader = new BGPHeader(); - - message = reader.readFrom(buffer, bgpHeader); - assertThat(message, instanceOf(BGPNotificationMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testNotificationMsg = buf.array(); - - int iReadLen = buf.writerIndex() - 0; - testNotificationMsg = new byte[iReadLen]; - buf.readBytes(testNotificationMsg, 0, iReadLen); - assertThat(testNotificationMsg, is(notificationMsg)); - } - - /** - * Notification message with wrong message length. - * - * @throws BGPParseException while decoding and encoding notification message - */ - @Test(expected = BGPParseException.class) - public void bgpNotificationMessageTest5() throws BGPParseException { - byte[] notificationMsg = new byte[] {(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, 0x00, - 0x14, 0x03, 0x02, 0x02}; - - byte[] testNotificationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(notificationMsg); - - BGPMessageReader reader = BGPFactories.getGenericReader(); - BGPMessage message = null; - BGPHeader bgpHeader = new BGPHeader(); - - message = reader.readFrom(buffer, bgpHeader); - assertThat(message, instanceOf(BGPNotificationMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testNotificationMsg = buf.array(); - - int iReadLen = buf.writerIndex() - 0; - testNotificationMsg = new byte[iReadLen]; - buf.readBytes(testNotificationMsg, 0, iReadLen); - assertThat(testNotificationMsg, is(notificationMsg)); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrMetricTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrMetricTest.java deleted file mode 100644 index 5a3662be..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrMetricTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.attr.BgpPrefixAttrMetric; - -import com.google.common.testing.EqualsTester; - -/** - * Test for BGP prefix metric attribute. - */ -public class BgpPrefixAttrMetricTest { - private final int val = 1111; - private final int val1 = 2222; - - private final BgpPrefixAttrMetric data = BgpPrefixAttrMetric.of(val); - private final BgpPrefixAttrMetric sameAsData = BgpPrefixAttrMetric.of(val); - private final BgpPrefixAttrMetric diffData = BgpPrefixAttrMetric.of(val1); - - @Test - public void basics() { - - new EqualsTester().addEqualityGroup(data, sameAsData) - .addEqualityGroup(diffData).testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrOspfFwdAddrTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrOspfFwdAddrTest.java deleted file mode 100644 index f736bead..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrOspfFwdAddrTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onlab.packet.Ip4Address; -import org.onlab.packet.Ip6Address; -import org.onosproject.bgpio.types.attr.BgpPrefixAttrOspfFwdAddr; - -import com.google.common.testing.EqualsTester; - -/** - * Test for BGP prefix metric attribute. - */ -public class BgpPrefixAttrOspfFwdAddrTest { - - private final short lsAttrLength = 4; - private final Ip4Address ip4RouterId = Ip4Address.valueOf("192.168.1.1"); - private final Ip6Address ip6RouterId = Ip6Address - .valueOf("2001:0db8:0a0b:12f0:0000:0000:0000:0001"); - - private final short lsAttrLength1 = 16; - private final Ip4Address ip4RouterId1 = Ip4Address.valueOf("192.168.1.2"); - private final Ip6Address ip6RouterId1 = Ip6Address - .valueOf("1002:0db8:0a0b:12f0:0000:0000:0000:0002"); - - private final BgpPrefixAttrOspfFwdAddr data = BgpPrefixAttrOspfFwdAddr - .of(lsAttrLength, ip4RouterId, ip6RouterId); - private final BgpPrefixAttrOspfFwdAddr sameAsData = BgpPrefixAttrOspfFwdAddr - .of(lsAttrLength, ip4RouterId, ip6RouterId); - private final BgpPrefixAttrOspfFwdAddr diffData = BgpPrefixAttrOspfFwdAddr - .of(lsAttrLength1, ip4RouterId1, ip6RouterId1); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(data, sameAsData) - .addEqualityGroup(diffData).testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPReachabilityInformationTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPReachabilityInformationTest.java deleted file mode 100644 index 81f4b725..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPReachabilityInformationTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.IPReachabilityInformationTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test for IPReachabilityInformation Tlv. - */ -public class IPReachabilityInformationTest { - private final byte[] value1 = new byte[] {(byte) 0xc0, (byte) 0xa8, 0x4d, 0x01}; - private final byte[] value2 = new byte[] {(byte) 0xc0}; - private final IPReachabilityInformationTlv tlv1 = IPReachabilityInformationTlv.of((byte) 0x17, value1, (short) 4); - private final IPReachabilityInformationTlv sameAsTlv1 = IPReachabilityInformationTlv - .of((byte) 0x17, value1, (short) 4); - private final IPReachabilityInformationTlv tlv2 = IPReachabilityInformationTlv.of((byte) 0x05, value2, (short) 1); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv4AddressTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv4AddressTest.java deleted file mode 100755 index f3a0469c..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv4AddressTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onlab.packet.Ip4Address; -import org.onosproject.bgpio.types.IPv4AddressTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test for IPv4Address Tlv. - */ -public class IPv4AddressTest { - private final Ip4Address value1 = Ip4Address.valueOf("127.0.0.1"); - private final Ip4Address value2 = Ip4Address.valueOf("127.0.0.1"); - private final IPv4AddressTlv tlv1 = IPv4AddressTlv.of(value1, (short) 259); - private final IPv4AddressTlv sameAsTlv1 = IPv4AddressTlv.of(value1, (short) 259); - private final IPv4AddressTlv tlv2 = IPv4AddressTlv.of(value2, (short) 260); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv6AddressTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv6AddressTest.java deleted file mode 100644 index 2023093f..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv6AddressTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onlab.packet.Ip6Address; -import org.onosproject.bgpio.types.IPv6AddressTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test for IPv6Address Tlv. - */ -public class IPv6AddressTest { - private final Ip6Address value1 = Ip6Address.valueOf("2001:db8:0:0:0:0:2:1"); - private final Ip6Address value2 = Ip6Address.valueOf("2001:db8:0:0:0:0:2:1"); - private final IPv6AddressTlv tlv1 = IPv6AddressTlv.of(value1, (short) 261); - private final IPv6AddressTlv sameAsTlv1 = IPv6AddressTlv.of(value1, (short) 261); - private final IPv6AddressTlv tlv2 = IPv6AddressTlv.of(value2, (short) 262); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsNonPseudonodeTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsNonPseudonodeTest.java deleted file mode 100644 index 8112b51c..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsNonPseudonodeTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.IsIsNonPseudonode; - -import com.google.common.testing.EqualsTester; - -/** - * Test for IsIsNonPseudonode Tlv. - */ -public class IsIsNonPseudonodeTest { - private final byte[] value1 = new byte[] {0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; - private final byte[] value2 = new byte[] {0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x59}; - private final IsIsNonPseudonode tlv1 = IsIsNonPseudonode.of(value1); - private final IsIsNonPseudonode sameAsTlv1 = IsIsNonPseudonode.of(value1); - private final IsIsNonPseudonode tlv2 = IsIsNonPseudonode.of(value2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsPseudonodeTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsPseudonodeTest.java deleted file mode 100644 index bbc9e6a2..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsPseudonodeTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.IsIsPseudonode; - -import com.google.common.testing.EqualsTester; - -/** - * Test for IsIsPseudonode Tlv. - */ -public class IsIsPseudonodeTest { - private final byte[] value1 = new byte[] {0x01, 0x02, 0x01, 0x02, 0x01, 0x02}; - private final byte[] value2 = new byte[] {0x01, 0x02, 0x01, 0x02, 0x01, 0x03}; - private final IsIsPseudonode tlv1 = IsIsPseudonode.of(value1, (byte) 1); - private final IsIsPseudonode sameAsTlv1 = IsIsPseudonode.of(value1, (byte) 1); - private final IsIsPseudonode tlv2 = IsIsPseudonode.of(value2, (byte) 1); - - @Test - public void testEquality() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/LinkLocalRemoteIdentifiersTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/LinkLocalRemoteIdentifiersTest.java deleted file mode 100644 index 22b9aba3..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/LinkLocalRemoteIdentifiersTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test for LinkLocalRemoteIdentifiers Tlv. - */ -public class LinkLocalRemoteIdentifiersTest { - private final int value1 = 0x12101010; - private final int value2 = 0x12101012; - private final LinkLocalRemoteIdentifiersTlv tlv1 = LinkLocalRemoteIdentifiersTlv.of(value1, value2); - private final LinkLocalRemoteIdentifiersTlv sameAsTlv1 = LinkLocalRemoteIdentifiersTlv.of(value1, value2); - private final LinkLocalRemoteIdentifiersTlv tlv2 = LinkLocalRemoteIdentifiersTlv.of(value2, value1); - - @Test - public void testEquality() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/NextHopTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/NextHopTest.java deleted file mode 100755 index 109197bb..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/NextHopTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onlab.packet.Ip4Address; -import org.onosproject.bgpio.types.NextHop; - -import com.google.common.testing.EqualsTester; - -/** - * Test for NextHop BGP Path Attribute. - */ -public class NextHopTest { - private final Ip4Address value1 = Ip4Address.valueOf("12.12.12.12"); - private final Ip4Address value2 = Ip4Address.valueOf("12.12.12.13"); - private final NextHop attr1 = new NextHop(value1); - private final NextHop sameAsAttr1 = new NextHop(value1); - private final NextHop attr2 = new NextHop(value2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(attr1, sameAsAttr1) - .addEqualityGroup(attr2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OriginTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OriginTest.java deleted file mode 100644 index 88261ad5..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OriginTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.Origin; - -import com.google.common.testing.EqualsTester; - -/** - * Test for Origin BGP Path Attribute. - */ -public class OriginTest { - private final byte value1 = 0x01; - private final byte value2 = 0x02; - private final Origin attr1 = new Origin(value1); - private final Origin sameAsAttr1 = new Origin(value1); - private final Origin attr2 = new Origin(value2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(attr1, sameAsAttr1) - .addEqualityGroup(attr2) - .testEquals(); - } -} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfNonPseudonodeTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfNonPseudonodeTest.java deleted file mode 100644 index 19002913..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfNonPseudonodeTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2014-2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.OSPFNonPseudonode; - -import com.google.common.testing.EqualsTester; - -/** - * Test for OSPFNonPseudonode Tlv. - */ -public class OspfNonPseudonodeTest { - private final int value1 = 0x12121212; - private final int value2 = 0x12121211; - private final OSPFNonPseudonode tlv1 = OSPFNonPseudonode.of(value1); - private final OSPFNonPseudonode sameAsTlv1 = OSPFNonPseudonode.of(value1); - private final OSPFNonPseudonode tlv2 = OSPFNonPseudonode.of(value2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfPseudonodeTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfPseudonodeTest.java deleted file mode 100644 index 55b1190b..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfPseudonodeTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onlab.packet.Ip4Address; -import org.onosproject.bgpio.types.OSPFPseudonode; - -import com.google.common.testing.EqualsTester; - -/** - * Test for OSPFPseudonode Tlv. - */ -public class OspfPseudonodeTest { - private final int value1 = 0xc3223409; - private final int value2 = 0xc3223406; - private final Ip4Address drInterface1 = Ip4Address.valueOf(0xaf91e01); - private final Ip4Address drInterface2 = Ip4Address.valueOf(0xaf91e02); - private final OSPFPseudonode tlv1 = OSPFPseudonode.of(value1, drInterface1); - private final OSPFPseudonode sameAsTlv1 = OSPFPseudonode.of(value1, drInterface1); - private final OSPFPseudonode tlv2 = OSPFPseudonode.of(value2, drInterface2); - - @Test - public void testEquality() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfRouteTypeTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfRouteTypeTest.java deleted file mode 100644 index e2fd1eaf..00000000 --- a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfRouteTypeTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2015 Open Networking Laboratory - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.onosproject.bgp; - -import org.junit.Test; -import org.onosproject.bgpio.types.OSPFRouteTypeTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test for OSPFRouteType Tlv. - */ -public class OspfRouteTypeTest { - private final byte value1 = 5; - private final byte value2 = 4; - private final OSPFRouteTypeTlv tlv1 = OSPFRouteTypeTlv.of(value1); - private final OSPFRouteTypeTlv sameAsTlv1 = OSPFRouteTypeTlv.of(value1); - private final OSPFRouteTypeTlv tlv2 = OSPFRouteTypeTlv.of(value2); - - @Test - public void testEquality() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BGPKeepaliveMsgTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BGPKeepaliveMsgTest.java new file mode 100755 index 00000000..68ce3070 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BGPKeepaliveMsgTest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.bgpio.exceptions.BGPParseException; +import org.onosproject.bgpio.types.BGPHeader; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +/** + * Test case for BGP KEEPALIVE Message. + */ +public class BGPKeepaliveMsgTest { + + /** + * This test case checks BGP Keepalive message. + */ + @Test + public void keepaliveMessageTest1() throws BGPParseException { + + // BGP KEEPALIVE Message + byte[] keepaliveMsg = new byte[] {(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, + 0x00, 0x13, 0x04}; + + byte[] testKeepaliveMsg; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(keepaliveMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message; + BGPHeader bgpHeader = new BGPHeader(); + + message = reader.readFrom(buffer, bgpHeader); + + assertThat(message, instanceOf(BGPKeepaliveMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testKeepaliveMsg = new byte[readLen]; + buf.readBytes(testKeepaliveMsg, 0, readLen); + + assertThat(testKeepaliveMsg, is(keepaliveMsg)); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BGPOpenMsgTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BGPOpenMsgTest.java new file mode 100755 index 00000000..d5210177 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BGPOpenMsgTest.java @@ -0,0 +1,314 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.bgpio.exceptions.BGPParseException; +import org.onosproject.bgpio.types.BGPHeader; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +/** + * Test cases for BGP Open Message. + */ +public class BGPOpenMsgTest { + + /** + * This test case checks open message without optional parameter. + */ + @Test + public void openMessageTest1() throws BGPParseException { + //Open message without optional parameter + byte[] openMsg = new byte[] {(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, + 0x00, 0x1d, 0x01, 0X04, (byte) 0xfe, 0x09, 0x00, + (byte) 0xb4, (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, + 0x00}; + + byte[] testOpenMsg; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message; + BGPHeader bgpHeader = new BGPHeader(); + message = reader.readFrom(buffer, bgpHeader); + + assertThat(message, instanceOf(BGPOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + } + + /** + * This test case checks open message with Multiprotocol extension + * capability. + */ + @Test + public void openMessageTest2() throws BGPParseException { + + // OPEN Message (MultiProtocolExtension-CAPABILITY). + byte[] openMsg = new byte[] {(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, 0x00, 0x25, + 0x01, //BGP Header + 0X04, //Version + (byte) 0x00, (byte) 0xc8, // AS Number + 0x00, (byte) 0xb4, // Hold time + (byte) 0xb6, (byte) 0x02, 0x5d, + (byte) 0xc8, // BGP Identifier + 0x08, 0x02, 0x06, // Opt Parameter length + 0x01, 0x04, 0x00, 0x00, 0x00, (byte) 0xc8}; // Multiprotocol CAPABILITY + + byte[] testOpenMsg; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message; + BGPHeader bgpHeader = new BGPHeader(); + + message = reader.readFrom(buffer, bgpHeader); + + assertThat(message, instanceOf(BGPOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + } + + /** + * This test case checks open message with Four-octet AS number + * capability. + */ + @Test + public void openMessageTest3() throws BGPParseException { + + // OPEN Message (Four-Octet AS number capability). + byte[] openMsg = new byte[] {(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, 0x00, 0x25, + 0x01, //BGPHeader + 0X04, //Version + (byte) 0x00, (byte) 0xc8, //AS Number + 0x00, (byte) 0xb4, //Hold Time + (byte) 0xb6, (byte) 0x02, 0x5d, + (byte) 0xc8, //BGP Identifier + 0x08, 0x02, 0x06, //Opt Parameter Length + 0x41, 0x04, 0x00, 0x01, 0x00, 0x01}; //Four Octet AS Number-CAPABILITY-TLV + + byte[] testOpenMsg; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message; + BGPHeader bgpHeader = new BGPHeader(); + + message = reader.readFrom(buffer, bgpHeader); + + assertThat(message, instanceOf(BGPOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + } + + /** + * This test case checks open message with capabilities. + */ + @Test + public void openMessageTest4() throws BGPParseException { + + // OPEN Message with capabilities. + byte[] openMsg = new byte[] {(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, 0x00, 0x2b, + 0x01, //BGPHeader + 0X04, //Version + (byte) 0x00, (byte) 0xc8, //AS Number + 0x00, (byte) 0xb4, //Hold Time + (byte) 0xb6, (byte) 0x02, 0x5d, (byte) 0xc8, //BGP Identifier + 0x0e, 0x02, 0x0c, //Opt Parameter Length + 0x01, 0x04, 0x00, 0x00, 0x00, (byte) 0xc8, // Multiprotocol extension capability + 0x41, 0x04, 0x00, 0x01, 0x00, 0x01}; //Four Octet AS Number-CAPABILITY-TLV + + byte[] testOpenMsg; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message; + BGPHeader bgpHeader = new BGPHeader(); + + message = reader.readFrom(buffer, bgpHeader); + + assertThat(message, instanceOf(BGPOpenMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + } + + /** + * In this test case, Invalid version is given as input and expecting + * an exception. + */ + @Test(expected = BGPParseException.class) + public void openMessageTest5() throws BGPParseException { + + // OPEN Message with invalid version number. + byte[] openMsg = new byte[] {(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, 0x00, 0x1d, 0x01, 0X05, + (byte) 0xfe, 0x09, 0x00, (byte) 0xb4, + (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, + 0x00}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message; + BGPHeader bgpHeader = new BGPHeader(); + message = reader.readFrom(buffer, bgpHeader); + + assertThat(message, instanceOf(BGPOpenMsg.class)); + } + + /** + * In this test case, Marker is set as 0 in input and expecting + * an exception. + */ + @Test(expected = BGPParseException.class) + public void openMessageTest6() throws BGPParseException { + + // OPEN Message with marker set to 0. + byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, + (byte) 0x00, (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, (byte) 0xff, + 0x00, 0x00, 0x1d, 0x01, 0X04, + (byte) 0xfe, 0x09, 0x00, (byte) 0xb4, + (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, + 0x00}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message; + BGPHeader bgpHeader = new BGPHeader(); + message = reader.readFrom(buffer, bgpHeader); + + assertThat(message, instanceOf(BGPOpenMsg.class)); + } + + /** + * In this test case, Invalid message length is given as input and expecting + * an exception. + */ + @Test(expected = BGPParseException.class) + public void openMessageTest7() throws BGPParseException { + + // OPEN Message with invalid header length. + byte[] openMsg = new byte[] {(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, 0x00, 0x1e, 0x01, 0X04, + (byte) 0xfe, 0x09, 0x00, (byte) 0xb4, + (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, + 0x00}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message; + BGPHeader bgpHeader = new BGPHeader(); + message = reader.readFrom(buffer, bgpHeader); + + assertThat(message, instanceOf(BGPOpenMsg.class)); + } + + /** + * In this test case, Invalid message type is given as input and expecting + * an exception. + */ + @Test(expected = BGPParseException.class) + public void openMessageTest8() throws BGPParseException { + + // OPEN Message with invalid message type. + byte[] openMsg = new byte[] {(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, 0x00, 0x1d, 0x05, 0X04, + (byte) 0xfe, 0x09, 0x00, (byte) 0xb4, + (byte) 0xc0, (byte) 0xa8, 0x00, 0x0f, + 0x00}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message; + BGPHeader bgpHeader = new BGPHeader(); + message = reader.readFrom(buffer, bgpHeader); + + assertThat(message, instanceOf(BGPOpenMsg.class)); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpNotificationMsgTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpNotificationMsgTest.java new file mode 100644 index 00000000..78edf133 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/protocol/BgpNotificationMsgTest.java @@ -0,0 +1,224 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.bgpio.exceptions.BGPParseException; +import org.onosproject.bgpio.types.BGPHeader; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +/** + * Test for Notification message. + */ +public class BgpNotificationMsgTest { + + /** + * Notification message with error code, error subcode and data. + * + * @throws BGPParseException while decoding and encoding notification message + */ + @Test + public void bgpNotificationMessageTest1() throws BGPParseException { + byte[] notificationMsg = new byte[] {(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, 0x00, + 0x17, 0x03, 0x02, 0x02, + (byte) 0xfe, (byte) 0xb0}; + + byte[] testNotificationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(notificationMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message = null; + BGPHeader bgpHeader = new BGPHeader(); + + message = reader.readFrom(buffer, bgpHeader); + assertThat(message, instanceOf(BGPNotificationMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testNotificationMsg = buf.array(); + + int iReadLen = buf.writerIndex() - 0; + testNotificationMsg = new byte[iReadLen]; + buf.readBytes(testNotificationMsg, 0, iReadLen); + assertThat(testNotificationMsg, is(notificationMsg)); + } + + /** + * Notification message without data. + * + * @throws BGPParseException while decoding and encoding notification message + */ + @Test + public void bgpNotificationMessageTest2() throws BGPParseException { + byte[] notificationMsg = new byte[] {(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, 0x00, + 0x15, 0x03, 0x02, 0x00}; + + byte[] testNotificationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(notificationMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message = null; + BGPHeader bgpHeader = new BGPHeader(); + + message = reader.readFrom(buffer, bgpHeader); + assertThat(message, instanceOf(BGPNotificationMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testNotificationMsg = buf.array(); + + int iReadLen = buf.writerIndex() - 0; + testNotificationMsg = new byte[iReadLen]; + buf.readBytes(testNotificationMsg, 0, iReadLen); + assertThat(testNotificationMsg, is(notificationMsg)); + } + + //Negative scenarios + /** + * Notification message with wrong maker value. + * + * @throws BGPParseException while decoding and encoding notification message + */ + @Test(expected = BGPParseException.class) + public void bgpNotificationMessageTest3() throws BGPParseException { + byte[] notificationMsg = new byte[] {(byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, + 0x01, (byte) 0xff, + (byte) 0xff, (byte) 0xff, + (byte) 0xff, (byte) 0xff, 0x00, + 0x15, 0x03, 0x02, 0x00}; + + byte[] testNotificationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(notificationMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message = null; + BGPHeader bgpHeader = new BGPHeader(); + + message = reader.readFrom(buffer, bgpHeader); + assertThat(message, instanceOf(BGPNotificationMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testNotificationMsg = buf.array(); + + int iReadLen = buf.writerIndex() - 0; + testNotificationMsg = new byte[iReadLen]; + buf.readBytes(testNotificationMsg, 0, iReadLen); + assertThat(testNotificationMsg, is(notificationMsg)); + } + + /** + * Notification message without error subcode. + * + * @throws BGPParseException while decoding and encoding notification message + */ + @Test(expected = BGPParseException.class) + public void bgpNotificationMessageTest4() throws BGPParseException { + byte[] notificationMsg = new byte[] {(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, 0x00, + 0x14, 0x03, 0x02}; + + byte[] testNotificationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(notificationMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message = null; + BGPHeader bgpHeader = new BGPHeader(); + + message = reader.readFrom(buffer, bgpHeader); + assertThat(message, instanceOf(BGPNotificationMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testNotificationMsg = buf.array(); + + int iReadLen = buf.writerIndex() - 0; + testNotificationMsg = new byte[iReadLen]; + buf.readBytes(testNotificationMsg, 0, iReadLen); + assertThat(testNotificationMsg, is(notificationMsg)); + } + + /** + * Notification message with wrong message length. + * + * @throws BGPParseException while decoding and encoding notification message + */ + @Test(expected = BGPParseException.class) + public void bgpNotificationMessageTest5() throws BGPParseException { + byte[] notificationMsg = new byte[] {(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, 0x00, + 0x14, 0x03, 0x02, 0x02}; + + byte[] testNotificationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(notificationMsg); + + BGPMessageReader reader = BGPFactories.getGenericReader(); + BGPMessage message = null; + BGPHeader bgpHeader = new BGPHeader(); + + message = reader.readFrom(buffer, bgpHeader); + assertThat(message, instanceOf(BGPNotificationMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testNotificationMsg = buf.array(); + + int iReadLen = buf.writerIndex() - 0; + testNotificationMsg = new byte[iReadLen]; + buf.readBytes(testNotificationMsg, 0, iReadLen); + assertThat(testNotificationMsg, is(notificationMsg)); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AreaIdTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AreaIdTest.java new file mode 100644 index 00000000..6a9e2ec5 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AreaIdTest.java @@ -0,0 +1,77 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for AreaID Tlv. + */ +public class AreaIdTest { + private final int value1 = 10; + private final int value2 = 20; + private final AreaIDTlv tlv1 = AreaIDTlv.of(value1); + private final AreaIDTlv sameAsTlv1 = AreaIDTlv.of(value1); + private final AreaIDTlv tlv2 = AreaIDTlv.of(value2); + + @Test + public void testEquality() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } + + /** + * Test for OSPFNonPseudonode Tlv. + */ + public static class OspfNonPseudonodeTest { + private final int value1 = 0x12121212; + private final int value2 = 0x12121211; + private final OSPFNonPseudonode tlv1 = OSPFNonPseudonode.of(value1); + private final OSPFNonPseudonode sameAsTlv1 = OSPFNonPseudonode.of(value1); + private final OSPFNonPseudonode tlv2 = OSPFNonPseudonode.of(value2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } + } + + /** + * Test for IsIsNonPseudonode Tlv. + */ + public static class IsIsNonPseudonodeTest { + private final byte[] value1 = new byte[] {0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x58}; + private final byte[] value2 = new byte[] {0x19, 0x00, (byte) 0x95, 0x01, (byte) 0x90, 0x59}; + private final IsIsNonPseudonode tlv1 = IsIsNonPseudonode.of(value1); + private final IsIsNonPseudonode sameAsTlv1 = IsIsNonPseudonode.of(value1); + private final IsIsNonPseudonode tlv2 = IsIsNonPseudonode.of(value2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/As4PathTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/As4PathTest.java new file mode 100755 index 00000000..3ea56b64 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/As4PathTest.java @@ -0,0 +1,55 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for As4Path BGP Path Attribute. + */ +public class As4PathTest { + //Two scenarios as4path set and sequence + private final List as4pathSet1 = new ArrayList<>(); + private final List as4pathSeq1 = new ArrayList<>(); + private final List as4pathSet2 = new ArrayList<>(); + private final List as4pathSeq2 = new ArrayList<>(); + private final As4Path attr1 = new As4Path(as4pathSet1, null); + private final As4Path sameAsAttr1 = new As4Path(as4pathSet1, null); + private final As4Path attr2 = new As4Path(as4pathSet2, null); + private final As4Path attr3 = new As4Path(null, as4pathSeq1); + private final As4Path sameAsAttr3 = new As4Path(null, as4pathSeq1); + private final As4Path attr4 = new As4Path(null, as4pathSeq2); + + @Test + public void basics() { + as4pathSet1.add(197358); + as4pathSet1.add(12883); + as4pathSet2.add(2008989); + as4pathSeq1.add(3009009); + as4pathSeq2.add(409900); + new EqualsTester() + .addEqualityGroup(attr1, sameAsAttr1) + .addEqualityGroup(attr2) + .addEqualityGroup(attr3, sameAsAttr3) + .addEqualityGroup(attr4) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AsPathTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AsPathTest.java new file mode 100644 index 00000000..e56ec5a5 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AsPathTest.java @@ -0,0 +1,55 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for AsPath BGP Path Attribute. + */ +public class AsPathTest { + //Two scenarios aspath set and sequence + private final List aspathSet1 = new ArrayList<>(); + private final List aspathSet2 = new ArrayList<>(); + private final List aspathSeq1 = new ArrayList<>(); + private final List aspathSeq2 = new ArrayList<>(); + private final AsPath attr1 = new AsPath(aspathSet1, null); + private final AsPath sameAsAttr1 = new AsPath(aspathSet1, null); + private final AsPath attr2 = new AsPath(aspathSet2, null); + private final AsPath attr3 = new AsPath(null, aspathSeq1); + private final AsPath sameAsAttr3 = new AsPath(null, aspathSeq1); + private final AsPath attr4 = new AsPath(null, aspathSeq2); + + @Test + public void basics() { + aspathSet1.add((short) 100); + aspathSet1.add((short) 300); + aspathSet2.add((short) 200); + aspathSeq2.add((short) 400); + aspathSeq1.add((short) 300); + new EqualsTester() + .addEqualityGroup(attr1, sameAsAttr1) + .addEqualityGroup(attr2) + .addEqualityGroup(attr3, sameAsAttr3) + .addEqualityGroup(attr4) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AutonomousSystemTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AutonomousSystemTest.java new file mode 100644 index 00000000..1695583b --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/AutonomousSystemTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for AutonomousSystem Tlv. + */ +public class AutonomousSystemTest { + private final int value1 = 101; + private final int value2 = 201; + private final AutonomousSystemTlv tlv1 = AutonomousSystemTlv.of(value1); + private final AutonomousSystemTlv sameAsTlv1 = AutonomousSystemTlv.of(value1); + private final AutonomousSystemTlv tlv2 = AutonomousSystemTlv.of(value2); + + @Test + public void testEquality() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BGPLSIdentifierTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BGPLSIdentifierTest.java new file mode 100644 index 00000000..f3355d35 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BGPLSIdentifierTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for BGPLSIdentifier Tlv. + */ +public class BGPLSIdentifierTest { + private final int value1 = 8738; + private final int value2 = 13107; + private final BGPLSIdentifierTlv tlv1 = BGPLSIdentifierTlv.of(value1); + private final BGPLSIdentifierTlv sameAsTlv1 = new BGPLSIdentifierTlv(value1); + private final BGPLSIdentifierTlv tlv2 = new BGPLSIdentifierTlv(value2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPReachabilityInformationTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPReachabilityInformationTest.java new file mode 100644 index 00000000..7bea518a --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPReachabilityInformationTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for IPReachabilityInformation Tlv. + */ +public class IPReachabilityInformationTest { + private final byte[] value1 = new byte[] {(byte) 0xc0, (byte) 0xa8, 0x4d, 0x01}; + private final byte[] value2 = new byte[] {(byte) 0xc0}; + private final IPReachabilityInformationTlv tlv1 = IPReachabilityInformationTlv.of((byte) 0x17, value1, (short) 4); + private final IPReachabilityInformationTlv sameAsTlv1 = IPReachabilityInformationTlv + .of((byte) 0x17, value1, (short) 4); + private final IPReachabilityInformationTlv tlv2 = IPReachabilityInformationTlv.of((byte) 0x05, value2, (short) 1); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv4AddressTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv4AddressTest.java new file mode 100755 index 00000000..fdb71189 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv4AddressTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; +import org.onlab.packet.Ip4Address; + +import com.google.common.testing.EqualsTester; + +/** + * Test for IPv4Address Tlv. + */ +public class IPv4AddressTest { + private final Ip4Address value1 = Ip4Address.valueOf("127.0.0.1"); + private final Ip4Address value2 = Ip4Address.valueOf("127.0.0.1"); + private final IPv4AddressTlv tlv1 = IPv4AddressTlv.of(value1, (short) 259); + private final IPv4AddressTlv sameAsTlv1 = IPv4AddressTlv.of(value1, (short) 259); + private final IPv4AddressTlv tlv2 = IPv4AddressTlv.of(value2, (short) 260); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv6AddressTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv6AddressTest.java new file mode 100644 index 00000000..781935b4 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IPv6AddressTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; +import org.onlab.packet.Ip6Address; + +import com.google.common.testing.EqualsTester; + +/** + * Test for IPv6Address Tlv. + */ +public class IPv6AddressTest { + private final Ip6Address value1 = Ip6Address.valueOf("2001:db8:0:0:0:0:2:1"); + private final Ip6Address value2 = Ip6Address.valueOf("2001:db8:0:0:0:0:2:1"); + private final IPv6AddressTlv tlv1 = IPv6AddressTlv.of(value1, (short) 261); + private final IPv6AddressTlv sameAsTlv1 = IPv6AddressTlv.of(value1, (short) 261); + private final IPv6AddressTlv tlv2 = IPv6AddressTlv.of(value2, (short) 262); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsPseudonodeTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsPseudonodeTest.java new file mode 100644 index 00000000..a2a7c2b5 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/IsIsPseudonodeTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for IsIsPseudonode Tlv. + */ +public class IsIsPseudonodeTest { + private final byte[] value1 = new byte[] {0x01, 0x02, 0x01, 0x02, 0x01, 0x02}; + private final byte[] value2 = new byte[] {0x01, 0x02, 0x01, 0x02, 0x01, 0x03}; + private final IsIsPseudonode tlv1 = IsIsPseudonode.of(value1, (byte) 1); + private final IsIsPseudonode sameAsTlv1 = IsIsPseudonode.of(value1, (byte) 1); + private final IsIsPseudonode tlv2 = IsIsPseudonode.of(value2, (byte) 1); + + @Test + public void testEquality() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTest.java new file mode 100644 index 00000000..f1510b17 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for LinkLocalRemoteIdentifiers Tlv. + */ +public class LinkLocalRemoteIdentifiersTest { + private final int value1 = 0x12101010; + private final int value2 = 0x12101012; + private final LinkLocalRemoteIdentifiersTlv tlv1 = LinkLocalRemoteIdentifiersTlv.of(value1, value2); + private final LinkLocalRemoteIdentifiersTlv sameAsTlv1 = LinkLocalRemoteIdentifiersTlv.of(value1, value2); + private final LinkLocalRemoteIdentifiersTlv tlv2 = LinkLocalRemoteIdentifiersTlv.of(value2, value1); + + @Test + public void testEquality() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/NextHopTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/NextHopTest.java new file mode 100755 index 00000000..799419a1 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/NextHopTest.java @@ -0,0 +1,40 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; +import org.onlab.packet.Ip4Address; + +import com.google.common.testing.EqualsTester; + +/** + * Test for NextHop BGP Path Attribute. + */ +public class NextHopTest { + private final Ip4Address value1 = Ip4Address.valueOf("12.12.12.12"); + private final Ip4Address value2 = Ip4Address.valueOf("12.12.12.13"); + private final NextHop attr1 = new NextHop(value1); + private final NextHop sameAsAttr1 = new NextHop(value1); + private final NextHop attr2 = new NextHop(value2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(attr1, sameAsAttr1) + .addEqualityGroup(attr2) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OriginTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OriginTest.java new file mode 100644 index 00000000..da7b5570 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OriginTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for Origin BGP Path Attribute. + */ +public class OriginTest { + private final byte value1 = 0x01; + private final byte value2 = 0x02; + private final Origin attr1 = new Origin(value1); + private final Origin sameAsAttr1 = new Origin(value1); + private final Origin attr2 = new Origin(value2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(attr1, sameAsAttr1) + .addEqualityGroup(attr2) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfPseudonodeTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfPseudonodeTest.java new file mode 100644 index 00000000..a8002311 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfPseudonodeTest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; +import org.onlab.packet.Ip4Address; + +import com.google.common.testing.EqualsTester; + +/** + * Test for OSPFPseudonode Tlv. + */ +public class OspfPseudonodeTest { + private final int value1 = 0xc3223409; + private final int value2 = 0xc3223406; + private final Ip4Address drInterface1 = Ip4Address.valueOf(0xaf91e01); + private final Ip4Address drInterface2 = Ip4Address.valueOf(0xaf91e02); + private final OSPFPseudonode tlv1 = OSPFPseudonode.of(value1, drInterface1); + private final OSPFPseudonode sameAsTlv1 = OSPFPseudonode.of(value1, drInterface1); + private final OSPFPseudonode tlv2 = OSPFPseudonode.of(value2, drInterface2); + + @Test + public void testEquality() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfRouteTypeTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfRouteTypeTest.java new file mode 100644 index 00000000..859bdbe5 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/OspfRouteTypeTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for OSPFRouteType Tlv. + */ +public class OspfRouteTypeTest { + private final byte value1 = 5; + private final byte value2 = 4; + private final OSPFRouteTypeTlv tlv1 = OSPFRouteTypeTlv.of(value1); + private final OSPFRouteTypeTlv sameAsTlv1 = OSPFRouteTypeTlv.of(value1); + private final OSPFRouteTypeTlv tlv2 = OSPFRouteTypeTlv.of(value2); + + @Test + public void testEquality() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlvTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlvTest.java new file mode 100644 index 00000000..4efb7f5b --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlvTest.java @@ -0,0 +1,50 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types.attr; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for BGP attribute node flag. + */ +public class BgpAttrNodeFlagBitTlvTest { + + private final boolean bOverloadBit = true; + private final boolean bAttachedBit = true; + private final boolean bExternalBit = true; + private final boolean bABRBit = true; + + private final boolean bOverloadBit1 = false; + private final boolean bAttachedBit1 = false; + private final boolean bExternalBit1 = false; + private final boolean bABRBit1 = false; + + private final BgpAttrNodeFlagBitTlv data = BgpAttrNodeFlagBitTlv + .of(bOverloadBit, bAttachedBit, bExternalBit, bABRBit); + private final BgpAttrNodeFlagBitTlv sameAsData = BgpAttrNodeFlagBitTlv + .of(bOverloadBit, bAttachedBit, bExternalBit, bABRBit); + private final BgpAttrNodeFlagBitTlv diffData = BgpAttrNodeFlagBitTlv + .of(bOverloadBit1, bAttachedBit1, bExternalBit1, bABRBit1); + + @Test + public void basics() { + + new EqualsTester().addEqualityGroup(data, sameAsData) + .addEqualityGroup(diffData).testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6Test.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6Test.java new file mode 100644 index 00000000..16ca58ee --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpAttrRouterIdV6Test.java @@ -0,0 +1,49 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types.attr; + +import org.junit.Test; +import org.onlab.packet.Ip6Address; + +import com.google.common.testing.EqualsTester; + +/** + * Test for BGP attribute node router ID. + */ +public class BgpAttrRouterIdV6Test { + + private final short sType = 1; + private final Ip6Address ip6RouterId = Ip6Address + .valueOf("2001:0db8:0a0b:12f0:0000:0000:0000:0001"); + + private final short sType1 = 2; + private final Ip6Address ip6RouterId1 = Ip6Address + .valueOf("2004:0db8:0a0b:12f0:0000:0000:0000:0004"); + + private final BgpAttrRouterIdV6 data = BgpAttrRouterIdV6.of(ip6RouterId, + sType); + private final BgpAttrRouterIdV6 sameAsData = BgpAttrRouterIdV6 + .of(ip6RouterId, sType); + private final BgpAttrRouterIdV6 diffData = BgpAttrRouterIdV6 + .of(ip6RouterId1, sType1); + + @Test + public void basics() { + + new EqualsTester().addEqualityGroup(data, sameAsData) + .addEqualityGroup(diffData).testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetricTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetricTest.java new file mode 100644 index 00000000..ef1cfcea --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrIgpMetricTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types.attr; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for BGP link IGP metric attribute. + */ +public class BgpLinkAttrIgpMetricTest { + private final int val = 0x010203; + private final int valLen = 3; + private final int val1 = 0x01020304; + private final int val1Len = 4; + + private final BgpLinkAttrIgpMetric data = BgpLinkAttrIgpMetric.of(val, + valLen); + private final BgpLinkAttrIgpMetric sameAsData = BgpLinkAttrIgpMetric + .of(val, valLen); + private final BgpLinkAttrIgpMetric diffData = BgpLinkAttrIgpMetric + .of(val1, val1Len); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(data, sameAsData) + .addEqualityGroup(diffData).testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMaskTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMaskTest.java new file mode 100644 index 00000000..c0d7f986 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrMplsProtocolMaskTest.java @@ -0,0 +1,42 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types.attr; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for MPLS protocol mask attribute. + */ +public class BgpLinkAttrMplsProtocolMaskTest { + private final boolean val = true; + private final boolean val1 = false; + + private final BgpLinkAttrMplsProtocolMask data = BgpLinkAttrMplsProtocolMask + .of(val, val); + private final BgpLinkAttrMplsProtocolMask sameAsData = BgpLinkAttrMplsProtocolMask + .of(val, val); + private final BgpLinkAttrMplsProtocolMask diffData = BgpLinkAttrMplsProtocolMask + .of(val, val1); + + @Test + public void basics() { + + new EqualsTester().addEqualityGroup(data, sameAsData) + .addEqualityGroup(diffData).testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionTypeTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionTypeTest.java new file mode 100644 index 00000000..2fb76352 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpLinkAttrProtectionTypeTest.java @@ -0,0 +1,56 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types.attr; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for MPLS protocol mask attribute. + */ +public class BgpLinkAttrProtectionTypeTest { + boolean bExtraTraffic = true; + boolean bUnprotected = true; + boolean bShared = true; + boolean bDedOneIstoOne = true; + boolean bDedOnePlusOne = true; + boolean bEnhanced = true; + + boolean bExtraTraffic1 = false; + boolean bUnprotected1 = false; + boolean bShared1 = false; + boolean bDedOneIstoOne1 = false; + boolean bDedOnePlusOne1 = false; + boolean bEnhanced1 = false; + + private final BgpLinkAttrProtectionType data = BgpLinkAttrProtectionType + .of(bExtraTraffic, bUnprotected, bShared, bDedOneIstoOne, + bDedOnePlusOne, bEnhanced); + private final BgpLinkAttrProtectionType sameAsData = BgpLinkAttrProtectionType + .of(bExtraTraffic, bUnprotected, bShared, bDedOneIstoOne, + bDedOnePlusOne, bEnhanced); + private final BgpLinkAttrProtectionType diffData = BgpLinkAttrProtectionType + .of(bExtraTraffic1, bUnprotected1, bShared1, bDedOneIstoOne1, + bDedOnePlusOne1, bEnhanced1); + + @Test + public void basics() { + + new EqualsTester().addEqualityGroup(data, sameAsData) + .addEqualityGroup(diffData).testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlagsTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlagsTest.java new file mode 100644 index 00000000..535518f8 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrIgpFlagsTest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types.attr; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for BGP prefix IGP Flag attribute. + */ +public class BgpPrefixAttrIgpFlagsTest { + + private final boolean bisisUpDownBit = true; + private final boolean bOspfNoUnicastBit = true; + private final boolean bOspfLclAddrBit = true; + private final boolean bOspfNSSABit = true; + + private final boolean bisisUpDownBit1 = false; + private final boolean bOspfNoUnicastBit1 = false; + private final boolean bOspfLclAddrBit1 = false; + private final boolean bOspfNSSABit1 = false; + + private final BgpPrefixAttrIgpFlags data = BgpPrefixAttrIgpFlags + .of(bisisUpDownBit, bOspfNoUnicastBit, bOspfLclAddrBit, + bOspfNSSABit); + private final BgpPrefixAttrIgpFlags sameAsData = BgpPrefixAttrIgpFlags + .of(bisisUpDownBit, bOspfNoUnicastBit, bOspfLclAddrBit, + bOspfNSSABit); + private final BgpPrefixAttrIgpFlags diffData = BgpPrefixAttrIgpFlags + .of(bisisUpDownBit1, bOspfNoUnicastBit1, bOspfLclAddrBit1, + bOspfNSSABit1); + + @Test + public void basics() { + + new EqualsTester().addEqualityGroup(data, sameAsData) + .addEqualityGroup(diffData).testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetricTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetricTest.java new file mode 100644 index 00000000..fe6079fd --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrMetricTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types.attr; + +import org.junit.Test; + +import com.google.common.testing.EqualsTester; + +/** + * Test for BGP prefix metric attribute. + */ +public class BgpPrefixAttrMetricTest { + private final int val = 1111; + private final int val1 = 2222; + + private final BgpPrefixAttrMetric data = BgpPrefixAttrMetric.of(val); + private final BgpPrefixAttrMetric sameAsData = BgpPrefixAttrMetric.of(val); + private final BgpPrefixAttrMetric diffData = BgpPrefixAttrMetric.of(val1); + + @Test + public void basics() { + + new EqualsTester().addEqualityGroup(data, sameAsData) + .addEqualityGroup(diffData).testEquals(); + } +} diff --git a/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddrTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddrTest.java new file mode 100644 index 00000000..f6fe39f8 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/attr/BgpPrefixAttrOspfFwdAddrTest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.onosproject.bgpio.types.attr; + +import org.junit.Test; +import org.onlab.packet.Ip4Address; +import org.onlab.packet.Ip6Address; + +import com.google.common.testing.EqualsTester; + +/** + * Test for BGP prefix metric attribute. + */ +public class BgpPrefixAttrOspfFwdAddrTest { + + private final short lsAttrLength = 4; + private final Ip4Address ip4RouterId = Ip4Address.valueOf("192.168.1.1"); + private final Ip6Address ip6RouterId = Ip6Address + .valueOf("2001:0db8:0a0b:12f0:0000:0000:0000:0001"); + + private final short lsAttrLength1 = 16; + private final Ip4Address ip4RouterId1 = Ip4Address.valueOf("192.168.1.2"); + private final Ip6Address ip6RouterId1 = Ip6Address + .valueOf("1002:0db8:0a0b:12f0:0000:0000:0000:0002"); + + private final BgpPrefixAttrOspfFwdAddr data = BgpPrefixAttrOspfFwdAddr + .of(lsAttrLength, ip4RouterId, ip6RouterId); + private final BgpPrefixAttrOspfFwdAddr sameAsData = BgpPrefixAttrOspfFwdAddr + .of(lsAttrLength, ip4RouterId, ip6RouterId); + private final BgpPrefixAttrOspfFwdAddr diffData = BgpPrefixAttrOspfFwdAddr + .of(lsAttrLength1, ip4RouterId1, ip6RouterId1); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(data, sameAsData) + .addEqualityGroup(diffData).testEquals(); + } +} -- cgit 1.2.3-korg