From b34f82bf11934fc6b938ef997d536a7ccea76c36 Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Thu, 5 Nov 2015 14:00:42 -0800 Subject: Updates ONOS tree to checkin id ca9cc8e28eba18da77f4fa021fb7c3a3f76e5d44 upstream. Change-Id: I49f8e41733afea8101ec50c0102213c8d18949ae Signed-off-by: Ashlee Young --- .../org/onosproject/bgprouter/NextHopGroupKey.java | 2 +- .../org/onosproject/pim/cli/PIMShowCommand.java | 22 +- .../org/onosproject/pim/impl/PIMComponent.java | 121 +- .../org/onosproject/pim/impl/PIMInterface.java | 339 ++++ .../org/onosproject/pim/impl/PIMInterfaces.java | 260 +++ .../onosproject/pim/impl/PIMInterfacesCodec.java | 96 ++ .../java/org/onosproject/pim/impl/PIMNeighbor.java | 52 +- .../org/onosproject/pim/impl/PIMNeighbors.java | 395 ----- .../onosproject/pim/impl/PIMNeighborsCodec.java | 97 -- .../org/onosproject/pim/impl/PIMPacketHandler.java | 229 +++ .../java/org/onosproject/pim/impl/PIMTimer.java | 19 + .../org/onosproject/routing/bgp/BgpRouteEntry.java | 2 +- .../org/onosproject/sdnip/IntentSynchronizer.java | 42 +- .../onosproject/segmentrouting/DefaultTunnel.java | 4 +- .../segmentrouting/SegmentRoutingManager.java | 68 +- .../java/org/onosproject/vtnrsc/BindingHostId.java | 2 +- .../org/onosproject/vtnrsc/FlowClassifierId.java | 7 +- .../org/onosproject/vtnrsc/PhysicalNetwork.java | 2 +- .../java/org/onosproject/vtnrsc/PortChainId.java | 22 +- .../org/onosproject/vtnrsc/PortPairGroupId.java | 23 +- .../java/org/onosproject/vtnrsc/PortPairId.java | 20 +- .../java/org/onosproject/vtnrsc/SecurityGroup.java | 2 +- .../org/onosproject/vtnrsc/SegmentationId.java | 2 +- .../main/java/org/onosproject/vtnrsc/SubnetId.java | 2 +- .../main/java/org/onosproject/vtnrsc/TenantId.java | 2 +- .../org/onosproject/vtnrsc/TenantNetworkId.java | 2 +- .../java/org/onosproject/vtnrsc/VirtualPortId.java | 2 +- .../flowClassifier/impl/FlowClassifierManager.java | 32 +- .../vtnrsc/portchain/impl/PortChainManager.java | 146 ++ .../vtnrsc/portchain/impl/package-info.java | 20 + .../vtnrsc/portpair/PortPairService.java | 80 + .../vtnrsc/portpair/impl/PortPairManager.java | 146 ++ .../vtnrsc/portpair/impl/package-info.java | 20 + .../onosproject/vtnrsc/portpair/package-info.java | 20 + .../portpairgroup/impl/PortPairGroupManager.java | 146 ++ .../vtnrsc/portpairgroup/impl/package-info.java | 20 + .../vtnrsc/web/FlowClassifierCodec.java | 134 -- .../org/onosproject/vtnrsc/web/package-info.java | 20 - .../flowclassifier/FlowClassifierIdTest.java | 8 +- .../vtnrsc/portchain/PortChainIdTest.java | 65 + .../vtnrsc/portpair/PortPairIdTest.java | 64 + .../vtnrsc/portpairgroup/PortPairGroupIdTest.java | 66 + .../resources/FlowClassifierWebResource.java | 8 +- .../vtnweb/resources/PortChainWebResource.java | 157 ++ .../vtnweb/resources/PortPairGroupWebResource.java | 163 ++ .../vtnweb/resources/PortPairWebResource.java | 161 ++ .../vtnweb/web/FlowClassifierCodec.java | 134 ++ .../org/onosproject/vtnweb/web/PortChainCodec.java | 6 +- .../org/onosproject/vtnweb/web/PortPairCodec.java | 94 ++ .../onosproject/vtnweb/web/PortPairGroupCodec.java | 95 ++ .../vtn/vtnweb/src/main/webapp/WEB-INF/web.xml | 4 + .../onosproject/vtnweb/web/PortPairCodecTest.java | 94 ++ .../onosproject/vtnweb/web/SfcCodecContext.java | 77 + .../org/onosproject/vtnweb/web/portPair.json | 9 + .../onosproject/bgp/controller/BGPConnectPeer.java | 28 + .../org/onosproject/bgpio/protocol/BGPOpenMsg.java | 28 - .../protocol/link_state/BGPLinkLSIdentifier.java | 252 +++ .../bgpio/protocol/ver4/BGPOpenMsgVer4.java | 24 +- .../onosproject/bgpio/types/IPv4AddressTlv.java | 128 ++ .../onosproject/bgpio/types/IPv6AddressTlv.java | 128 ++ .../bgpio/types/LinkLocalRemoteIdentifiersTlv.java | 131 ++ .../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 ++++ .../bgp/BgpLinkAttrMplsProtocolMaskTest.java | 43 + .../onosproject/bgp/BgpNotificationMsgTest.java | 228 +++ .../onosproject/bgp/BgpPrefixAttrMetricTest.java | 40 + .../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/OriginTest.java | 40 + .../org/onosproject/bgp/OspfNonPseudonodeTest.java | 40 + .../org/onosproject/bgp/OspfPseudonodeTest.java | 43 + .../org/onosproject/bgp/OspfRouteTypeTest.java | 40 + .../bgp/controller/impl/BGPMessageDecoder.java | 15 +- .../cli/net/ConnectivityIntentCommand.java | 14 +- .../org/onosproject/app/ApplicationService.java | 7 + .../java/org/onosproject/cfg/ConfigProperty.java | 2 +- .../onosproject/cluster/DefaultControllerNode.java | 5 +- .../main/java/org/onosproject/cluster/NodeId.java | 2 +- .../java/org/onosproject/core/CoreService.java | 17 +- .../org/onosproject/core/DefaultApplicationId.java | 2 +- .../java/org/onosproject/core/DefaultGroupId.java | 2 +- .../main/java/org/onosproject/core/Version.java | 2 +- .../main/java/org/onosproject/net/DefaultPath.java | 2 +- .../main/java/org/onosproject/net/DeviceId.java | 2 +- .../org/onosproject/net/behaviour/BridgeName.java | 2 +- .../net/flow/DefaultTrafficTreatment.java | 7 +- .../org/onosproject/net/flow/TrafficTreatment.java | 9 + .../net/flow/instructions/Instructions.java | 34 +- .../instructions/L0ModificationInstruction.java | 2 +- .../instructions/L1ModificationInstruction.java | 2 +- .../org/onosproject/net/group/DefaultGroup.java | 2 +- .../net/intent/constraint/BandwidthConstraint.java | 2 +- .../net/intent/constraint/LambdaConstraint.java | 2 +- .../net/intent/constraint/LatencyConstraint.java | 2 +- .../net/intent/constraint/ObstacleConstraint.java | 2 +- .../net/intent/constraint/WaypointConstraint.java | 2 +- .../resource/link/BandwidthResourceAllocation.java | 2 +- .../resource/link/BandwidthResourceRequest.java | 2 +- .../resource/link/LambdaResourceAllocation.java | 2 +- .../resource/link/MplsLabelResourceAllocation.java | 2 +- .../org/onosproject/net/topology/ClusterId.java | 2 +- .../net/topology/DefaultTopologyEdge.java | 5 +- .../net/topology/DefaultTopologyVertex.java | 2 +- .../store/service/WallClockTimestamp.java | 2 +- .../src/main/java/org/onosproject/ui/UiView.java | 2 +- .../org/onosproject/ui/topo/PropertyPanel.java | 26 +- .../onosproject/app/ApplicationServiceAdapter.java | 4 + .../org/onosproject/core/CoreServiceAdapter.java | 7 +- .../onosproject/net/intent/IntentTestsMocks.java | 5 +- .../org/onosproject/ui/topo/PropertyPanelTest.java | 25 +- .../store/trivial/SystemClockTimestamp.java | 2 +- .../onosproject/app/impl/ApplicationManager.java | 30 +- .../org/onosproject/core/impl/CoreManager.java | 21 +- .../net/newresource/impl/ResourceManager.java | 3 - .../net/newresource/impl/ResourceRegistrar.java | 2 +- .../app/impl/ApplicationManagerTest.java | 13 +- .../onosproject/store/impl/LogicalTimestamp.java | 2 +- .../onosproject/store/intent/impl/PartitionId.java | 2 +- .../newresource/impl/ConsistentResourceStore.java | 154 +- .../resource/impl/ConsistentLinkResourceStore.java | 11 +- .../driver/pipeline/CpqdOFDPA2Pipeline.java | 102 +- .../driver/pipeline/OFDPA2Pipeline.java | 7 +- .../incubator/net/domain/DomainEdge.java | 2 +- .../incubator/net/tunnel/OpticalLogicId.java | 2 +- .../net/virtual/DefaultVirtualDevice.java | 2 +- .../incubator/net/virtual/TenantId.java | 2 +- .../net/mcast/impl/MulticastRouteManagerTest.java | 53 +- .../openflow/controller/impl/Controller.java | 23 +- .../org/onosproject/openflow/ChannelAdapter.java | 159 ++ .../openflow/ChannelHandlerContextAdapter.java | 77 + .../org/onosproject/openflow/OfMessageAdapter.java | 54 + .../controller/impl/OFMessageDecoderTest.java | 84 + .../controller/impl/OFMessageEncoderTest.java | 88 + framework/src/onos/openflow/pom.xml | 18 + .../ovsdb/controller/OvsdbBridgeName.java | 2 +- .../ovsdb/controller/OvsdbDatapathId.java | 2 +- .../onosproject/ovsdb/controller/OvsdbEvent.java | 4 +- .../onosproject/ovsdb/controller/OvsdbIfaceId.java | 2 +- .../onosproject/ovsdb/controller/OvsdbNodeId.java | 8 +- .../ovsdb/controller/OvsdbPortName.java | 2 +- .../ovsdb/controller/OvsdbPortNumber.java | 2 +- .../ovsdb/controller/OvsdbPortType.java | 11 +- .../ovsdb/controller/OvsdbTunnelName.java | 2 +- .../onosproject/ovsdb/rfc/message/TableUpdate.java | 2 +- .../ovsdb/rfc/message/TableUpdates.java | 2 +- .../onosproject/ovsdb/rfc/notation/OvsdbMap.java | 2 +- .../onosproject/ovsdb/rfc/notation/OvsdbSet.java | 2 +- .../org/onosproject/ovsdb/rfc/notation/UUID.java | 2 +- .../tableservice/AbstractOvsdbTableService.java | 8 +- .../pcepio/AdministrativeGroupTlvTest.java | 38 - .../pcepio/AutonomousSystemTlvTest.java | 38 - .../onosproject/pcepio/BGPLSidentifierTlvTest.java | 38 - .../onosproject/pcepio/GmplsCapabilityTlvTest.java | 38 - .../org/onosproject/pcepio/IGPMetricTlvTest.java | 40 - .../pcepio/IPv4InterfaceAddressTlvTest.java | 39 - .../pcepio/IPv4NeighborAddressTlvTest.java | 39 - .../org/onosproject/pcepio/IPv4SubObjectTest.java | 39 - .../pcepio/IPv4TERouterIdOfLocalNodeTlvTest.java | 39 - .../pcepio/IPv4TERouterIdOfRemoteNodeTlvTest.java | 39 - .../pcepio/IPv6InterfaceAddressTlvTest.java | 44 - .../pcepio/IPv6NeighborAddressTlvTest.java | 44 - .../org/onosproject/pcepio/IPv6SubObjectTest.java | 41 - .../pcepio/IPv6TERouterIdofLocalNodeTlvTest.java | 44 - .../pcepio/IPv6TERouterIdofRemoteNodeTlvTest.java | 44 - .../pcepio/ISISAreaIdentifierTlvTest.java | 42 - .../org/onosproject/pcepio/LabelSubObjectTest.java | 39 - .../pcepio/LinkLocalRemoteIdentifiersTlvTest.java | 39 - .../org/onosproject/pcepio/LinkNameTlvTest.java | 41 - .../pcepio/LinkProtectionTypeTlvTest.java | 41 - .../pcepio/LocalTENodeDescriptorsTlvTest.java | 56 - .../pcepio/MPLSProtocolMaskTlvTest.java | 41 - .../pcepio/MaximumLinkBandwidthTlvTest.java | 41 - .../MaximumReservableLinkBandwidthTlvTest.java | 41 - .../pcepio/NexthopIPv4addressTlvTest.java | 39 - .../pcepio/NexthopIPv6addressTlvTest.java | 43 - .../pcepio/NexthopUnnumberedIPv4IDTlvTest.java | 39 - .../onosproject/pcepio/NodeFlagBitsTlvTest.java | 41 - .../org/onosproject/pcepio/NodeNameTlvTest.java | 41 - .../onosproject/pcepio/OSPFareaIDsubTlvTest.java | 38 - .../pcepio/OpaqueLinkAttributeTlvTest.java | 41 - .../onosproject/pcepio/PathKeySubObjectTest.java | 39 - .../onosproject/pcepio/PathSetupTypeTlvTest.java | 36 - .../onosproject/pcepio/PceccCapabilityTlvTest.java | 41 - .../org/onosproject/pcepio/PcepCloseMsgTest.java | 60 - .../org/onosproject/pcepio/PcepErrorMsgTest.java | 739 --------- .../onosproject/pcepio/PcepInitiateMsgExtTest.java | 1686 -------------------- .../onosproject/pcepio/PcepInitiateMsgTest.java | 1335 ---------------- .../onosproject/pcepio/PcepKeepaliveMsgTest.java | 63 - .../onosproject/pcepio/PcepLabelUpdateMsgTest.java | 406 ----- .../pcepio/PcepNaiIpv4AdjacencyTest.java | 38 - .../onosproject/pcepio/PcepNaiIpv4NodeIdTest.java | 36 - .../pcepio/PcepNaiIpv6AdjacencyTest.java | 39 - .../onosproject/pcepio/PcepNaiIpv6NodeIdTest.java | 45 - .../pcepio/PcepNaiUnnumberedAdjacencyIpv4Test.java | 51 - .../org/onosproject/pcepio/PcepOpenMsgTest.java | 562 ------- .../onosproject/pcepio/PcepReportMsgExtTest.java | 221 --- .../org/onosproject/pcepio/PcepReportMsgTest.java | 1601 ------------------- .../onosproject/pcepio/PcepTEReportMsgTest.java | 1600 ------------------- .../onosproject/pcepio/PcepUpdateMsgExtTest.java | 1275 --------------- .../org/onosproject/pcepio/PcepUpdateMsgTest.java | 1427 ----------------- .../pcepio/RemoteTENodeDescriptorsTlvTest.java | 57 - .../org/onosproject/pcepio/RouterIDSubTlvTest.java | 44 - .../onosproject/pcepio/RoutingUniverseTlvTest.java | 37 - .../pcepio/SharedRiskLinkGroupTlvTest.java | 43 - .../org/onosproject/pcepio/SrEroSubObjectTest.java | 61 - .../pcepio/StatefulIPv4LspIdentidiersTlvTest.java | 57 - .../pcepio/StatefulLspDbVerTlvTest.java | 37 - .../pcepio/StatefulLspErrorCodeTlvTest.java | 32 - .../pcepio/StatefulPceCapabilityTlvTest.java | 35 - .../pcepio/SymbolicPathNameTlvTest.java | 45 - .../onosproject/pcepio/TEDefaultMetricTlvTest.java | 36 - .../pcepio/TELinkAttributesTlvTest.java | 59 - .../pcepio/TELinkDescriptorsTlvTest.java | 57 - .../pcepio/TENodeAttributesTlvTest.java | 59 - .../onosproject/pcepio/TedCapabilityTlvTest.java | 36 - .../pcepio/UnreservedBandwidthTlvTest.java | 37 - .../pcepio/protocol/PcepCloseMsgTest.java | 56 + .../pcepio/protocol/PcepErrorMsgTest.java | 735 +++++++++ .../pcepio/protocol/PcepInitiateMsgExtTest.java | 1683 +++++++++++++++++++ .../pcepio/protocol/PcepInitiateMsgTest.java | 1331 +++++++++++++++ .../pcepio/protocol/PcepKeepaliveMsgTest.java | 59 + .../pcepio/protocol/PcepLabelUpdateMsgTest.java | 402 +++++ .../pcepio/protocol/PcepOpenMsgTest.java | 558 +++++++ .../pcepio/protocol/PcepReportMsgExtTest.java | 218 +++ .../pcepio/protocol/PcepReportMsgTest.java | 1597 ++++++++++++++++++ .../pcepio/protocol/PcepTEReportMsgTest.java | 1596 ++++++++++++++++++ .../pcepio/protocol/PcepUpdateMsgExtTest.java | 1269 +++++++++++++++ .../pcepio/protocol/PcepUpdateMsgTest.java | 1423 +++++++++++++++++ .../pcepio/types/AdministrativeGroupTlvTest.java | 36 + .../pcepio/types/AutonomousSystemTlvTest.java | 36 + .../pcepio/types/BGPLSidentifierTlvTest.java | 36 + .../pcepio/types/GmplsCapabilityTlvTest.java | 36 + .../onosproject/pcepio/types/IGPMetricTlvTest.java | 38 + .../pcepio/types/IPv4InterfaceAddressTlvTest.java | 37 + .../pcepio/types/IPv4NeighborAddressTlvTest.java | 37 + .../pcepio/types/IPv4SubObjectTest.java | 37 + .../types/IPv4TERouterIdOfLocalNodeTlvTest.java | 37 + .../types/IPv4TERouterIdOfRemoteNodeTlvTest.java | 37 + .../pcepio/types/IPv6InterfaceAddressTlvTest.java | 42 + .../pcepio/types/IPv6NeighborAddressTlvTest.java | 42 + .../pcepio/types/IPv6SubObjectTest.java | 39 + .../types/IPv6TERouterIdofLocalNodeTlvTest.java | 42 + .../types/IPv6TERouterIdofRemoteNodeTlvTest.java | 42 + .../pcepio/types/ISISAreaIdentifierTlvTest.java | 40 + .../pcepio/types/LabelSubObjectTest.java | 37 + .../types/LinkLocalRemoteIdentifiersTlvTest.java | 37 + .../onosproject/pcepio/types/LinkNameTlvTest.java | 39 + .../pcepio/types/LinkProtectionTypeTlvTest.java | 39 + .../types/LocalTENodeDescriptorsTlvTest.java | 50 + .../pcepio/types/MPLSProtocolMaskTlvTest.java | 39 + .../pcepio/types/MaximumLinkBandwidthTlvTest.java | 39 + .../MaximumReservableLinkBandwidthTlvTest.java | 39 + .../pcepio/types/NexthopIPv4addressTlvTest.java | 37 + .../pcepio/types/NexthopIPv6addressTlvTest.java | 41 + .../types/NexthopUnnumberedIPv4IDTlvTest.java | 37 + .../pcepio/types/NodeFlagBitsTlvTest.java | 39 + .../onosproject/pcepio/types/NodeNameTlvTest.java | 39 + .../pcepio/types/OSPFareaIDsubTlvTest.java | 36 + .../pcepio/types/OpaqueLinkAttributeTlvTest.java | 39 + .../pcepio/types/PathKeySubObjectTest.java | 37 + .../pcepio/types/PathSetupTypeTlvTest.java | 34 + .../pcepio/types/PceccCapabilityTlvTest.java | 39 + .../pcepio/types/PcepNaiIpv4AdjacencyTest.java | 36 + .../pcepio/types/PcepNaiIpv4NodeIdTest.java | 34 + .../pcepio/types/PcepNaiIpv6AdjacencyTest.java | 37 + .../pcepio/types/PcepNaiIpv6NodeIdTest.java | 43 + .../types/PcepNaiUnnumberedAdjacencyIpv4Test.java | 49 + .../types/RemoteTENodeDescriptorsTlvTest.java | 52 + .../pcepio/types/RouterIDSubTlvTest.java | 42 + .../pcepio/types/RoutingUniverseTlvTest.java | 35 + .../pcepio/types/SharedRiskLinkGroupTlvTest.java | 41 + .../pcepio/types/SrEroSubObjectTest.java | 59 + .../types/StatefulIPv4LspIdentidiersTlvTest.java | 55 + .../pcepio/types/StatefulLspDbVerTlvTest.java | 35 + .../pcepio/types/StatefulLspErrorCodeTlvTest.java | 31 + .../pcepio/types/StatefulPceCapabilityTlvTest.java | 34 + .../pcepio/types/SymbolicPathNameTlvTest.java | 43 + .../pcepio/types/TEDefaultMetricTlvTest.java | 34 + .../pcepio/types/TELinkAttributesTlvTest.java | 54 + .../pcepio/types/TELinkDescriptorsTlvTest.java | 52 + .../pcepio/types/TENodeAttributesTlvTest.java | 54 + .../pcepio/types/TedCapabilityTlvTest.java | 34 + .../pcepio/types/UnreservedBandwidthTlvTest.java | 36 + .../provider/of/flow/impl/FlowEntryBuilder.java | 6 +- .../provider/of/flow/impl/FlowModBuilderVer10.java | 12 + framework/src/onos/tools/test/scenarios/fast.xml | 2 +- .../main/java/org/onlab/jdvue/DependencyCycle.java | 2 +- .../java/org/onlab/graph/DisjointPathPair.java | 10 +- .../org/onlab/graph/DisjointPathPair.java.orig | 169 -- .../src/main/java/org/onlab/util/Frequency.java | 4 +- .../java/org/onlab/graph/DisjointPathPairTest.java | 43 + .../src/test/java/org/onlab/graph/TestVertex.java | 2 +- .../src/main/java/org/onlab/stc/Coordinator.java | 34 +- .../stc/src/main/java/org/onlab/stc/Step.java | 2 +- 303 files changed, 19069 insertions(+), 14719 deletions(-) create mode 100644 framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java create mode 100644 framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaces.java create mode 100644 framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfacesCodec.java delete mode 100644 framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighbors.java delete mode 100644 framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighborsCodec.java create mode 100644 framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMPacketHandler.java create mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/PortChainManager.java create mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/package-info.java create mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairService.java create mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/PortPairManager.java create mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/package-info.java create mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/package-info.java create mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/PortPairGroupManager.java create mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/package-info.java delete mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FlowClassifierCodec.java delete mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java create mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java create mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/PortPairIdTest.java create mode 100644 framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java create mode 100644 framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java create mode 100644 framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairGroupWebResource.java create mode 100644 framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java create mode 100644 framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java create mode 100644 framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairCodec.java create mode 100644 framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairGroupCodec.java create mode 100644 framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairCodecTest.java create mode 100644 framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/SfcCodecContext.java create mode 100644 framework/src/onos/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portPair.json create mode 100755 framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPConnectPeer.java create mode 100755 framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPLinkLSIdentifier.java create mode 100644 framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java create mode 100644 framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java create mode 100644 framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AreaIdTest.java create mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/As4PathTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AsPathTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AutonomousSystemTest.java create mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPKeepaliveMsgTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPLSIdentifierTest.java create mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPOpenMsgTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrMplsProtocolMaskTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpNotificationMsgTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrMetricTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPReachabilityInformationTest.java create mode 100755 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv4AddressTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv6AddressTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsNonPseudonodeTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsPseudonodeTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/LinkLocalRemoteIdentifiersTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OriginTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfNonPseudonodeTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfPseudonodeTest.java create mode 100644 framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfRouteTypeTest.java create mode 100644 framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelAdapter.java create mode 100644 framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelHandlerContextAdapter.java create mode 100644 framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/OfMessageAdapter.java create mode 100644 framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java create mode 100644 framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageEncoderTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/AdministrativeGroupTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/AutonomousSystemTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/BGPLSidentifierTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/GmplsCapabilityTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IGPMetricTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4InterfaceAddressTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4NeighborAddressTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4SubObjectTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfLocalNodeTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfRemoteNodeTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6InterfaceAddressTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6NeighborAddressTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6SubObjectTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofLocalNodeTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofRemoteNodeTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/ISISAreaIdentifierTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LabelSubObjectTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkLocalRemoteIdentifiersTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkNameTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkProtectionTypeTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LocalTENodeDescriptorsTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MPLSProtocolMaskTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumLinkBandwidthTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumReservableLinkBandwidthTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv4addressTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv6addressTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopUnnumberedIPv4IDTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeFlagBitsTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeNameTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/OSPFareaIDsubTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/OpaqueLinkAttributeTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathKeySubObjectTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathSetupTypeTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PceccCapabilityTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepCloseMsgTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepErrorMsgTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgExtTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepKeepaliveMsgTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepLabelUpdateMsgTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4AdjacencyTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4NodeIdTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6AdjacencyTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6NodeIdTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiUnnumberedAdjacencyIpv4Test.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepOpenMsgTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepReportMsgExtTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepReportMsgTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepTEReportMsgTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgExtTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RemoteTENodeDescriptorsTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RouterIDSubTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RoutingUniverseTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SharedRiskLinkGroupTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SrEroSubObjectTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulIPv4LspIdentidiersTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspDbVerTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspErrorCodeTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulPceCapabilityTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SymbolicPathNameTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TEDefaultMetricTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkAttributesTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkDescriptorsTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TENodeAttributesTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TedCapabilityTlvTest.java delete mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/UnreservedBandwidthTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepTEReportMsgTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BGPLSidentifierTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IGPMetricTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OSPFareaIDsubTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RouterIDSubTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkAttributesTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkDescriptorsTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TENodeAttributesTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TedCapabilityTlvTest.java create mode 100644 framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthTlvTest.java delete mode 100644 framework/src/onos/utils/misc/src/main/java/org/onlab/graph/DisjointPathPair.java.orig create mode 100644 framework/src/onos/utils/misc/src/test/java/org/onlab/graph/DisjointPathPairTest.java (limited to 'framework/src') diff --git a/framework/src/onos/apps/bgprouter/src/main/java/org/onosproject/bgprouter/NextHopGroupKey.java b/framework/src/onos/apps/bgprouter/src/main/java/org/onosproject/bgprouter/NextHopGroupKey.java index 82a45a08..cd4c4e9a 100644 --- a/framework/src/onos/apps/bgprouter/src/main/java/org/onosproject/bgprouter/NextHopGroupKey.java +++ b/framework/src/onos/apps/bgprouter/src/main/java/org/onosproject/bgprouter/NextHopGroupKey.java @@ -61,7 +61,7 @@ public class NextHopGroupKey { @Override public int hashCode() { - return Objects.hash(address); + return address.hashCode(); } @Override diff --git a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/cli/PIMShowCommand.java b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/cli/PIMShowCommand.java index 0ef7e389..6bd563b6 100644 --- a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/cli/PIMShowCommand.java +++ b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/cli/PIMShowCommand.java @@ -18,30 +18,30 @@ package org.onosproject.pim.cli; import com.fasterxml.jackson.databind.JsonNode; import org.apache.karaf.shell.commands.Command; import org.onosproject.cli.AbstractShellCommand; -import org.onosproject.net.ConnectPoint; -import org.onosproject.pim.impl.PIMNeighbors; -import org.onosproject.pim.impl.PIMNeighborsCodec; +import org.onosproject.pim.impl.PIMInterface; +import org.onosproject.pim.impl.PIMInterfaces; +import org.onosproject.pim.impl.PIMInterfacesCodec; -import java.util.HashMap; +import java.util.Collection; -@Command(scope = "onos", name = "pim-neighbors", description = "Displays the pim neighbors") +@Command(scope = "onos", name = "pim-interfaces", description = "Displays the pim interfaces") public class PIMShowCommand extends AbstractShellCommand { // prints either the json or cli version of the hash map connect point - // neighbors from the PIMNeighbors class. + // neighbors from the PIMInterfaces class. @Override protected void execute() { // grab connect point neighbors hash map to send in to json encoder. - HashMap pimNbrs = PIMNeighbors.getConnectPointNeighbors(); + Collection pimIntfs = PIMInterfaces.getInstance().getInterfaces(); if (outputJson()) { - print("%s", json(pimNbrs)); + print("%s", json(pimIntfs)); } else { - print(PIMNeighbors.printPimNeighbors()); + print(PIMInterfaces.getInstance().printInterfaces()); } } - private JsonNode json(HashMap pimNbrs) { - return new PIMNeighborsCodec().encode(pimNbrs, this); + private JsonNode json(Collection pimIntfs) { + return new PIMInterfacesCodec().encode(pimIntfs, this); } } \ No newline at end of file diff --git a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMComponent.java b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMComponent.java index bd5e1486..1a2d6f54 100644 --- a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMComponent.java +++ b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMComponent.java @@ -22,132 +22,61 @@ import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.ReferenceCardinality; -import org.onlab.packet.Ethernet; -import org.onlab.packet.IPv4; -import org.onlab.packet.Ip4Address; -import org.onlab.packet.IpAddress; -import org.onlab.packet.IpPrefix; -import org.onlab.packet.PIM; import org.onosproject.core.ApplicationId; import org.onosproject.core.CoreService; -import org.onosproject.net.flow.DefaultTrafficSelector; -import org.onosproject.net.flow.TrafficSelector; -import org.onosproject.net.packet.InboundPacket; -import org.onosproject.net.packet.PacketContext; -import org.onosproject.net.packet.PacketPriority; -import org.onosproject.net.packet.PacketProcessor; +import org.onosproject.incubator.net.intf.InterfaceService; +import org.onosproject.net.config.NetworkConfigService; import org.onosproject.net.packet.PacketService; import org.slf4j.Logger; /** - * Protocol Independent Multicast Emulation. + * Protocol Independent Multicast (PIM) Emulation. This component is responsible + * for reference the services this PIM module is going to need, then initializing + * the corresponding utility classes. */ @Component(immediate = true) public class PIMComponent { private final Logger log = getLogger(getClass()); + // Register to receive PIM packets, used to send packets as well @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected PacketService packetService; + // Get the appId @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected CoreService coreService; - private PIMPacketProcessor processor = new PIMPacketProcessor(); + // Get the network configuration updates + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected NetworkConfigService configService; + + // Access defined network (IP) interfaces + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected InterfaceService interfaceService; + private static ApplicationId appId; + private PIMInterfaces pimInterfaces; + private PIMPacketHandler pimPacketHandler; + @Activate public void activate() { appId = coreService.registerApplication("org.onosproject.pim"); - packetService.addProcessor(processor, PacketProcessor.director(1)); + // Initialize the Packet Handler class + pimPacketHandler = PIMPacketHandler.getInstance(); + pimPacketHandler.initialize(packetService, appId); - // Build a traffic selector for all multicast traffic - TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); - selector.matchEthType(Ethernet.TYPE_IPV4); - selector.matchIPProtocol(IPv4.PROTOCOL_PIM); - packetService.requestPackets(selector.build(), PacketPriority.REACTIVE, appId); + // Initialize the Interface class + pimInterfaces = PIMInterfaces.getInstance(); + pimInterfaces.initialize(configService, interfaceService); log.info("Started"); } @Deactivate public void deactivate() { - packetService.removeProcessor(processor); - processor = null; + PIMPacketHandler.getInstance().stop(); log.info("Stopped"); } - - /** - * Packet processor responsible for handling IGMP packets. - */ - private class PIMPacketProcessor implements PacketProcessor { - - @Override - public void process(PacketContext context) { - // Stop processing if the packet has been handled, since we - // can't do any more to it. - if (context.isHandled()) { - return; - } - - InboundPacket pkt = context.inPacket(); - if (pkt == null) { - return; - } - - Ethernet ethPkt = pkt.parsed(); - if (ethPkt == null) { - return; - } - - /* - * IPv6 MLD packets are handled by ICMP6. We'll only deal - * with IPv4. - */ - if (ethPkt.getEtherType() != Ethernet.TYPE_IPV4) { - return; - } - - IPv4 ip = (IPv4) ethPkt.getPayload(); - IpAddress gaddr = IpAddress.valueOf(ip.getDestinationAddress()); - IpAddress saddr = Ip4Address.valueOf(ip.getSourceAddress()); - log.debug("Packet (" + saddr.toString() + ", " + gaddr.toString() + - "\tingress port: " + context.inPacket().receivedFrom().toString()); - - if (ip.getProtocol() != IPv4.PROTOCOL_PIM) { - log.debug("PIM Picked up a non PIM packet: IP protocol: " + ip.getProtocol()); - return; - } - - // TODO: check incoming to be PIM.PIM_ADDRESS or "Our" address. - IpPrefix spfx = IpPrefix.valueOf(saddr, 32); - IpPrefix gpfx = IpPrefix.valueOf(gaddr, 32); - - PIM pim = (PIM) ip.getPayload(); - switch (pim.getPimMsgType()) { - - case PIM.TYPE_HELLO: - PIMNeighbors.processHello(ethPkt, context.inPacket().receivedFrom()); - break; - - case PIM.TYPE_JOIN_PRUNE_REQUEST: - // Create the function - break; - - case PIM.TYPE_ASSERT: - case PIM.TYPE_BOOTSTRAP: - case PIM.TYPE_CANDIDATE_RP_ADV: - case PIM.TYPE_GRAFT: - case PIM.TYPE_GRAFT_ACK: - case PIM.TYPE_REGISTER: - case PIM.TYPE_REGISTER_STOP: - log.debug("Unsupported PIM message type: " + pim.getPimMsgType()); - break; - - default: - log.debug("Unkown PIM message type: " + pim.getPimMsgType()); - break; - } - } - } } diff --git a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java new file mode 100644 index 00000000..28d1e8ba --- /dev/null +++ b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterface.java @@ -0,0 +1,339 @@ +/* + * 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.pim.impl; + +import org.onlab.packet.Ethernet; +import org.onlab.packet.IPv4; +import org.onlab.packet.Ip4Address; +import org.onlab.packet.IpAddress; +import org.onlab.packet.MacAddress; +import org.onlab.packet.PIM; +import org.onlab.packet.pim.PIMHello; +import org.onlab.packet.pim.PIMHelloOption; +import org.onosproject.incubator.net.intf.Interface; +import org.onosproject.net.ConnectPoint; +import org.onosproject.net.host.InterfaceIpAddress; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * The PIM Interface is a wrapper around a ConnectPoint and used to provide + * hello options values when "talking" with PIM other PIM routers. + */ +public class PIMInterface { + private static Logger log = LoggerFactory.getLogger("PIMInterfaces"); + + // Interface from the interface subsystem + private Interface theInterface; + + // The list of PIM neighbors adjacent to this interface + private Map neighbors = new HashMap<>(); + + // The designatedRouter for this LAN + private PIMNeighbor designatedRouter; + + // The priority we use on this ConnectPoint. + private int priority = PIMHelloOption.DEFAULT_PRIORITY; + + // The holdtime we are sending out. + private int holdtime = PIMHelloOption.DEFAULT_HOLDTIME; + + // Then generation ID we are sending out. 0 means we need to generate a new random ID + private int genid = PIMHelloOption.DEFAULT_GENID; + + // Our default prune delay + private int prunedelay = PIMHelloOption.DEFAULT_PRUNEDELAY; + + /** + * Create a PIMInterface. + */ + public PIMInterface(Interface intf) { + + log.debug("Adding an interface: " + intf.toString() + "\n"); + this.theInterface = intf; + + // Send a hello to let our neighbors know we are alive + sendHello(); + } + + /** + * Get the PIM Interface. + * + * @return the PIM Interface + */ + public Interface getInterface() { + return theInterface; + } + + /** + * Getter for our IP address. + * + * @return our IP address. + */ + public IpAddress getIpAddress() { + if (theInterface.ipAddresses().isEmpty()) { + return null; + } + + // We will just assume the first interface on the list + IpAddress ipaddr = null; + for (InterfaceIpAddress ifipaddr : theInterface.ipAddresses()) { + ipaddr = ifipaddr.ipAddress(); + break; + } + return ipaddr; + } + + /** + * Get our priority. + * + * @return our priority. + */ + public int getPriority() { + return this.priority; + } + + /** + * Get the designated router on this connection. + * + * @return the PIMNeighbor representing the DR + */ + public PIMNeighbor getDesignatedRouter() { + return designatedRouter; + } + + /** + * Are we the DR on this CP? + * + * @return true if we are, false if not + */ + public boolean areWeDr() { + return (designatedRouter != null && + designatedRouter.getPrimaryAddr().equals(this.getIpAddress())); + } + + /** + * Return a collection of PIM Neighbors. + * + * @return the collection of PIM Neighbors + */ + public Collection getNeighbors() { + return this.neighbors.values(); + } + + /** + * Find the neighbor with the given IP address on this CP. + * + * @param ipaddr the IP address of the neighbor we are interested in + * @return the pim neighbor if it exists + */ + public PIMNeighbor findNeighbor(IpAddress ipaddr) { + PIMNeighbor nbr = neighbors.get(ipaddr); + return nbr; + } + + /** + * Add a new PIM neighbor to this list. + * + * @param nbr the neighbor to be added. + */ + public void addNeighbor(PIMNeighbor nbr) { + if (neighbors.containsKey(nbr.getPrimaryAddr())) { + + log.debug("We are adding a neighbor that already exists: {}", nbr.toString()); + neighbors.remove(nbr.getPrimaryAddr()); + } + neighbors.put(nbr.getPrimaryAddr(), nbr); + } + + /** + * Remove the neighbor from our neighbor list. + * + * @param ipaddr the IP address of the neighbor to remove + */ + public void removeNeighbor(IpAddress ipaddr) { + + if (neighbors.containsKey(ipaddr)) { + neighbors.remove(ipaddr); + } + this.electDR(); + } + + /** + * Remove the given neighbor from the neighbor list. + * + * @param nbr the nbr to be removed. + */ + public void removeNeighbor(PIMNeighbor nbr) { + + neighbors.remove(nbr.getPrimaryAddr(), nbr); + this.electDR(); + } + + /** + * Elect a new DR on this ConnectPoint. + * + * @return the PIM Neighbor that wins + */ + public PIMNeighbor electDR() { + + for (PIMNeighbor nbr : this.neighbors.values()) { + if (this.designatedRouter == null) { + this.designatedRouter = nbr; + continue; + } + + if (nbr.getPriority() > this.designatedRouter.getPriority()) { + this.designatedRouter = nbr; + continue; + } + + // We could sort in ascending order + if (this.designatedRouter.getPrimaryAddr().compareTo(nbr.getPrimaryAddr()) > 0) { + this.designatedRouter = nbr; + continue; + } + } + + return this.designatedRouter; + } + + /** + * Elect a new DR given the new neighbor. + * + * @param nbr the new neighbor to use in DR election. + * @return the PIM Neighbor that wins DR election + */ + public PIMNeighbor electDR(PIMNeighbor nbr) { + + // Make sure I have + if (this.designatedRouter == null || + this.designatedRouter.getPriority() < nbr.getPriority() || + this.designatedRouter.getPrimaryAddr().compareTo(nbr.getPrimaryAddr()) > 0) { + this.designatedRouter = nbr; + } + return this.designatedRouter; + } + + /** + * Find or create a pim neighbor with a given ip address and connect point. + * + * @param ipaddr of the pim neighbor + * @param mac The mac address of our sending neighbor + * @return an existing or new PIM neighbor + */ + public PIMNeighbor findOrCreate(IpAddress ipaddr, MacAddress mac) { + PIMNeighbor nbr = this.findNeighbor(ipaddr); + if (nbr == null) { + nbr = new PIMNeighbor(ipaddr, mac, this); + this.addNeighbor(nbr); + this.electDR(nbr); + } + return nbr; + } + + /** + * Process a hello packet received on this Interface. + * + * @param ethPkt the ethernet packet containing the hello message + * @param cp the ConnectPoint of this interface + */ + public void processHello(Ethernet ethPkt, ConnectPoint cp) { + checkNotNull(ethPkt); + checkNotNull(cp); + + MacAddress srcmac = ethPkt.getSourceMAC(); + IPv4 ip = (IPv4) ethPkt.getPayload(); + Ip4Address srcip = Ip4Address.valueOf(ip.getSourceAddress()); + + PIM pim = (PIM) ip.getPayload(); + checkNotNull(pim); + + PIMHello hello = (PIMHello) pim.getPayload(); + checkNotNull(hello); + + PIMNeighbor nbr = this.findOrCreate(srcip, srcmac); + if (nbr == null) { + log.error("Could not create a neighbor for: {1}", srcip.toString()); + return; + } + + ConnectPoint icp = theInterface.connectPoint(); + checkNotNull(icp); + if (!cp.equals(icp)) { + log.error("PIM Hello message received from {} on incorrect interface {}", + nbr.getPrimaryAddr(), this.toString()); + return; + } + nbr.refresh(hello); + } + + /** + * Send a hello packet from this interface. + */ + public void sendHello() { + PIM pim = new PIM(); + PIMHello hello = new PIMHello(); + + // Create a PIM Hello + pim = new PIM(); + pim.setVersion((byte) 2); + pim.setPIMType((byte) PIM.TYPE_HELLO); + pim.setChecksum((short) 0); + + hello = new PIMHello(); + hello.createDefaultOptions(); + pim.setPayload(hello); + hello.setParent(pim); + + log.debug("Sending hello: \n"); + PIMPacketHandler.getInstance().sendPacket(pim, this); + } + + /** + * prints the connectPointNeighbors list with each neighbor list. + * + * @return string of neighbors. + */ + public String printNeighbors() { + String out = "PIM Neighbors Table: \n"; + for (PIMNeighbor nbr : this.neighbors.values()) { + out += "\t" + nbr.toString(); + } + return out; + } + + @Override + public String toString() { + IpAddress ipaddr = this.getIpAddress(); + String out = "PIM Neighbors: "; + if (ipaddr != null) { + out += "IP: " + ipaddr.toString(); + } else { + out += "IP: *Null*"; + } + out += "\tPR: " + String.valueOf(this.priority) + "\n"; + return out; + } + +} + diff --git a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaces.java b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaces.java new file mode 100644 index 00000000..e33d5aa1 --- /dev/null +++ b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfaces.java @@ -0,0 +1,260 @@ +/* + * 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.pim.impl; + +import org.jboss.netty.util.Timeout; +import org.jboss.netty.util.TimerTask; +import org.onosproject.incubator.net.config.basics.ConfigException; +import org.onosproject.incubator.net.config.basics.InterfaceConfig; +import org.onosproject.incubator.net.intf.Interface; +import org.onosproject.incubator.net.intf.InterfaceService; +import org.onosproject.net.ConnectPoint; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +import org.onosproject.net.config.NetworkConfigEvent; +import org.onosproject.net.config.NetworkConfigListener; +import org.onosproject.net.config.NetworkConfigService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * PIMInterfaces is a collection of all neighbors we have received + * PIM hello messages from. The main structure is a HashMap indexed + * by ConnectPoint with another HashMap indexed on the PIM neighbors + * IPAddress, it contains all PIM neighbors attached on that ConnectPoint. + */ +public final class PIMInterfaces { + + private Logger log = LoggerFactory.getLogger("PIMInterfaces"); + + private static PIMInterfaces instance = null; + + // Used to listen to network configuration changes + private NetworkConfigService configService; + + // Used to access IP Interface definitions for our segment + private InterfaceService interfaceService; + + // Internal class used to listen for network configuration changes + private InternalConfigListener configListener = new InternalConfigListener(); + + // This is the global container for all PIM Interfaces indexed by ConnectPoints. + private Map interfaces = new HashMap<>(); + + // Default hello message interval + private int helloMessageInterval = 60; + + // Timer used to send hello messages on this interface + private Timeout helloTimer; + + // Required by a utility class + private PIMInterfaces() {} + + /** + * Get the instance of PIMInterfaces. Create the instance if needed. + * + * @return PIMInterface instance + */ + public static PIMInterfaces getInstance() { + if (null == instance) { + instance = new PIMInterfaces(); + } + return instance; + } + + // Initialize the services + public void initialize(NetworkConfigService cs, InterfaceService is) { + configService = cs; + interfaceService = is; + + // Initialize interfaces if they already exist + initInterfaces(); + + // Listen for network config changes + configService.addListener(configListener); + } + + /** + * Listener for network config events. + */ + private class InternalConfigListener implements NetworkConfigListener { + + private void updateInterfaces(InterfaceConfig config) { + Set intfs; + try { + intfs = config.getInterfaces(); + } catch (ConfigException e) { + log.error(e.toString()); + return; + } + for (Interface intf : intfs) { + addInterface(intf); + } + } + + /** + * Remove the PIMInterface represented by the ConnectPoint. If the + * PIMInterface does not exist this function is a no-op. + * + * @param cp The connectPoint representing the PIMInterface to be removed. + */ + private void removeInterface(ConnectPoint cp) { + removeInterface(cp); + } + + @Override + public void event(NetworkConfigEvent event) { + switch (event.type()) { + case CONFIG_ADDED: + case CONFIG_UPDATED: + log.debug("Config updated: " + event.toString() + "\n"); + if (event.configClass() == InterfaceConfig.class) { + InterfaceConfig config = + configService.getConfig((ConnectPoint) event.subject(), InterfaceConfig.class); + updateInterfaces(config); + } + break; + case CONFIG_REMOVED: + if (event.configClass() == InterfaceConfig.class) { + removeInterface((ConnectPoint) event.subject()); + } + break; + case CONFIG_REGISTERED: + case CONFIG_UNREGISTERED: + default: + break; + } + } + } + + // Configure interfaces if they already exist. + private void initInterfaces() { + Set intfs = interfaceService.getInterfaces(); + for (Interface intf : intfs) { + log.debug("Adding interface: " + intf.toString() + "\n"); + addInterface(intf); + } + } + + /** + * Create a PIM Interface and add to our interfaces list. + * + * @param intf the interface to add + * @return the PIMInterface + */ + public PIMInterface addInterface(Interface intf) { + PIMInterface pif = new PIMInterface(intf); + interfaces.put(intf.connectPoint(), pif); + + // If we have added our first interface start the hello timer. + if (interfaces.size() == 1) { + startHelloTimer(); + } + + // Return this interface + return pif; + } + + /** + * Remove the PIMInterface from the given ConnectPoint. + * + * @param cp the ConnectPoint indexing the PIMInterface to be removed. + */ + public void removeInterface(ConnectPoint cp) { + if (interfaces.containsKey(cp)) { + interfaces.remove(cp); + } + + if (interfaces.size() == 0) { + PIMTimer.stop(); + } + } + + /** + * Return a collection of PIMInterfaces for use by the PIM Interface codec. + * + * @return the collection of PIMInterfaces + */ + public Collection getInterfaces() { + return interfaces.values(); + } + + /** + * Get the PIM Interface indexed by the given ConnectPoint. + * + * @param cp the connect point + * @return the PIMInterface if it exists, NULL if not + */ + public PIMInterface getInterface(ConnectPoint cp) { + return interfaces.get(cp); + } + + /** + * Return a string of PIMInterfaces for the cli command. + * + * @return a string representing PIM interfaces + */ + public String printInterfaces() { + String str = ""; + for (PIMInterface pi : interfaces.values()) { + str += pi.toString(); + } + return str; + } + + /* ---------------------------------- PIM Hello Timer ----------------------------------- */ + + /** + * Start a new hello timer for this interface. + */ + private void startHelloTimer() { + helloTimer = PIMTimer.getTimer().newTimeout( + new HelloTimer(), + helloMessageInterval, + TimeUnit.SECONDS); + + log.debug("Started Hello Timer"); + } + + /** + * This inner class handles transmitting a PIM hello message on this ConnectPoint. + */ + private final class HelloTimer implements TimerTask { + + HelloTimer() { + } + + @Override + public void run(Timeout timeout) throws Exception { + + log.debug("Running Hello Timer\n"); + // Technically we should not send all hello's in synch.. + for (PIMInterface pi : interfaces.values()) { + pi.sendHello(); + } + + // restart the hello timer + if (interfaces.size() > 0) { + startHelloTimer(); + } + } + } +} \ No newline at end of file diff --git a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfacesCodec.java b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfacesCodec.java new file mode 100644 index 00000000..ddd7a597 --- /dev/null +++ b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMInterfacesCodec.java @@ -0,0 +1,96 @@ +/* + * 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.pim.impl; + +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.onosproject.codec.CodecContext; +import org.onosproject.codec.JsonCodec; + +import java.util.Collection; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * PIM neighbors Codec. + */ +public class PIMInterfacesCodec extends JsonCodec> { + // JSON field names + //Return Name + private static final String CPNBRLIST = "connect_point_list"; + + // PIM Neightbors Fields + private static final String IP = "ip"; + private static final String PRIORITY = "priority"; + private static final String NBRLIST = "neighbor_list"; + + // PIM neighbor Files + private static final String DR = "designated"; + private static final String NBR_IP = "ip"; + private static final String PR = "priority"; + private static final String HOLDTIME = "hold_time"; + + /** + * Encode the PIM Neighbors. + * + * @param cpn ConnectPoint neighbors + * @param context encoding context + * + * @return Encoded neighbors used by CLI and REST + */ + @Override + public ObjectNode encode(Collection cpn, CodecContext context) { + checkNotNull(cpn, "Pim Neighbors cannot be null"); + + ObjectNode pimNbrJsonCodec = context.mapper().createObjectNode(); + ArrayNode cpnList = context.mapper().createArrayNode(); + + for (PIMInterface pn: cpn) { + // get the PimNeighbors Obj, contains Neighbors list + // create the json object for a single Entry in the Neighbors list + ObjectNode cp = context.mapper().createObjectNode(); + cp.put(IP, pn.getIpAddress().toString()); + cp.put(PRIORITY, String.valueOf(pn.getPriority())); + + // create the array for the neighbors list + ArrayNode nbrsList = context.mapper().createArrayNode(); + for (PIMNeighbor nbr : pn.getNeighbors()) { + nbrsList.add(neighbor(nbr, context)); + } + // adds pim neighbor to list + cp.set(NBRLIST, nbrsList); + // adds to arraynode which will represent the connect point neighbors hash map. + cpnList.add(cp); + } + pimNbrJsonCodec.set(CPNBRLIST, cpnList); + return pimNbrJsonCodec; + } + + /** + * Encode a single PIM Neighbor. + * + * @param nbr the neighbor to be encoded + * @param context encoding context + * @return the encoded neighbor + */ + private ObjectNode neighbor(PIMNeighbor nbr, CodecContext context) { + return context.mapper().createObjectNode() + .put(DR, Boolean.toString(nbr.isDr())) + .put(NBR_IP, nbr.getPrimaryAddr().toString()) + .put(PR, String.valueOf(nbr.getPriority())) + .put(HOLDTIME, String.valueOf(nbr.getHoldtime())); + } +} diff --git a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighbor.java b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighbor.java index 1a96138f..73d1598a 100644 --- a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighbor.java +++ b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighbor.java @@ -60,22 +60,20 @@ public class PIMNeighbor { // Timeout for this neighbor private volatile Timeout timeout; - private boolean reelect = false; - // A back pointer the neighbors list this neighbor belongs to. - private PIMNeighbors neighbors; + private PIMInterface pimInterface; /** * Construct this neighbor from the address and connect point. * * @param ipaddr IP Address of neighbor * @param macaddr MAC Address of the neighbor - * @param cp The ConnectPoint of this neighbor + * @param pimInterface The PIMInterface of this neighbor */ - public PIMNeighbor(IpAddress ipaddr, MacAddress macaddr, ConnectPoint cp) { + public PIMNeighbor(IpAddress ipaddr, MacAddress macaddr, PIMInterface pimInterface) { this.macAddress = macaddr; this.primaryAddr = ipaddr; - this.connectPoint = cp; + this.pimInterface = pimInterface; this.resetTimeout(); } @@ -174,30 +172,12 @@ public class PIMNeighbor { * * @return the ConnectPoint */ - public ConnectPoint getConnectPoint() { - return connectPoint; - } - - /** - * Set the ConnectPoint this router is connected to. - * - * @param connectPoint the ConnectPoint this router is connected to. - */ - public void setConnectPoint(ConnectPoint connectPoint) { - this.connectPoint = connectPoint; + public PIMInterface getPimInterface() { + return pimInterface; } /** - * Set a back pointer to the neighbors list this neighbor is a member of. - * - * @param neighbors the neighbor list this neighbor belongs to - */ - public void setNeighbors(PIMNeighbors neighbors) { - this.neighbors = neighbors; - } - - /** - * We have received a fresh hello from a neighbor, now we need to process it. + * We have received a fresh hello from this neighbor, now we need to process it. * Depending on the values received in the the hello options may force a * re-election process. * @@ -208,17 +188,19 @@ public class PIMNeighbor { public void refresh(PIMHello hello) { checkNotNull(hello); + boolean reelect = false; for (PIMHelloOption opt : hello.getOptions().values()) { int len = opt.getOptLength(); - byte [] value = new byte[len]; - ByteBuffer bb = ByteBuffer.wrap(value); + ByteBuffer bb = ByteBuffer.wrap(opt.getValue()); switch (opt.getOptType()) { case PIMHelloOption.OPT_GENID: int newid = bb.getInt(); if (this.genId != newid) { - // TODO: we have a newly rebooted neighbor. Send them our joins. + + // We have a newly rebooted neighbor, this is where we would + // send them our joins. this.genId = newid; } break; @@ -228,7 +210,7 @@ public class PIMNeighbor { if (this.priority != newpri) { // The priorities have changed. We may need to re-elect a new DR? - if (this.isDr || this.neighbors.getDesignatedRouter().getPriority() < priority) { + if (this.isDr || pimInterface.getDesignatedRouter().getPriority() < priority) { reelect = true; } this.priority = newpri; @@ -242,7 +224,6 @@ public class PIMNeighbor { if (holdtime == 0) { // We have a neighbor going down. We can remove all joins // we have learned from them. - // TODO: What else do we need to do when a neighbor goes down? log.debug("PIM Neighbor has timed out: {}", this.primaryAddr.toString()); return; @@ -261,7 +242,7 @@ public class PIMNeighbor { } if (reelect) { - this.neighbors.electDR(this); + pimInterface.electDR(this); } // Reset the next timeout timer @@ -307,9 +288,8 @@ public class PIMNeighbor { @Override public void run(Timeout timeout) throws Exception { - // TODO: log.debug; - PIMNeighbors neighbors = nbr.neighbors; - neighbors.removeNeighbor(nbr.getPrimaryAddr()); + log.debug("PIM Neighbor {} has timed out: ", nbr.toString()); + nbr.pimInterface.removeNeighbor(nbr); } } diff --git a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighbors.java b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighbors.java deleted file mode 100644 index cad90768..00000000 --- a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighbors.java +++ /dev/null @@ -1,395 +0,0 @@ - -package org.onosproject.pim.impl; - -import org.jboss.netty.util.Timeout; -import org.jboss.netty.util.TimerTask; -import org.onlab.packet.Ethernet; -import org.onlab.packet.IPv4; -import org.onlab.packet.Ip4Address; -import org.onlab.packet.IpAddress; -import org.onlab.packet.MacAddress; -import org.onlab.packet.PIM; -import org.onlab.packet.pim.PIMHello; -import org.onosproject.net.ConnectPoint; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * PIMNeighbors is a collection of all neighbors we have received - * PIM hello messages from. The main structure is a HashMap indexed - * by ConnectPoint with another HashMap indexed on the PIM neighbors - * IPAddress, it contains all PIM neighbors attached on that ConnectPoint. - */ -public final class PIMNeighbors { - - private static Logger log = LoggerFactory.getLogger("PIMNeighbors"); - - /** - * This is the global container for all PIM neighbors indexed by ConnectPoints. - * - * NOTE: We'll have a problem if the same neighbor can show up on two interfaces - * but that should never happen. - */ - private static HashMap connectPointNeighbors = new HashMap<>(); - - // The connect point these neighbors are connected to. - private ConnectPoint connectPoint; - - // Pointer to the current designated router on this ConnectPoint. - private PIMNeighbor designatedRouter; - - // The list of neighbors we have learned on this ConnectPoint. - private HashMap neighbors = new HashMap<>(); - - /* - * TODO: turn ourIpAddress, ourPriority and OurHoldTime into config options. - */ - // The IP address we are using to source our PIM hello messages on this connect Point. - private IpAddress ourIpAddress; - - // The priority we use on this ConnectPoint. - private int ourPriority = 1; - - // The holdtime we are sending out. - private int ourHoldtime = 105; - - // Then generation ID we are sending out. 0 means we need to generate a new random ID - private int ourGenid = 0; - - // Hello Timer for sending hello messages per ConnectPoint with neighbors. - private volatile Timeout helloTimer; - - // The period of which we will be sending out PIM hello messages. - private final int defaultPimHelloInterval = 30; // seconds - - /** - * Create PIMNeighbors object per ConnectPoint. - * - * @param cp the ConnectPoint. - * @return PIMNeighbors structure - */ - public static PIMNeighbors getConnectPointNeighbors(ConnectPoint cp) { - return connectPointNeighbors.get(cp); - } - - /** - * Process incoming hello message, we will need the Macaddress and IP address of the sender. - * - * @param ethPkt the ethernet header - * @param receivedFrom the connect point we recieved this message from - */ - public static void processHello(Ethernet ethPkt, ConnectPoint receivedFrom) { - checkNotNull(ethPkt); - checkNotNull(ethPkt); - - MacAddress srcmac = ethPkt.getSourceMAC(); - IPv4 ip = (IPv4) ethPkt.getPayload(); - Ip4Address srcip = Ip4Address.valueOf(ip.getSourceAddress()); - - PIM pim = (PIM) ip.getPayload(); - checkNotNull(pim); - - PIMHello hello = (PIMHello) pim.getPayload(); - checkNotNull(hello); - - PIMNeighbor nbr = PIMNeighbors.findOrCreate(srcip, srcmac, receivedFrom); - if (nbr == null) { - log.error("Could not create a neighbor for: {1}", srcip.toString()); - return; - } - - nbr.setConnectPoint(receivedFrom); - nbr.refresh(hello); - } - - /** - * Create a PIM Neighbor. - * - * @param cp The ConnectPoint this neighbor was found on - */ - public PIMNeighbors(ConnectPoint cp) { - this.connectPoint = cp; - - // TODO: use network config to assign address. - this.ourIpAddress = IpAddress.valueOf("10.2.2.2"); - this.addIpAddress(this.ourIpAddress); - } - - /** - * Create a PIM neighbor. - * - * @param cp the ConnectPoint this neighbor was found on - * @param ourIp the IP address of this neighbor - */ - public PIMNeighbors(ConnectPoint cp, IpAddress ourIp) { - this.connectPoint = cp; - this.addIpAddress(ourIp); - } - - /** - * Start the hello timer when we have been given an IP address. - * - * @param ourIp our IP address. - */ - public void addIpAddress(IpAddress ourIp) { - this.startHelloTimer(); - - // Kick off the first pim hello packet - this.sendHelloPacket(); - } - - /** - * Getter for our IP address. - * - * @return our IP address. - */ - public IpAddress getOurIpAddress() { - return this.ourIpAddress; - } - - /** - * Get our priority. - * - * @return our priority. - */ - public int getOurPriority() { - return this.ourPriority; - } - - /** - * Get the neighbor list for this specific connectPoint. - * - * @return PIM neighbors on this ConnectPoint - */ - public HashMap getOurNeighborsList() { - return this.neighbors; - } - - /** - * Get the designated router on this connection. - * - * @return the PIMNeighbor representing the DR - */ - public PIMNeighbor getDesignatedRouter() { - return designatedRouter; - } - - /** - * Are we the DR on this CP? - * - * @return true if we are, false if not - */ - public boolean weAreTheDr() { - return (designatedRouter != null && - designatedRouter.getPrimaryAddr().equals(ourIpAddress)); - } - - /** - * Find the neighbor with the given IP address on this CP. - * - * @param ipaddr the IP address of the neighbor we are interested in - * @return the pim neighbor if it exists - */ - public PIMNeighbor findNeighbor(IpAddress ipaddr) { - PIMNeighbor nbr = neighbors.get(ipaddr); - return nbr; - } - - /** - * Add a new PIM neighbor to this list. - * - * @param nbr the neighbor to be added. - */ - public void addNeighbor(PIMNeighbor nbr) { - if (neighbors.containsKey(nbr.getPrimaryAddr())) { - - // TODO: Hmmm, how should this be handled? - log.debug("We are adding a neighbor that already exists: {}", nbr.toString()); - neighbors.remove(nbr.getPrimaryAddr(), nbr); - } - nbr.setNeighbors(this); - neighbors.put(nbr.getPrimaryAddr(), nbr); - } - - /** - * Remove the neighbor from our neighbor list. - * - * @param ipaddr the IP address of the neighbor to remove - */ - public void removeNeighbor(IpAddress ipaddr) { - - boolean reelect = (designatedRouter == null || designatedRouter.getPrimaryAddr().equals(ipaddr)); - if (neighbors.containsKey(ipaddr)) { - neighbors.remove(ipaddr); - } - this.electDR(); - } - - /** - * Remove the given neighbor from the neighbor list. - * - * @param nbr the nbr to be removed. - */ - public void removeNeighbor(PIMNeighbor nbr) { - - boolean reelect = (designatedRouter == null || nbr.isDr()); - neighbors.remove(nbr.getPrimaryAddr(), nbr); - this.electDR(); - } - - /** - * Elect a new DR on this ConnectPoint. - * - * @return the PIM Neighbor that wins - */ - public PIMNeighbor electDR() { - - for (PIMNeighbor nbr : this.neighbors.values()) { - if (this.designatedRouter == null) { - this.designatedRouter = nbr; - continue; - } - - if (nbr.getPriority() > this.designatedRouter.getPriority()) { - this.designatedRouter = nbr; - continue; - } - - // We could sort in ascending order - if (this.designatedRouter.getPrimaryAddr().compareTo(nbr.getPrimaryAddr()) > 0) { - this.designatedRouter = nbr; - continue; - } - } - - return this.designatedRouter; - } - - /** - * Elect a new DR given the new neighbor. - * - * @param nbr the new neighbor to use in DR election. - * @return the PIM Neighbor that wins DR election - */ - public PIMNeighbor electDR(PIMNeighbor nbr) { - - // Make sure I have - if (this.designatedRouter == null || - this.designatedRouter.getPriority() < nbr.getPriority() || - this.designatedRouter.getPrimaryAddr().compareTo(nbr.getPrimaryAddr()) > 0) { - this.designatedRouter = nbr; - } - return this.designatedRouter; - } - - /** - * Find or create a pim neighbor with a given ip address and connect point. - * - * @param ipaddr of the pim neighbor - * @param mac The mac address of our sending neighbor - * @param cp the connect point the neighbor was learned from - * @return an existing or new PIM neighbor - */ - public static PIMNeighbor findOrCreate(IpAddress ipaddr, MacAddress mac, ConnectPoint cp) { - PIMNeighbors neighbors = connectPointNeighbors.get(cp); - if (neighbors == null) { - neighbors = new PIMNeighbors(cp); - connectPointNeighbors.put(cp, neighbors); - } - - PIMNeighbor nbr = neighbors.findNeighbor(ipaddr); - if (nbr == null) { - nbr = new PIMNeighbor(ipaddr, mac, cp); - neighbors.addNeighbor(nbr); - neighbors.electDR(nbr); - } - return nbr; - } - - // Returns the connect point neighbors hash map - public static HashMap getConnectPointNeighbors() { - return connectPointNeighbors; - } - - /* ---------------------------------- PIM Hello Timer ----------------------------------- */ - - /** - * Start a new hello timer for this ConnectPoint. - */ - private void startHelloTimer() { - this.helloTimer = PIMTimer.getTimer().newTimeout( - new HelloTimer(this), - this.defaultPimHelloInterval, - TimeUnit.SECONDS); - - log.trace("Started Hello Timer: " + this.ourIpAddress.toString()); - } - - /** - * This inner class handles transmitting a PIM hello message on this ConnectPoint. - */ - private final class HelloTimer implements TimerTask { - PIMNeighbors neighbors; - - HelloTimer(PIMNeighbors neighbors) { - this.neighbors = neighbors; - } - - @Override - public void run(Timeout timeout) throws Exception { - - // Send off a hello packet - sendHelloPacket(); - - // restart the hello timer - neighbors.startHelloTimer(); - } - } - - private void sendHelloPacket() { - PIMHello hello = new PIMHello(); - - // TODO: we will need to implement the network config service to assign ip addresses & options - /* - hello.createDefaultOptions(); - - Ethernet eth = hello.createPIMHello(this.ourIpAddress); - hello.sendPacket(this.connectPoint); - */ - } - - /** - * prints the connectPointNeighbors list with each neighbor list. - * - * @return string of neighbors. - */ - public static String printPimNeighbors() { - String out = "PIM Neighbors Table: \n"; - - for (PIMNeighbors pn: connectPointNeighbors.values()) { - - out += "CP:\n " + pn.toString(); - for (PIMNeighbor nbr : pn.neighbors.values()) { - out += "\t" + nbr.toString(); - } - } - return out; - } - - @Override - public String toString() { - String out = "PIM Neighbors: "; - if (this.ourIpAddress != null) { - out += "IP: " + this.ourIpAddress.toString(); - } else { - out += "IP: *Null*"; - } - out += "\tPR: " + String.valueOf(this.ourPriority) + "\n"; - return out; - } -} \ No newline at end of file diff --git a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighborsCodec.java b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighborsCodec.java deleted file mode 100644 index ee62eb79..00000000 --- a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMNeighborsCodec.java +++ /dev/null @@ -1,97 +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.pim.impl; - -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.net.ConnectPoint; - -import java.util.HashMap; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * PIM neighbors Codec. - */ -public class PIMNeighborsCodec extends JsonCodec> { - // JSON field names - //Return Name - private static final String CPNBRLIST = "connect_point_list"; - - // PIM Neightbors Fields - private static final String IP = "ip"; - private static final String PRIORITY = "priority"; - private static final String NBRLIST = "neighbor_list"; - - // PIM neighbor Files - private static final String DR = "designated"; - private static final String NBR_IP = "ip"; - private static final String PR = "priority"; - private static final String HOLDTIME = "hold_time"; - - /** - * Encode the PIM Neighbors. - * - * @param cpn ConnectPoint neighbors - * @param context encoding context - * - * @return Encoded neighbors used by CLI and REST - */ - @Override - public ObjectNode encode(HashMap cpn, CodecContext context) { - checkNotNull(cpn, "Pim Neighbors cannot be null"); - - ObjectNode pimNbrJsonCodec = context.mapper().createObjectNode(); - ArrayNode cpnList = context.mapper().createArrayNode(); - - for (PIMNeighbors pn: cpn.values()) { - // get the PimNeighbors Obj, contains Neighbors list - // create the json object for a single Entry in the Neighbors list - ObjectNode cp = context.mapper().createObjectNode(); - cp.put(IP, pn.getOurIpAddress().toString()); - cp.put(PRIORITY, String.valueOf(pn.getOurPriority())); - - // create the array for the neighbors list - ArrayNode nbrsList = context.mapper().createArrayNode(); - for (PIMNeighbor nbr : pn.getOurNeighborsList().values()) { - nbrsList.add(neighbor(nbr, context)); - } - // adds pim neighbor to list - cp.set(NBRLIST, nbrsList); - // adds to arraynode which will represent the connect point neighbors hash map. - cpnList.add(cp); - } - pimNbrJsonCodec.set(CPNBRLIST, cpnList); - return pimNbrJsonCodec; - } - - /** - * Encode a single PIM Neighbor. - * - * @param nbr the neighbor to be encoded - * @param context encoding context - * @return the encoded neighbor - */ - private ObjectNode neighbor(PIMNeighbor nbr, CodecContext context) { - return context.mapper().createObjectNode() - .put(DR, Boolean.toString(nbr.isDr())) - .put(NBR_IP, nbr.getPrimaryAddr().toString()) - .put(PR, String.valueOf(nbr.getPriority())) - .put(HOLDTIME, String.valueOf(nbr.getHoldtime())); - } -} diff --git a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMPacketHandler.java b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMPacketHandler.java new file mode 100644 index 00000000..c1ad2cfe --- /dev/null +++ b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMPacketHandler.java @@ -0,0 +1,229 @@ +/* + * 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.pim.impl; + +import org.onlab.packet.Ethernet; +import org.onlab.packet.IPv4; +import org.onlab.packet.Ip4Address; +import org.onlab.packet.IpAddress; +import org.onlab.packet.IpPrefix; +import org.onlab.packet.MacAddress; +import org.onlab.packet.PIM; +import org.onlab.packet.VlanId; +import org.onosproject.core.ApplicationId; +import org.onosproject.incubator.net.intf.Interface; +import org.onosproject.net.ConnectPoint; +import org.onosproject.net.flow.DefaultTrafficSelector; +import org.onosproject.net.flow.DefaultTrafficTreatment; +import org.onosproject.net.flow.TrafficSelector; +import org.onosproject.net.flow.TrafficTreatment; +import org.onosproject.net.packet.DefaultOutboundPacket; +import org.onosproject.net.packet.InboundPacket; +import org.onosproject.net.packet.OutboundPacket; +import org.onosproject.net.packet.PacketContext; +import org.onosproject.net.packet.PacketPriority; +import org.onosproject.net.packet.PacketProcessor; +import org.onosproject.net.packet.PacketService; +import org.slf4j.Logger; + +import java.nio.ByteBuffer; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.slf4j.LoggerFactory.getLogger; + +/** + * Handing Incoming and outgoing PIM packets. + */ +public final class PIMPacketHandler { + private final Logger log = getLogger(getClass()); + + private static PIMPacketHandler instance = null; + + private PacketService packetService; + private PIMPacketProcessor processor = new PIMPacketProcessor(); + private MacAddress pimDestinationMac = MacAddress.valueOf("01:00:5E:00:00:0d"); + + // Utility class + private PIMPacketHandler() {} + + public static PIMPacketHandler getInstance() { + if (null == instance) { + instance = new PIMPacketHandler(); + } + return instance; + } + + /** + * Initialize the packet handling service. + * + * @param ps the packetService + * @param appId our application ID + */ + public void initialize(PacketService ps, ApplicationId appId) { + packetService = ps; + + // Build a traffic selector for all multicast traffic + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); + selector.matchEthType(Ethernet.TYPE_IPV4); + selector.matchIPProtocol(IPv4.PROTOCOL_PIM); + packetService.requestPackets(selector.build(), PacketPriority.REACTIVE, appId); + + packetService.addProcessor(processor, PacketProcessor.director(1)); + } + + /** + * Shutdown the packet handling service. + */ + public void stop() { + packetService.removeProcessor(processor); + processor = null; + } + + /** + * Packet processor responsible for handling IGMP packets. + */ + public class PIMPacketProcessor implements PacketProcessor { + private final Logger log = getLogger(getClass()); + + @Override + public void process(PacketContext context) { + // Stop processing if the packet has been handled, since we + // can't do any more to it. + if (context.isHandled()) { + return; + } + + InboundPacket pkt = context.inPacket(); + if (pkt == null) { + return; + } + + Ethernet ethPkt = pkt.parsed(); + if (ethPkt == null) { + return; + } + + /* + * IPv6 MLD packets are handled by ICMP6. We'll only deal + * with IPv4. + */ + if (ethPkt.getEtherType() != Ethernet.TYPE_IPV4) { + return; + } + + IPv4 ip = (IPv4) ethPkt.getPayload(); + IpAddress gaddr = IpAddress.valueOf(ip.getDestinationAddress()); + IpAddress saddr = Ip4Address.valueOf(ip.getSourceAddress()); + log.debug("Packet (" + saddr.toString() + ", " + gaddr.toString() + + "\tingress port: " + context.inPacket().receivedFrom().toString()); + + if (ip.getProtocol() != IPv4.PROTOCOL_PIM) { + log.debug("PIM Picked up a non PIM packet: IP protocol: " + ip.getProtocol()); + return; + } + + // TODO: check incoming to be PIM.PIM_ADDRESS or "Our" address. + IpPrefix spfx = IpPrefix.valueOf(saddr, 32); + IpPrefix gpfx = IpPrefix.valueOf(gaddr, 32); + + PIM pim = (PIM) ip.getPayload(); + switch (pim.getPimMsgType()) { + + case PIM.TYPE_HELLO: + processHello(ethPkt, context.inPacket().receivedFrom()); + break; + + case PIM.TYPE_JOIN_PRUNE_REQUEST: + // Create the function + break; + + case PIM.TYPE_ASSERT: + case PIM.TYPE_BOOTSTRAP: + case PIM.TYPE_CANDIDATE_RP_ADV: + case PIM.TYPE_GRAFT: + case PIM.TYPE_GRAFT_ACK: + case PIM.TYPE_REGISTER: + case PIM.TYPE_REGISTER_STOP: + log.debug("Unsupported PIM message type: " + pim.getPimMsgType()); + break; + + default: + log.debug("Unkown PIM message type: " + pim.getPimMsgType()); + break; + } + } + + /** + * Process incoming hello message, we will need the Macaddress and IP address of the sender. + * + * @param ethPkt the ethernet header + * @param receivedFrom the connect point we recieved this message from + */ + private void processHello(Ethernet ethPkt, ConnectPoint receivedFrom) { + checkNotNull(ethPkt); + checkNotNull(receivedFrom); + + // It is a problem if we don't have the + PIMInterfaces pintfs = PIMInterfaces.getInstance(); + PIMInterface intf = pintfs.getInterface(receivedFrom); + if (intf == null) { + log.error("We received a PIM message on an interface we were not supposed to"); + return; + } + intf.processHello(ethPkt, receivedFrom); + } + } + + // Create an ethernet header and serialize then send + public void sendPacket(PIM pim, PIMInterface pimIntf) { + + Interface theInterface = pimIntf.getInterface(); + + // Create the ethernet packet + Ethernet eth = new Ethernet(); + eth.setDestinationMACAddress(pimDestinationMac); + eth.setSourceMACAddress(theInterface.mac()); + eth.setEtherType(Ethernet.TYPE_IPV4); + if (theInterface.vlan() != VlanId.NONE) { + eth.setVlanID(theInterface.vlan().toShort()); + } + + // Create the IP Packet + IPv4 ip = new IPv4(); + ip.setVersion((byte) 4); + ip.setTtl((byte) 20); + ip.setProtocol(IPv4.PROTOCOL_PIM); + ip.setChecksum((short) 0); + ip.setSourceAddress(checkNotNull(pimIntf.getIpAddress()).getIp4Address().toInt()); + ip.setDestinationAddress(PIM.PIM_ADDRESS.getIp4Address().toInt()); + eth.setPayload(ip); + ip.setParent(eth); + + // Now set pim + ip.setPayload(pim); + pim.setParent(ip); + + ConnectPoint cp = theInterface.connectPoint(); + checkNotNull(cp); + + TrafficTreatment treat = DefaultTrafficTreatment.builder().setOutput(cp.port()).build(); + ByteBuffer bb = ByteBuffer.wrap(eth.serialize()); + OutboundPacket packet = new DefaultOutboundPacket(cp.deviceId(), treat, bb); + checkNotNull(packet); + + packetService.emit(packet); + } +} diff --git a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMTimer.java b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMTimer.java index c131a53b..c2a33033 100644 --- a/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMTimer.java +++ b/framework/src/onos/apps/pim/src/main/java/org/onosproject/pim/impl/PIMTimer.java @@ -17,6 +17,8 @@ package org.onosproject.pim.impl; import org.jboss.netty.util.HashedWheelTimer; +import static com.google.common.base.Preconditions.checkNotNull; + /** * PIM Timer used for PIM Neighbors. */ @@ -50,4 +52,21 @@ public final class PIMTimer { PIMTimer.timer = hwTimer; } } + + public static void start() { + if (PIMTimer.timer == null) { + getTimer(); + } + checkNotNull(timer); + timer.start(); + } + + public static void stop() { + if (PIMTimer.timer == null) { + // No need to stop + return; + } + checkNotNull(timer); + timer.stop(); + } } diff --git a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteEntry.java b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteEntry.java index 974da808..24d1a8da 100644 --- a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteEntry.java +++ b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpRouteEntry.java @@ -421,7 +421,7 @@ public class BgpRouteEntry extends RouteEntry { @Override public int hashCode() { - return Objects.hash(pathSegments); + return pathSegments.hashCode(); } @Override diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java index eaabed33..f2d5b5e2 100644 --- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java +++ b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java @@ -49,9 +49,9 @@ public class IntentSynchronizer implements IntentSynchronizationService { private final Map intents; // - // State to deal with SDN-IP Leader election and pushing Intents + // State to deal with the Leader election and pushing Intents // - private final ExecutorService bgpIntentsSynchronizerExecutor; + private final ExecutorService intentsSynchronizerExecutor; private volatile boolean isElectedLeader = false; private volatile boolean isActivatedLeader = false; @@ -61,9 +61,9 @@ public class IntentSynchronizer implements IntentSynchronizationService { * @param appId the Application ID * @param intentService the intent service */ - IntentSynchronizer(ApplicationId appId, IntentService intentService) { + public IntentSynchronizer(ApplicationId appId, IntentService intentService) { this(appId, intentService, - newSingleThreadExecutor(groupedThreads("onos/sdnip", "sync"))); + newSingleThreadExecutor(groupedThreads("onos/" + appId, "sync"))); } /** @@ -80,7 +80,7 @@ public class IntentSynchronizer implements IntentSynchronizationService { intents = new ConcurrentHashMap<>(); - bgpIntentsSynchronizerExecutor = executorService; + intentsSynchronizerExecutor = executorService; } /** @@ -96,10 +96,10 @@ public class IntentSynchronizer implements IntentSynchronizationService { public void stop() { synchronized (this) { // Stop the thread(s) - bgpIntentsSynchronizerExecutor.shutdownNow(); + intentsSynchronizerExecutor.shutdownNow(); // - // Withdraw all SDN-IP intents + // Withdraw all app related intents // if (!isElectedLeader) { return; // Nothing to do: not the leader anymore @@ -115,7 +115,7 @@ public class IntentSynchronizer implements IntentSynchronizationService { // Build a batch operation to withdraw all intents from this // application. // - log.debug("SDN-IP Intent Synchronizer shutdown: " + + log.debug("Intent Synchronizer shutdown: " + "withdrawing all intents..."); IntentOperations.Builder builder = IntentOperations.builder(appId); for (Intent intent : intentService.getIntents()) { @@ -133,7 +133,7 @@ public class IntentSynchronizer implements IntentSynchronizationService { continue; } - log.trace("SDN-IP Intent Synchronizer withdrawing intent: {}", + log.trace("Intent Synchronizer withdrawing intent: {}", intent); builder.addWithdrawOperation(intent.id()); } @@ -143,7 +143,7 @@ public class IntentSynchronizer implements IntentSynchronizationService { peerIntents.clear(); routeIntents.clear(); - log.debug("SDN-IP Intent Synchronizer shutdown completed"); + log.debug("Intent Synchronizer shutdown completed"); */ } } @@ -153,7 +153,7 @@ public class IntentSynchronizer implements IntentSynchronizationService { synchronized (this) { intents.put(intent.key(), intent); if (isElectedLeader && isActivatedLeader) { - log.trace("SDN-IP Submitting intent: {}", intent); + log.trace("Submitting intent: {}", intent); intentService.submit(intent); } } @@ -164,19 +164,19 @@ public class IntentSynchronizer implements IntentSynchronizationService { synchronized (this) { intents.remove(intent.key(), intent); if (isElectedLeader && isActivatedLeader) { - log.trace("SDN-IP Withdrawing intent: {}", intent); + log.trace("Withdrawing intent: {}", intent); intentService.withdraw(intent); } } } /** - * Signals the synchronizer that the SDN-IP leadership has changed. + * Signals the synchronizer that the leadership has changed. * * @param isLeader true if this instance is now the leader, otherwise false */ public void leaderChanged(boolean isLeader) { - log.debug("SDN-IP Leader changed: {}", isLeader); + log.debug("Leader changed: {}", isLeader); if (!isLeader) { this.isElectedLeader = false; @@ -187,7 +187,7 @@ public class IntentSynchronizer implements IntentSynchronizationService { this.isElectedLeader = true; // Run the synchronization method off-thread - bgpIntentsSynchronizerExecutor.execute(this::synchronizeIntents); + intentsSynchronizerExecutor.execute(this::synchronizeIntents); } private void synchronizeIntents() { @@ -225,17 +225,17 @@ public class IntentSynchronizer implements IntentSynchronizationService { } } - log.debug("SDN-IP Intent Synchronizer: submitting {}, withdrawing {}", + log.debug("Intent Synchronizer: submitting {}, withdrawing {}", intentsToAdd.size(), intentsToRemove.size()); // Withdraw Intents for (Intent intent : intentsToRemove) { intentService.withdraw(intent); - log.trace("SDN-IP Intent Synchronizer: withdrawing intent: {}", + log.trace("Intent Synchronizer: withdrawing intent: {}", intent); } if (!isElectedLeader) { - log.debug("SDN-IP Intent Synchronizer: cannot withdraw intents: " + + log.debug("Intent Synchronizer: cannot withdraw intents: " + "not elected leader anymore"); isActivatedLeader = false; return; @@ -244,11 +244,11 @@ public class IntentSynchronizer implements IntentSynchronizationService { // Add Intents for (Intent intent : intentsToAdd) { intentService.submit(intent); - log.trace("SDN-IP Intent Synchronizer: submitting intent: {}", + log.trace("Intent Synchronizer: submitting intent: {}", intent); } if (!isElectedLeader) { - log.debug("SDN-IP Intent Synchronizer: cannot submit intents: " + + log.debug("Intent Synchronizer: cannot submit intents: " + "not elected leader anymore"); isActivatedLeader = false; return; @@ -259,7 +259,7 @@ public class IntentSynchronizer implements IntentSynchronizationService { } else { isActivatedLeader = false; } - log.debug("SDN-IP intent synchronization completed"); + log.debug("Intent synchronization completed"); } } diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultTunnel.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultTunnel.java index 8c6fbe8d..70161432 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultTunnel.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DefaultTunnel.java @@ -17,8 +17,6 @@ package org.onosproject.segmentrouting; import java.util.List; -import java.util.Objects; - import static com.google.common.base.Preconditions.checkNotNull; /** @@ -96,7 +94,7 @@ public class DefaultTunnel implements Tunnel { @Override public int hashCode() { - return Objects.hash(labelIds); + return labelIds.hashCode(); } @Override diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java index 9d60b279..b82752d6 100644 --- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java +++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java @@ -596,29 +596,35 @@ public class SegmentRoutingManager implements SegmentRoutingService { private void processDeviceAdded(Device device) { log.debug("A new device with ID {} was added", device.id()); + if (deviceConfiguration == null) { + log.warn("Device configuration uploading. Device {} will be " + + "processed after config completes.", device.id()); + return; + } // Irrespective of whether the local is a MASTER or not for this device, // we need to create a SR-group-handler instance. This is because in a // multi-instance setup, any instance can initiate forwarding/next-objectives // for any switch (even if this instance is a SLAVE or not even connected // to the switch). To handle this, a default-group-handler instance is necessary // per switch. - DefaultGroupHandler groupHandler = DefaultGroupHandler. - createGroupHandler(device.id(), - appId, - deviceConfiguration, - linkService, - flowObjectiveService, - nsNextObjStore, - subnetNextObjStore); - groupHandlerMap.put(device.id(), groupHandler); - - // Also, in some cases, drivers may need extra - // information to process rules (eg. Router IP/MAC); and so, we send - // port addressing rules to the driver as well irrespective of whether - // this instance is the master or not. - defaultRoutingHandler.populatePortAddressingRules(device.id()); - + if (groupHandlerMap.get(device.id()) == null) { + DefaultGroupHandler groupHandler = DefaultGroupHandler. + createGroupHandler(device.id(), + appId, + deviceConfiguration, + linkService, + flowObjectiveService, + nsNextObjStore, + subnetNextObjStore); + groupHandlerMap.put(device.id(), groupHandler); + // Also, in some cases, drivers may need extra + // information to process rules (eg. Router IP/MAC); and so, we send + // port addressing rules to the driver as well irrespective of whether + // this instance is the master or not. + defaultRoutingHandler.populatePortAddressingRules(device.id()); + } if (mastershipService.isLocalMaster(device.id())) { + DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id()); groupHandler.createGroupsFromSubnetConfig(); } } @@ -660,21 +666,23 @@ public class SegmentRoutingManager implements SegmentRoutingService { // for any switch (even if this instance is a SLAVE or not even connected // to the switch). To handle this, a default-group-handler instance is necessary // per switch. - DefaultGroupHandler groupHandler = DefaultGroupHandler - .createGroupHandler(device.id(), appId, - deviceConfiguration, linkService, - flowObjectiveService, - nsNextObjStore, - subnetNextObjStore); - groupHandlerMap.put(device.id(), groupHandler); - - // Also, in some cases, drivers may need extra - // information to process rules (eg. Router IP/MAC); and so, we send - // port addressing rules to the driver as well, irrespective of whether - // this instance is the master or not. - defaultRoutingHandler.populatePortAddressingRules(device.id()); - + if (groupHandlerMap.get(device.id()) == null) { + DefaultGroupHandler groupHandler = DefaultGroupHandler + .createGroupHandler(device.id(), appId, + deviceConfiguration, linkService, + flowObjectiveService, + nsNextObjStore, + subnetNextObjStore); + groupHandlerMap.put(device.id(), groupHandler); + + // Also, in some cases, drivers may need extra + // information to process rules (eg. Router IP/MAC); and so, we send + // port addressing rules to the driver as well, irrespective of whether + // this instance is the master or not. + defaultRoutingHandler.populatePortAddressingRules(device.id()); + } if (mastershipService.isLocalMaster(device.id())) { + DefaultGroupHandler groupHandler = groupHandlerMap.get(device.id()); groupHandler.createGroupsFromSubnetConfig(); } } diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java index c715d08a..7dca32de 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java @@ -49,7 +49,7 @@ public final class BindingHostId { @Override public int hashCode() { - return Objects.hash(bindingHostId); + return bindingHostId.hashCode(); } @Override diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifierId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifierId.java index b789abe3..df180ebe 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifierId.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifierId.java @@ -15,6 +15,8 @@ */ package org.onosproject.vtnrsc; +import static com.google.common.base.Preconditions.checkNotNull; + import com.google.common.base.MoreObjects; import java.util.UUID; @@ -33,6 +35,7 @@ public final class FlowClassifierId { * @param flowClassifierId flow classifier id. */ private FlowClassifierId(final UUID flowClassifierId) { + checkNotNull(flowClassifierId, "Flow classifier id can not be null"); this.flowClassifierId = flowClassifierId; } @@ -42,7 +45,7 @@ public final class FlowClassifierId { * @param flowClassifierId flow classifier id * @return new flow classifier id */ - public static FlowClassifierId flowClassifierId(final UUID flowClassifierId) { + public static FlowClassifierId of(final UUID flowClassifierId) { return new FlowClassifierId(flowClassifierId); } @@ -52,7 +55,7 @@ public final class FlowClassifierId { * @param flowClassifierId flow classifier id * @return new flow classifier id */ - public static FlowClassifierId flowClassifierId(final String flowClassifierId) { + public static FlowClassifierId of(final String flowClassifierId) { return new FlowClassifierId(UUID.fromString(flowClassifierId)); } diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java index e96e666a..30631d28 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java @@ -53,7 +53,7 @@ public final class PhysicalNetwork { @Override public int hashCode() { - return Objects.hash(physicalNetwork); + return physicalNetwork.hashCode(); } @Override diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java index 66edbdcc..a42a700f 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java @@ -19,8 +19,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; import static com.google.common.base.Preconditions.checkNotNull; import java.util.UUID; - -import com.google.common.base.Objects; +import java.util.Objects; /** * Representation of a Port Chain ID. @@ -40,22 +39,22 @@ public final class PortChainId { } /** - * Constructor to create port chain id from UUID. + * Returns newly created port chain id object. * * @param id UUID of port chain * @return object of port chain id */ - public static PortChainId portChainId(UUID id) { + public static PortChainId of(UUID id) { return new PortChainId(id); } /** - * Constructor to create port chain id from string. + * Returns newly created port chain id object. * * @param id port chain id in string * @return object of port chain id */ - public static PortChainId portChainId(String id) { + public static PortChainId of(String id) { return new PortChainId(UUID.fromString(id)); } @@ -73,10 +72,9 @@ public final class PortChainId { if (this == obj) { return true; } - - if (obj.getClass() == this.getClass()) { - PortChainId that = (PortChainId) obj; - return Objects.equal(this.portChainId, that.portChainId); + if (obj instanceof PortChainId) { + final PortChainId other = (PortChainId) obj; + return Objects.equals(this.portChainId, other.portChainId); } return false; } @@ -88,8 +86,6 @@ public final class PortChainId { @Override public String toString() { - return toStringHelper(this) - .add("portChainId", portChainId.toString()) - .toString(); + return toStringHelper(this).add("portChainId", portChainId).toString(); } } diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroupId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroupId.java index 0474901c..a52a2bb3 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroupId.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroupId.java @@ -19,8 +19,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; import static com.google.common.base.Preconditions.checkNotNull; import java.util.UUID; - -import com.google.common.base.Objects; +import java.util.Objects; /** * Representation of a Port Pair Group ID. @@ -40,22 +39,22 @@ public final class PortPairGroupId { } /** - * Constructor to create port pair group id from UUID. + * Returns newly created port pair group id object. * - * @param id UUID of port pair group id + * @param id port pair group id in UUID * @return object of port pair group id */ - public static PortPairGroupId portPairGroupId(UUID id) { + public static PortPairGroupId of(UUID id) { return new PortPairGroupId(id); } /** - * Constructor to create port pair group id from string. + * Returns newly created port pair group id object. * * @param id port pair group id in string * @return object of port pair group id */ - public static PortPairGroupId portPairGroupId(String id) { + public static PortPairGroupId of(String id) { return new PortPairGroupId(UUID.fromString(id)); } @@ -73,10 +72,9 @@ public final class PortPairGroupId { if (this == obj) { return true; } - - if (obj.getClass() == this.getClass()) { - PortPairGroupId that = (PortPairGroupId) obj; - return Objects.equal(this.portPairGroupId, that.portPairGroupId); + if (obj instanceof PortPairGroupId) { + final PortPairGroupId other = (PortPairGroupId) obj; + return Objects.equals(this.portPairGroupId, other.portPairGroupId); } return false; } @@ -88,8 +86,7 @@ public final class PortPairGroupId { @Override public String toString() { - return toStringHelper(this) - .add("portPairGroupId", portPairGroupId.toString()) + return toStringHelper(this).add("portPairGroupId", portPairGroupId) .toString(); } } diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairId.java index 05c31aac..1f45e80e 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairId.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairId.java @@ -19,8 +19,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; import static com.google.common.base.Preconditions.checkNotNull; import java.util.UUID; - -import com.google.common.base.Objects; +import java.util.Objects; /** * Representation of a Port Pair ID. @@ -40,22 +39,22 @@ public final class PortPairId { } /** - * Constructor to create port pair id from UUID. + * Returns newly created port pair id object. * * @param id UUID of port pair id * @return object of port pair id */ - public static PortPairId portPairId(UUID id) { + public static PortPairId of(UUID id) { return new PortPairId(id); } /** - * Constructor to create port pair id from string. + * Returns newly created port pair id object. * * @param id port pair id in string * @return object of port pair id */ - public static PortPairId portPairId(String id) { + public static PortPairId of(String id) { return new PortPairId(UUID.fromString(id)); } @@ -73,10 +72,9 @@ public final class PortPairId { if (this == obj) { return true; } - - if (obj.getClass() == this.getClass()) { - PortPairId that = (PortPairId) obj; - return Objects.equal(this.portPairId, that.portPairId); + if (obj instanceof PortPairId) { + final PortPairId other = (PortPairId) obj; + return Objects.equals(this.portPairId, other.portPairId); } return false; } @@ -89,7 +87,7 @@ public final class PortPairId { @Override public String toString() { return toStringHelper(this) - .add("portPairId", portPairId.toString()) + .add("portPairId", portPairId) .toString(); } } diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java index 9ec1dc63..33ddcbfe 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java @@ -52,7 +52,7 @@ public final class SecurityGroup { @Override public int hashCode() { - return Objects.hash(securityGroup); + return securityGroup.hashCode(); } @Override diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java index a076265f..651ebd89 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java @@ -53,7 +53,7 @@ public final class SegmentationId { @Override public int hashCode() { - return Objects.hash(segmentationId); + return segmentationId.hashCode(); } @Override diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java index 4bcc3329..eb93d153 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java @@ -53,7 +53,7 @@ public final class SubnetId { @Override public int hashCode() { - return Objects.hash(subnetId); + return subnetId.hashCode(); } @Override diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java index c4d99e49..0e7c9417 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java @@ -53,7 +53,7 @@ public final class TenantId { @Override public int hashCode() { - return Objects.hash(tenantId); + return tenantId.hashCode(); } @Override diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java index fbb9e480..8680d28f 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java @@ -52,7 +52,7 @@ public final class TenantNetworkId { @Override public int hashCode() { - return Objects.hash(networkId); + return networkId.hashCode(); } @Override diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java index 3038bdff..a3863483 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java @@ -46,7 +46,7 @@ public final class VirtualPortId { @Override public int hashCode() { - return Objects.hash(portId); + return portId.hashCode(); } @Override diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/FlowClassifierManager.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/FlowClassifierManager.java index 7238558a..ca01c434 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/FlowClassifierManager.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/FlowClassifierManager.java @@ -15,21 +15,26 @@ */ package org.onosproject.vtnrsc.flowClassifier.impl; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.Service; +import org.onlab.util.KryoNamespace; +import org.onosproject.store.serializers.KryoNamespaces; +import org.onosproject.store.service.EventuallyConsistentMap; +import org.onosproject.store.service.MultiValuedTimestamp; +import org.onosproject.store.service.StorageService; +import org.onosproject.store.service.WallClockTimestamp; import org.onosproject.vtnrsc.FlowClassifierId; import org.onosproject.vtnrsc.FlowClassifier; import org.onosproject.vtnrsc.flowClassifier.FlowClassifierService; - import org.slf4j.Logger; -import static org.slf4j.LoggerFactory.getLogger; +import static org.slf4j.LoggerFactory.getLogger; import static com.google.common.base.Preconditions.checkNotNull; + import com.google.common.collect.ImmutableList; /** @@ -44,16 +49,26 @@ public class FlowClassifierManager implements FlowClassifierService { private static final String FLOW_CLASSIFIER_NOT_NULL = "Flow Classifier cannot be null"; private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "Flow Classifier Id cannot be null"; - private ConcurrentMap flowClassifierStore - = new ConcurrentHashMap(); + private EventuallyConsistentMap flowClassifierStore; + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected StorageService storageService; @Activate private void activate() { + KryoNamespace.Builder serializer = KryoNamespace.newBuilder() + .register(KryoNamespaces.API) + .register(MultiValuedTimestamp.class) + .register(FlowClassifier.class); + flowClassifierStore = storageService + .eventuallyConsistentMapBuilder() + .withName("flowclassifierstore").withSerializer(serializer) + .withTimestampProvider((k, v) -> new WallClockTimestamp()).build(); log.info("Flow Classifier service activated"); } @Deactivate private void deactivate() { + flowClassifierStore.destroy(); log.info("Flow Classifier service deactivated"); } @@ -92,7 +107,8 @@ public class FlowClassifierManager implements FlowClassifierService { public boolean updateFlowClassifier(FlowClassifier flowClassifier) { checkNotNull(flowClassifier, FLOW_CLASSIFIER_NOT_NULL); FlowClassifierId id = flowClassifier.flowClassifierId(); - return flowClassifierStore.replace(id, flowClassifierStore.get(id), flowClassifier); + flowClassifierStore.put(id, flowClassifier); + return true; } @Override diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/PortChainManager.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/PortChainManager.java new file mode 100644 index 00000000..5201a2ca --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/PortChainManager.java @@ -0,0 +1,146 @@ +/* + * 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.vtnrsc.portchain.impl; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.slf4j.LoggerFactory.getLogger; + +import java.util.Collections; + +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.ReferenceCardinality; +import org.apache.felix.scr.annotations.Service; +import org.onlab.util.KryoNamespace; +import org.onosproject.store.serializers.KryoNamespaces; +import org.onosproject.store.service.EventuallyConsistentMap; +import org.onosproject.store.service.MultiValuedTimestamp; +import org.onosproject.store.service.StorageService; +import org.onosproject.store.service.WallClockTimestamp; +import org.onosproject.vtnrsc.PortChain; +import org.onosproject.vtnrsc.PortChainId; +import org.onosproject.vtnrsc.portchain.PortChainService; +import org.slf4j.Logger; + +/** + * Provides implementation of the portChainService. + */ +@Component(immediate = true) +@Service +public class PortChainManager implements PortChainService { + + private final Logger log = getLogger(getClass()); + + private static final String PORT_CHAIN_ID_NULL = "PortChain ID cannot be null"; + private static final String PORT_CHAIN_NULL = "PortChain cannot be null"; + + private EventuallyConsistentMap portChainStore; + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected StorageService storageService; + + @Activate + public void activate() { + + KryoNamespace.Builder serializer = KryoNamespace.newBuilder() + .register(KryoNamespaces.API) + .register(MultiValuedTimestamp.class) + .register(PortChain.class); + + portChainStore = storageService + .eventuallyConsistentMapBuilder() + .withName("portchainstore").withSerializer(serializer) + .withTimestampProvider((k, v) -> new WallClockTimestamp()).build(); + + log.info("Started"); + } + + @Deactivate + public void deactivate() { + portChainStore.destroy(); + log.info("Stopped"); + } + + @Override + public boolean exists(PortChainId portChainId) { + checkNotNull(portChainId, PORT_CHAIN_ID_NULL); + return portChainStore.containsKey(portChainId); + } + + @Override + public int getPortChainCount() { + return portChainStore.size(); + } + + @Override + public Iterable getPortChains() { + return Collections.unmodifiableCollection(portChainStore.values()); + } + + @Override + public PortChain getPortChain(PortChainId portChainId) { + checkNotNull(portChainId, PORT_CHAIN_ID_NULL); + return portChainStore.get(portChainId); + } + + @Override + public boolean createPortChain(PortChain portChain) { + checkNotNull(portChain, PORT_CHAIN_NULL); + + portChainStore.put(portChain.portChainId(), portChain); + if (!portChainStore.containsKey(portChain.portChainId())) { + log.debug("The portChain is created failed which identifier was {}", portChain.portChainId() + .toString()); + return false; + } + return true; + } + + @Override + public boolean updatePortChain(PortChain portChain) { + checkNotNull(portChain, PORT_CHAIN_NULL); + + if (!portChainStore.containsKey(portChain.portChainId())) { + log.debug("The portChain is not exist whose identifier was {} ", + portChain.portChainId().toString()); + return false; + } + + portChainStore.put(portChain.portChainId(), portChain); + + if (!portChain.equals(portChainStore.get(portChain.portChainId()))) { + log.debug("The portChain is updated failed whose identifier was {} ", + portChain.portChainId().toString()); + return false; + } + return true; + } + + @Override + public boolean removePortChain(PortChainId portChainId) { + checkNotNull(portChainId, PORT_CHAIN_NULL); + + portChainStore.remove(portChainId); + if (portChainStore.containsKey(portChainId)) { + log.debug("The portChain is removed failed whose identifier was {}", + portChainId.toString()); + return false; + } + return true; + } +} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/package-info.java new file mode 100644 index 00000000..424d54ab --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/impl/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** + * Implementation of service for interacting with the inventory of port chains. + */ +package org.onosproject.vtnrsc.portchain.impl; diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairService.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairService.java new file mode 100644 index 00000000..f99cc2cf --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/PortPairService.java @@ -0,0 +1,80 @@ +/* + * 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.vtnrsc.portpair; + +import org.onosproject.vtnrsc.PortPair; +import org.onosproject.vtnrsc.PortPairId; + +/** + * Service for interacting with the inventory of port pairs. + */ +public interface PortPairService { + + /** + * Returns if the port pair is existed. + * + * @param portPairId port pair identifier + * @return true or false if one with the given identifier exists. + */ + boolean exists(PortPairId portPairId); + + /** + * Returns the number of port pairs known to the system. + * + * @return number of port pairs. + */ + int getPortPairCount(); + + /** + * Returns an iterable collection of the currently known port pairs. + * + * @return collection of port pairs. + */ + Iterable getPortPairs(); + + /** + * Returns the portPair with the given identifier. + * + * @param portPairId port pair identifier + * @return PortPair or null if port pair with the given identifier is not + * known. + */ + PortPair getPortPair(PortPairId portPairId); + + /** + * Creates a PortPair in the store. + * + * @param portPair the port pair to create + * @return true if given port pair is created successfully. + */ + boolean createPortPair(PortPair portPair); + + /** + * Updates the portPair in the store. + * + * @param portPair the port pair to update + * @return true if given port pair is updated successfully. + */ + boolean updatePortPair(PortPair portPair); + + /** + * Deletes portPair by given portPairId. + * + * @param portPairId id of port pair to remove + * @return true if the give port pair is deleted successfully. + */ + boolean removePortPair(PortPairId portPairId); +} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/PortPairManager.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/PortPairManager.java new file mode 100644 index 00000000..93c8782a --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/PortPairManager.java @@ -0,0 +1,146 @@ +/* + * 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.vtnrsc.portpair.impl; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.slf4j.LoggerFactory.getLogger; + +import java.util.Collections; + +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.ReferenceCardinality; +import org.apache.felix.scr.annotations.Service; +import org.onlab.util.KryoNamespace; +import org.onosproject.store.serializers.KryoNamespaces; +import org.onosproject.store.service.EventuallyConsistentMap; +import org.onosproject.store.service.MultiValuedTimestamp; +import org.onosproject.store.service.StorageService; +import org.onosproject.store.service.WallClockTimestamp; +import org.onosproject.vtnrsc.PortPair; +import org.onosproject.vtnrsc.PortPairId; +import org.onosproject.vtnrsc.portpair.PortPairService; +import org.slf4j.Logger; + +/** + * Provides implementation of the portPairService. + */ +@Component(immediate = true) +@Service +public class PortPairManager implements PortPairService { + + private final Logger log = getLogger(getClass()); + + private static final String PORT_PAIR_ID_NULL = "PortPair ID cannot be null"; + private static final String PORT_PAIR_NULL = "PortPair cannot be null"; + + private EventuallyConsistentMap portPairStore; + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected StorageService storageService; + + @Activate + public void activate() { + + KryoNamespace.Builder serializer = KryoNamespace.newBuilder() + .register(KryoNamespaces.API) + .register(MultiValuedTimestamp.class) + .register(PortPair.class); + + portPairStore = storageService + .eventuallyConsistentMapBuilder() + .withName("portpairstore").withSerializer(serializer) + .withTimestampProvider((k, v) -> new WallClockTimestamp()).build(); + + log.info("Started"); + } + + @Deactivate + public void deactivate() { + portPairStore.destroy(); + log.info("Stopped"); + } + + @Override + public boolean exists(PortPairId portPairId) { + checkNotNull(portPairId, PORT_PAIR_ID_NULL); + return portPairStore.containsKey(portPairId); + } + + @Override + public int getPortPairCount() { + return portPairStore.size(); + } + + @Override + public Iterable getPortPairs() { + return Collections.unmodifiableCollection(portPairStore.values()); + } + + @Override + public PortPair getPortPair(PortPairId portPairId) { + checkNotNull(portPairId, PORT_PAIR_ID_NULL); + return portPairStore.get(portPairId); + } + + @Override + public boolean createPortPair(PortPair portPair) { + checkNotNull(portPair, PORT_PAIR_NULL); + + portPairStore.put(portPair.portPairId(), portPair); + if (!portPairStore.containsKey(portPair.portPairId())) { + log.debug("The portPair is created failed which identifier was {}", portPair.portPairId() + .toString()); + return false; + } + return true; + } + + @Override + public boolean updatePortPair(PortPair portPair) { + checkNotNull(portPair, PORT_PAIR_NULL); + + if (!portPairStore.containsKey(portPair.portPairId())) { + log.debug("The portPair is not exist whose identifier was {} ", + portPair.portPairId().toString()); + return false; + } + + portPairStore.put(portPair.portPairId(), portPair); + + if (!portPair.equals(portPairStore.get(portPair.portPairId()))) { + log.debug("The portPair is updated failed whose identifier was {} ", + portPair.portPairId().toString()); + return false; + } + return true; + } + + @Override + public boolean removePortPair(PortPairId portPairId) { + checkNotNull(portPairId, PORT_PAIR_NULL); + + portPairStore.remove(portPairId); + if (portPairStore.containsKey(portPairId)) { + log.debug("The portPair is removed failed whose identifier was {}", + portPairId.toString()); + return false; + } + return true; + } +} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/package-info.java new file mode 100644 index 00000000..625fbdd4 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/impl/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** + * Implementation of service for interacting with the inventory of port pairs. + */ +package org.onosproject.vtnrsc.portpair.impl; diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/package-info.java new file mode 100644 index 00000000..e2c61531 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpair/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** + * Service for interacting with the inventory of port pairs. + */ +package org.onosproject.vtnrsc.portpair; diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/PortPairGroupManager.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/PortPairGroupManager.java new file mode 100644 index 00000000..55fb4e43 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/PortPairGroupManager.java @@ -0,0 +1,146 @@ +/* + * 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.vtnrsc.portpairgroup.impl; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.slf4j.LoggerFactory.getLogger; + +import java.util.Collections; + +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.ReferenceCardinality; +import org.apache.felix.scr.annotations.Service; +import org.onlab.util.KryoNamespace; +import org.onosproject.store.serializers.KryoNamespaces; +import org.onosproject.store.service.EventuallyConsistentMap; +import org.onosproject.store.service.MultiValuedTimestamp; +import org.onosproject.store.service.StorageService; +import org.onosproject.store.service.WallClockTimestamp; +import org.onosproject.vtnrsc.PortPairGroup; +import org.onosproject.vtnrsc.PortPairGroupId; +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; +import org.slf4j.Logger; + +/** + * Provides implementation of the portPairGroupService. + */ +@Component(immediate = true) +@Service +public class PortPairGroupManager implements PortPairGroupService { + + private final Logger log = getLogger(getClass()); + + private static final String PORT_PAIR_GROUP_ID_NULL = "PortPairGroup ID cannot be null"; + private static final String PORT_PAIR_GROUP_NULL = "PortPairGroup cannot be null"; + + private EventuallyConsistentMap portPairGroupStore; + + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected StorageService storageService; + + @Activate + public void activate() { + + KryoNamespace.Builder serializer = KryoNamespace.newBuilder() + .register(KryoNamespaces.API) + .register(MultiValuedTimestamp.class) + .register(PortPairGroup.class); + + portPairGroupStore = storageService + .eventuallyConsistentMapBuilder() + .withName("portpairgroupstore").withSerializer(serializer) + .withTimestampProvider((k, v) -> new WallClockTimestamp()).build(); + + log.info("Started"); + } + + @Deactivate + public void deactivate() { + portPairGroupStore.destroy(); + log.info("Stopped"); + } + + @Override + public boolean exists(PortPairGroupId portPairGroupId) { + checkNotNull(portPairGroupId, PORT_PAIR_GROUP_ID_NULL); + return portPairGroupStore.containsKey(portPairGroupId); + } + + @Override + public int getPortPairGroupCount() { + return portPairGroupStore.size(); + } + + @Override + public Iterable getPortPairGroups() { + return Collections.unmodifiableCollection(portPairGroupStore.values()); + } + + @Override + public PortPairGroup getPortPairGroup(PortPairGroupId portPairGroupId) { + checkNotNull(portPairGroupId, PORT_PAIR_GROUP_ID_NULL); + return portPairGroupStore.get(portPairGroupId); + } + + @Override + public boolean createPortPairGroup(PortPairGroup portPairGroup) { + checkNotNull(portPairGroup, PORT_PAIR_GROUP_NULL); + + portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup); + if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) { + log.debug("The portPairGroup is created failed which identifier was {}", portPairGroup.portPairGroupId() + .toString()); + return false; + } + return true; + } + + @Override + public boolean updatePortPairGroup(PortPairGroup portPairGroup) { + checkNotNull(portPairGroup, PORT_PAIR_GROUP_NULL); + + if (!portPairGroupStore.containsKey(portPairGroup.portPairGroupId())) { + log.debug("The portPairGroup is not exist whose identifier was {} ", + portPairGroup.portPairGroupId().toString()); + return false; + } + + portPairGroupStore.put(portPairGroup.portPairGroupId(), portPairGroup); + + if (!portPairGroup.equals(portPairGroupStore.get(portPairGroup.portPairGroupId()))) { + log.debug("The portPairGroup is updated failed whose identifier was {} ", + portPairGroup.portPairGroupId().toString()); + return false; + } + return true; + } + + @Override + public boolean removePortPairGroup(PortPairGroupId portPairGroupId) { + checkNotNull(portPairGroupId, PORT_PAIR_GROUP_NULL); + + portPairGroupStore.remove(portPairGroupId); + if (portPairGroupStore.containsKey(portPairGroupId)) { + log.debug("The portPairGroup is removed failed whose identifier was {}", + portPairGroupId.toString()); + return false; + } + return true; + } +} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/package-info.java new file mode 100644 index 00000000..68c186bc --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/impl/package-info.java @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/** + * Implementation of service for interacting with the inventory of port pair groups. + */ +package org.onosproject.vtnrsc.portpairgroup.impl; diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FlowClassifierCodec.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FlowClassifierCodec.java deleted file mode 100644 index fd5b1ee4..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FlowClassifierCodec.java +++ /dev/null @@ -1,134 +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.vtnrsc.web; - -import static com.google.common.base.Preconditions.checkNotNull; -import static org.onlab.util.Tools.nullIsIllegal; - -import java.util.UUID; - -import org.onlab.packet.IpPrefix; -import org.onosproject.codec.CodecContext; -import org.onosproject.codec.JsonCodec; -import org.onosproject.vtnrsc.DefaultFlowClassifier; -import org.onosproject.vtnrsc.FlowClassifier; -import org.onosproject.vtnrsc.FlowClassifierId; -import org.onosproject.vtnrsc.VirtualPortId; -import org.onosproject.vtnrsc.TenantId; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Flow Classifier JSON codec. - */ -public final class FlowClassifierCodec extends JsonCodec { - - private static final String FLOW_CLASSIFIER_ID = "id"; - private static final String TENANT_ID = "tenant_id"; - private static final String NAME = "name"; - private static final String DESCRIPTION = "description"; - private static final String ETHER_TYPE = "etherType"; - private static final String PROTOCOL = "protocol"; - private static final String MIN_SRC_PORT_RANGE = "source_port_range_min"; - private static final String MAX_SRC_PORT_RANGE = "source_port_range_max"; - private static final String MIN_DST_PORT_RANGE = "destination_port_range_min"; - private static final String MAX_DST_PORT_RANGE = "destination_port_range_max"; - private static final String SRC_IP_PREFIX = "source_ip_prefix"; - private static final String DST_IP_PREFIX = "destination_ip_prefix"; - private static final String SRC_PORT = "logical_source_port"; - private static final String DST_PORT = "logical_destination_port"; - private static final String MISSING_MEMBER_MESSAGE = " member is required in Flow Classifier."; - - @Override - public FlowClassifier decode(ObjectNode json, CodecContext context) { - if (json == null || !json.isObject()) { - return null; - } - - FlowClassifier.Builder resultBuilder = new DefaultFlowClassifier.Builder(); - - String flowClassifierId = nullIsIllegal(json.get(FLOW_CLASSIFIER_ID), - FLOW_CLASSIFIER_ID + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setFlowClassifierId(FlowClassifierId.flowClassifierId(UUID.fromString(flowClassifierId))); - - String tenantId = nullIsIllegal(json.get(TENANT_ID), TENANT_ID + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setTenantId(TenantId.tenantId(tenantId)); - - String flowClassiferName = nullIsIllegal(json.get(NAME), NAME + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setName(flowClassiferName); - - String flowClassiferDescription = nullIsIllegal(json.get(DESCRIPTION), DESCRIPTION + MISSING_MEMBER_MESSAGE) - .asText(); - resultBuilder.setDescription(flowClassiferDescription); - - String etherType = nullIsIllegal(json.get(ETHER_TYPE), ETHER_TYPE + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setEtherType(etherType); - - String protocol = nullIsIllegal(json.get(PROTOCOL), PROTOCOL + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setProtocol(protocol); - - int minSrcPortRange = nullIsIllegal(json.get(MIN_SRC_PORT_RANGE), MIN_SRC_PORT_RANGE + MISSING_MEMBER_MESSAGE) - .asInt(); - resultBuilder.setMinSrcPortRange(minSrcPortRange); - - int maxSrcPortRange = nullIsIllegal(json.get(MAX_SRC_PORT_RANGE), MAX_SRC_PORT_RANGE + MISSING_MEMBER_MESSAGE) - .asInt(); - resultBuilder.setMaxSrcPortRange(maxSrcPortRange); - - int minDstPortRange = nullIsIllegal(json.get(MIN_DST_PORT_RANGE), MIN_DST_PORT_RANGE + MISSING_MEMBER_MESSAGE) - .asInt(); - resultBuilder.setMinDstPortRange(minDstPortRange); - - int maxDstPortRange = nullIsIllegal(json.get(MAX_DST_PORT_RANGE), MAX_DST_PORT_RANGE + MISSING_MEMBER_MESSAGE) - .asInt(); - resultBuilder.setMaxDstPortRange(maxDstPortRange); - - String srcIpPrefix = nullIsIllegal(json.get(SRC_IP_PREFIX), SRC_IP_PREFIX + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setSrcIpPrefix(IpPrefix.valueOf(srcIpPrefix)); - - String dstIpPrefix = nullIsIllegal(json.get(DST_IP_PREFIX), DST_IP_PREFIX + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setDstIpPrefix(IpPrefix.valueOf(dstIpPrefix)); - - String srcPort = nullIsIllegal(json.get(SRC_PORT), SRC_PORT + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setSrcPort(VirtualPortId.portId(srcPort)); - - String dstPort = nullIsIllegal(json.get(DST_PORT), DST_PORT + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setDstPort(VirtualPortId.portId(dstPort)); - - return resultBuilder.build(); - } - - @Override - public ObjectNode encode(FlowClassifier flowClassifier, CodecContext context) { - checkNotNull(flowClassifier, "flowClassifier cannot be null"); - ObjectNode result = context.mapper().createObjectNode() - .put("FLOW_CLASSIFIER_ID", flowClassifier.flowClassifierId().toString()) - .put("TENANT_ID", flowClassifier.tenantId().toString()) - .put("NAME", flowClassifier.name()) - .put("DESCRIPTION", flowClassifier.description()) - .put("ETHER_TYPE", flowClassifier.etherType()) - .put("PROTOCOL", flowClassifier.protocol()) - .put("MIN_SRC_PORT_RANGE", flowClassifier.minSrcPortRange()) - .put("MAX_SRC_PORT_RANGE", flowClassifier.maxSrcPortRange()) - .put("MIN_DST_PORT_RANGE", flowClassifier.minDstPortRange()) - .put("MAX_DST_PORT_RANGE", flowClassifier.maxDstPortRange()) - .put("SRC_IP_PREFIX", flowClassifier.srcIpPrefix().toString()) - .put("DST_IP_PREFIX", flowClassifier.dstIpPrefix().toString()) - .put("SRC_PORT", flowClassifier.srcPort().toString()) - .put("DST_PORT", flowClassifier.dstPort().toString()); - return result; - } -} \ No newline at end of file diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java deleted file mode 100644 index 34636a9f..00000000 --- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java +++ /dev/null @@ -1,20 +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. - */ - -/** - * Codecs for virtual tenant objects. - */ -package org.onosproject.vtnrsc.web; diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierIdTest.java index b2fed347..4f521836 100644 --- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierIdTest.java +++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierIdTest.java @@ -32,11 +32,11 @@ import java.util.UUID; public class FlowClassifierIdTest { final FlowClassifierId flowClassifierId1 = FlowClassifierId - .flowClassifierId("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); + .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); final FlowClassifierId sameAsFlowClassifierId1 = FlowClassifierId - .flowClassifierId("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); + .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); final FlowClassifierId flowClassifierId2 = FlowClassifierId - .flowClassifierId("dace4513-24fc-4fae-af4b-321c5e2eb3d1"); + .of("dace4513-24fc-4fae-af4b-321c5e2eb3d1"); /** * Checks that the FlowClassifierId class is immutable. @@ -61,7 +61,7 @@ public class FlowClassifierIdTest { @Test public void testConstruction() { final String flowClassifierIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1"; - final FlowClassifierId flowClassifierId = FlowClassifierId.flowClassifierId(flowClassifierIdValue); + final FlowClassifierId flowClassifierId = FlowClassifierId.of(flowClassifierIdValue); assertThat(flowClassifierId, is(notNullValue())); assertThat(flowClassifierId.value(), is(UUID.fromString(flowClassifierIdValue))); } diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java new file mode 100644 index 00000000..88fecf8d --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java @@ -0,0 +1,65 @@ +/* + * 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.vtnrsc.portpair; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; + +import org.junit.Test; +import org.onosproject.vtnrsc.PortChainId; + +import com.google.common.testing.EqualsTester; +import java.util.UUID; + +/** + * Unit tests for PortChainId class. + */ +public class PortChainIdTest { + + final PortChainId portChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); + final PortChainId sameAsPortChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); + final PortChainId portChainId2 = PortChainId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1"); + + /** + * Checks that the PortChainId class is immutable. + */ + @Test + public void testImmutability() { + assertThatClassIsImmutable(PortChainId.class); + } + + /** + * Checks the operation of equals() methods. + */ + @Test + public void testEquals() { + new EqualsTester().addEqualityGroup(portChainId1, sameAsPortChainId1).addEqualityGroup(portChainId2) + .testEquals(); + } + + /** + * Checks the construction of a PortChainId object. + */ + @Test + public void testConstruction() { + final String portChainIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1"; + final PortChainId portChainId = PortChainId.of(portChainIdValue); + assertThat(portChainId, is(notNullValue())); + assertThat(portChainId.value(), is(UUID.fromString(portChainIdValue))); + } +} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/PortPairIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/PortPairIdTest.java new file mode 100644 index 00000000..f176089e --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/PortPairIdTest.java @@ -0,0 +1,64 @@ +/* + * 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.vtnrsc.portpair; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; + +import org.junit.Test; +import org.onosproject.vtnrsc.PortPairId; + +import com.google.common.testing.EqualsTester; +import java.util.UUID; + +/** + * Unit tests for PortPairId class. + */ +public class PortPairIdTest { + + final PortPairId portPairId1 = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); + final PortPairId sameAsPortPairId1 = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); + final PortPairId portPairId2 = PortPairId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1"); + + /** + * Checks that the PortPairId class is immutable. + */ + @Test + public void testImmutability() { + assertThatClassIsImmutable(PortPairId.class); + } + + /** + * Checks the operation of equals() methods. + */ + @Test + public void testEquals() { + new EqualsTester().addEqualityGroup(portPairId1, sameAsPortPairId1).addEqualityGroup(portPairId2).testEquals(); + } + + /** + * Checks the construction of a PortPairId object. + */ + @Test + public void testConstruction() { + final String portPairIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1"; + final PortPairId portPairId = PortPairId.of(portPairIdValue); + assertThat(portPairId, is(notNullValue())); + assertThat(portPairId.value(), is(UUID.fromString(portPairIdValue))); + } +} diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java new file mode 100644 index 00000000..7da4c489 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java @@ -0,0 +1,66 @@ +/* + * 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.vtnrsc.portpair; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; + +import org.junit.Test; +import org.onosproject.vtnrsc.PortPairGroupId; + +import com.google.common.testing.EqualsTester; +import java.util.UUID; + +/** + * Unit tests for PortPairGroupId class. + */ +public class PortPairGroupIdTest { + + final PortPairGroupId portPairGroupId1 = PortPairGroupId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); + final PortPairGroupId sameAsPortPairGroupId1 = PortPairGroupId + .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); + final PortPairGroupId portPairGroupId2 = PortPairGroupId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1"); + + /** + * Checks that the PortPairGroupId class is immutable. + */ + @Test + public void testImmutability() { + assertThatClassIsImmutable(PortPairGroupId.class); + } + + /** + * Checks the operation of equals() methods. + */ + @Test + public void testEquals() { + new EqualsTester().addEqualityGroup(portPairGroupId1, sameAsPortPairGroupId1) + .addEqualityGroup(portPairGroupId2).testEquals(); + } + + /** + * Checks the construction of a PortPairGroupId object. + */ + @Test + public void testConstruction() { + final String portPairGroupIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1"; + final PortPairGroupId portPairGroupId = PortPairGroupId.of(portPairGroupIdValue); + assertThat(portPairGroupId, is(notNullValue())); + assertThat(portPairGroupId.value(), is(UUID.fromString(portPairGroupIdValue))); + } +} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java index 1450e4ef..b5b8252b 100644 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java @@ -40,7 +40,7 @@ import org.onosproject.vtnrsc.FlowClassifier; import org.onosproject.vtnrsc.FlowClassifierId; import org.onosproject.rest.AbstractWebResource; import org.onosproject.vtnrsc.flowClassifier.FlowClassifierService; -import org.onosproject.vtnrsc.web.FlowClassifierCodec; +import org.onosproject.vtnweb.web.FlowClassifierCodec; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -82,11 +82,11 @@ public class FlowClassifierWebResource extends AbstractWebResource { @Produces(MediaType.APPLICATION_JSON) public Response getFlowClassifier(@PathParam("flow_id") String id) { - if (!service.hasFlowClassifier(FlowClassifierId.flowClassifierId(UUID.fromString(id)))) { + if (!service.hasFlowClassifier(FlowClassifierId.of(UUID.fromString(id)))) { return Response.status(NOT_FOUND).entity(FLOW_CLASSIFIER_NOT_FOUND).build(); } FlowClassifier flowClassifier = nullIsNotFound( - service.getFlowClassifier(FlowClassifierId.flowClassifierId(UUID.fromString(id))), + service.getFlowClassifier(FlowClassifierId.of(UUID.fromString(id))), FLOW_CLASSIFIER_NOT_FOUND); ObjectNode result = new ObjectMapper().createObjectNode(); @@ -182,7 +182,7 @@ public class FlowClassifierWebResource extends AbstractWebResource { @DELETE public Response deleteFlowClassifier(@PathParam("flow_id") String id) throws IOException { try { - FlowClassifierId flowClassifierId = FlowClassifierId.flowClassifierId(UUID.fromString(id)); + FlowClassifierId flowClassifierId = FlowClassifierId.of(UUID.fromString(id)); service.removeFlowClassifier(flowClassifierId); return Response.status(201).entity("SUCCESS").build(); } catch (Exception e) { diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java new file mode 100644 index 00000000..db12bcc7 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortChainWebResource.java @@ -0,0 +1,157 @@ +/* + * 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.vtnweb.resources; + +import static javax.ws.rs.core.Response.Status.NOT_FOUND; +import static javax.ws.rs.core.Response.Status.OK; +import static org.onlab.util.Tools.nullIsNotFound; + +import java.io.IOException; +import java.io.InputStream; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.onosproject.rest.AbstractWebResource; +import org.onosproject.vtnrsc.PortChain; +import org.onosproject.vtnrsc.PortChainId; +import org.onosproject.vtnrsc.portchain.PortChainService; +import org.onosproject.vtnweb.web.PortChainCodec; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * Query and program port chain. + */ + +@Path("port_chains") +public class PortChainWebResource extends AbstractWebResource { + + private final Logger log = LoggerFactory.getLogger(PortChainWebResource.class); + private final PortChainService service = get(PortChainService.class); + public static final String PORT_CHAIN_NOT_FOUND = "Port chain not found"; + public static final String PORT_CHAIN_ID_EXIST = "Port chain exists"; + public static final String PORT_CHAIN_ID_NOT_EXIST = "Port chain does not exist with identifier"; + + /** + * Get details of all port chains created. + * + * @return 200 OK + */ + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getPortChains() { + Iterable portChains = service.getPortChains(); + ObjectNode result = new ObjectMapper().createObjectNode(); + result.set("port_chains", new PortChainCodec().encode(portChains, this)); + return ok(result).build(); + } + + /** + * Get details of a specified port chain id. + * + * @param id port chain id + * @return 200 OK, 404 if given identifier does not exist + */ + @GET + @Path("{chain_id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getPortPain(@PathParam("chain_id") String id) { + + if (!service.exists(PortChainId.of(id))) { + return Response.status(NOT_FOUND).entity(PORT_CHAIN_NOT_FOUND).build(); + } + PortChain portChain = nullIsNotFound(service.getPortChain(PortChainId.of(id)), + PORT_CHAIN_NOT_FOUND); + ObjectNode result = new ObjectMapper().createObjectNode(); + result.set("port_chain", new PortChainCodec().encode(portChain, this)); + return ok(result).build(); + } + + /** + * Creates a new port chain. + * + * @param stream port chain from JSON + * @return status of the request - CREATED if the JSON is correct, + * BAD_REQUEST if the JSON is invalid + */ + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response createPortChain(InputStream stream) { + try { + ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); + PortChain portChain = codec(PortChain.class).decode(jsonTree, this); + Boolean issuccess = nullIsNotFound(service.createPortChain(portChain), PORT_CHAIN_NOT_FOUND); + return Response.status(OK).entity(issuccess.toString()).build(); + } catch (IOException e) { + log.error("Exception while creating port chain {}.", e.toString()); + throw new IllegalArgumentException(e); + } + } + + /** + * Update details of a specified port chain id. + * + * @param id port chain id + * @param stream port chain json + * @return 200 OK, 404 if given identifier does not exist + */ + @PUT + @Path("{chain_id}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public Response updatePortPain(@PathParam("chain_id") String id, + final InputStream stream) { + try { + ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); + PortChain portChain = codec(PortChain.class).decode(jsonTree, this); + Boolean result = nullIsNotFound(service.updatePortChain(portChain), PORT_CHAIN_NOT_FOUND); + return Response.status(OK).entity(result.toString()).build(); + } catch (IOException e) { + log.error("Update port chain failed because of exception {}.", e.toString()); + throw new IllegalArgumentException(e); + } + } + + /** + * Delete details of a specified port chain id. + * + * @param id port chain id + */ + @Path("{chain_id}") + @DELETE + public void deletePortPain(@PathParam("chain_id") String id) { + log.debug("Deletes port chain by identifier {}.", id); + PortChainId portChainId = PortChainId.of(id); + + Boolean issuccess = nullIsNotFound(service.removePortChain(portChainId), PORT_CHAIN_NOT_FOUND); + if (!issuccess) { + log.debug("Port Chain identifier {} does not exist", id); + } + } +} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairGroupWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairGroupWebResource.java new file mode 100644 index 00000000..69daad37 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairGroupWebResource.java @@ -0,0 +1,163 @@ +/* + * 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.vtnweb.resources; + +import static javax.ws.rs.core.Response.Status.NOT_FOUND; +import static javax.ws.rs.core.Response.Status.OK; +import static org.onlab.util.Tools.nullIsNotFound; + +import java.io.IOException; +import java.io.InputStream; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.onosproject.rest.AbstractWebResource; +import org.onosproject.vtnrsc.PortPairGroup; +import org.onosproject.vtnrsc.PortPairGroupId; +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; +import org.onosproject.vtnweb.web.PortPairGroupCodec; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * Query and program port pair group. + */ + +@Path("port_pair_groups") +public class PortPairGroupWebResource extends AbstractWebResource { + + private final Logger log = LoggerFactory.getLogger(PortPairGroupWebResource.class); + private final PortPairGroupService service = get(PortPairGroupService.class); + public static final String PORT_PAIR_GROUP_NOT_FOUND = "Port pair group not found"; + public static final String PORT_PAIR_GROUP_ID_EXIST = "Port pair group exists"; + public static final String PORT_PAIR_GROUP_ID_NOT_EXIST = "Port pair group does not exist with identifier"; + + /** + * Get details of all port pair groups created. + * + * @return 200 OK + */ + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getPortPairGroups() { + Iterable portPairGroups = service.getPortPairGroups(); + ObjectNode result = new ObjectMapper().createObjectNode(); + result.set("port_pair_groups", new PortPairGroupCodec().encode(portPairGroups, this)); + return ok(result).build(); + } + + /** + * Get details of a specified port pair group id. + * + * @param id port pair group id + * @return 200 OK, 404 if given identifier does not exist + */ + @GET + @Path("{group_id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getPortPairGroup(@PathParam("group_id") String id) { + + if (!service.exists(PortPairGroupId.of(id))) { + return Response.status(NOT_FOUND) + .entity(PORT_PAIR_GROUP_NOT_FOUND).build(); + } + PortPairGroup portPairGroup = nullIsNotFound(service.getPortPairGroup(PortPairGroupId.of(id)), + PORT_PAIR_GROUP_NOT_FOUND); + + ObjectNode result = new ObjectMapper().createObjectNode(); + result.set("port_pair_group", new PortPairGroupCodec().encode(portPairGroup, this)); + return ok(result).build(); + } + + /** + * Creates a new port pair group. + * + * @param stream port pair group from JSON + * @return status of the request - CREATED if the JSON is correct, + * BAD_REQUEST if the JSON is invalid + */ + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response createPortPairGroup(InputStream stream) { + + try { + ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); + + PortPairGroup portPairGroup = codec(PortPairGroup.class).decode(jsonTree, this); + Boolean issuccess = nullIsNotFound(service.createPortPairGroup(portPairGroup), + PORT_PAIR_GROUP_NOT_FOUND); + return Response.status(OK).entity(issuccess.toString()).build(); + } catch (IOException e) { + log.error("Exception while creating port pair group {}.", e.toString()); + throw new IllegalArgumentException(e); + } + } + + /** + * Update details of a specified port pair group id. + * + * @param id port pair group id + * @param stream port pair group from json + * @return 200 OK, 404 if given identifier does not exist + */ + @PUT + @Path("{group_id}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public Response updatePortPairGroup(@PathParam("group_id") String id, + final InputStream stream) { + try { + ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); + PortPairGroup portPairGroup = codec(PortPairGroup.class).decode(jsonTree, this); + Boolean isSuccess = nullIsNotFound(service.updatePortPairGroup(portPairGroup), PORT_PAIR_GROUP_NOT_FOUND); + return Response.status(OK).entity(isSuccess.toString()).build(); + } catch (IOException e) { + log.error("Update port pair group failed because of exception {}.", e.toString()); + throw new IllegalArgumentException(e); + } + } + + /** + * Delete details of a specified port pair group id. + * + * @param id port pair group id + */ + @Path("{group_id}") + @DELETE + public void deletePortPairGroup(@PathParam("group_id") String id) { + log.debug("Deletes port pair group by identifier {}.", id); + PortPairGroupId portPairGroupId = PortPairGroupId.of(id); + Boolean issuccess = nullIsNotFound(service.removePortPairGroup(portPairGroupId), + PORT_PAIR_GROUP_NOT_FOUND); + if (!issuccess) { + log.debug("Port pair group identifier {} does not exist", id); + } + } +} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java new file mode 100644 index 00000000..8bf459c2 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java @@ -0,0 +1,161 @@ +/* + * 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.vtnweb.resources; + +import static javax.ws.rs.core.Response.Status.NOT_FOUND; +import static javax.ws.rs.core.Response.Status.OK; +import static org.onlab.util.Tools.nullIsNotFound; + +import java.io.IOException; +import java.io.InputStream; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.onosproject.rest.AbstractWebResource; +import org.onosproject.vtnrsc.PortPair; +import org.onosproject.vtnrsc.PortPairId; +import org.onosproject.vtnrsc.portpair.PortPairService; +import org.onosproject.vtnweb.web.PortPairCodec; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * Query and program port pair. + */ +@Path("port_pairs") +public class PortPairWebResource extends AbstractWebResource { + + private final Logger log = LoggerFactory.getLogger(PortPairWebResource.class); + private final PortPairService service = get(PortPairService.class); + public static final String PORT_PAIR_NOT_FOUND = "Port pair not found"; + public static final String PORT_PAIR_ID_EXIST = "Port pair exists"; + public static final String PORT_PAIR_ID_NOT_EXIST = "Port pair does not exist with identifier"; + + /** + * Get details of all port pairs created. + * + * @return 200 OK + */ + @GET + @Produces(MediaType.APPLICATION_JSON) + public Response getPortPairs() { + Iterable portPairs = service.getPortPairs(); + ObjectNode result = new ObjectMapper().createObjectNode(); + result.set("port_pairs", new PortPairCodec().encode(portPairs, this)); + return ok(result).build(); + } + + /** + * Get details of a specified port pair id. + * + * @param id port pair id + * @return 200 OK, 404 if given identifier does not exist + */ + @GET + @Path("{pair_id}") + @Produces(MediaType.APPLICATION_JSON) + public Response getPortPair(@PathParam("portPairId") String id) { + + if (!service.exists(PortPairId.of(id))) { + return Response.status(NOT_FOUND) + .entity(PORT_PAIR_NOT_FOUND).build(); + } + PortPair portPair = nullIsNotFound(service.getPortPair(PortPairId.of(id)), + PORT_PAIR_NOT_FOUND); + + ObjectNode result = new ObjectMapper().createObjectNode(); + result.set("port_pair", new PortPairCodec().encode(portPair, this)); + return ok(result).build(); + } + + /** + * Creates a new port pair. + * + * @param stream port pair from JSON + * @return status of the request - CREATED if the JSON is correct, + * BAD_REQUEST if the JSON is invalid + */ + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public Response createPortPair(InputStream stream) { + try { + ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); + + PortPair portPair = codec(PortPair.class).decode(jsonTree, this); + Boolean isSuccess = nullIsNotFound(service.createPortPair(portPair), + PORT_PAIR_NOT_FOUND); + return Response.status(OK).entity(isSuccess.toString()).build(); + } catch (IOException e) { + log.error("Exception while creating port pair {}.", e.toString()); + throw new IllegalArgumentException(e); + } + } + + /** + * Update details of a specified port pair id. + * + * @param id port pair id + * @param stream port pair from json + * @return 200 OK, 404 if the given identifier does not exist + */ + @PUT + @Path("{pair_id}") + @Produces(MediaType.APPLICATION_JSON) + @Consumes(MediaType.APPLICATION_JSON) + public Response updatePortPair(@PathParam("pair_id") String id, + final InputStream stream) { + try { + ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); + PortPair portPair = codec(PortPair.class).decode(jsonTree, this); + Boolean isSuccess = nullIsNotFound(service.updatePortPair(portPair), PORT_PAIR_NOT_FOUND); + return Response.status(OK).entity(isSuccess.toString()).build(); + } catch (IOException e) { + log.error("Update port pair failed because of exception {}.", e.toString()); + throw new IllegalArgumentException(e); + } + } + + /** + * Delete details of a specified port pair id. + * + * @param id port pair id + */ + @Path("{pair_id}") + @DELETE + public void deletePortPair(@PathParam("pair_id") String id) { + + PortPairId portPairId = PortPairId.of(id); + Boolean isSuccess = nullIsNotFound(service.removePortPair(portPairId), + PORT_PAIR_NOT_FOUND); + if (!isSuccess) { + log.debug("Port pair identifier {} does not exist", id); + } + } +} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java new file mode 100644 index 00000000..4c17633c --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java @@ -0,0 +1,134 @@ +/* + * 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.vtnweb.web; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.onlab.util.Tools.nullIsIllegal; + +import java.util.UUID; + +import org.onlab.packet.IpPrefix; +import org.onosproject.codec.CodecContext; +import org.onosproject.codec.JsonCodec; +import org.onosproject.vtnrsc.DefaultFlowClassifier; +import org.onosproject.vtnrsc.FlowClassifier; +import org.onosproject.vtnrsc.FlowClassifierId; +import org.onosproject.vtnrsc.VirtualPortId; +import org.onosproject.vtnrsc.TenantId; + +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * Flow Classifier JSON codec. + */ +public final class FlowClassifierCodec extends JsonCodec { + + private static final String FLOW_CLASSIFIER_ID = "id"; + private static final String TENANT_ID = "tenant_id"; + private static final String NAME = "name"; + private static final String DESCRIPTION = "description"; + private static final String ETHER_TYPE = "etherType"; + private static final String PROTOCOL = "protocol"; + private static final String MIN_SRC_PORT_RANGE = "source_port_range_min"; + private static final String MAX_SRC_PORT_RANGE = "source_port_range_max"; + private static final String MIN_DST_PORT_RANGE = "destination_port_range_min"; + private static final String MAX_DST_PORT_RANGE = "destination_port_range_max"; + private static final String SRC_IP_PREFIX = "source_ip_prefix"; + private static final String DST_IP_PREFIX = "destination_ip_prefix"; + private static final String SRC_PORT = "logical_source_port"; + private static final String DST_PORT = "logical_destination_port"; + private static final String MISSING_MEMBER_MESSAGE = " member is required in Flow Classifier."; + + @Override + public FlowClassifier decode(ObjectNode json, CodecContext context) { + if (json == null || !json.isObject()) { + return null; + } + + FlowClassifier.Builder resultBuilder = new DefaultFlowClassifier.Builder(); + + String flowClassifierId = nullIsIllegal(json.get(FLOW_CLASSIFIER_ID), + FLOW_CLASSIFIER_ID + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setFlowClassifierId(FlowClassifierId.of(UUID.fromString(flowClassifierId))); + + String tenantId = nullIsIllegal(json.get(TENANT_ID), TENANT_ID + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setTenantId(TenantId.tenantId(tenantId)); + + String flowClassiferName = nullIsIllegal(json.get(NAME), NAME + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setName(flowClassiferName); + + String flowClassiferDescription = nullIsIllegal(json.get(DESCRIPTION), DESCRIPTION + MISSING_MEMBER_MESSAGE) + .asText(); + resultBuilder.setDescription(flowClassiferDescription); + + String etherType = nullIsIllegal(json.get(ETHER_TYPE), ETHER_TYPE + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setEtherType(etherType); + + String protocol = nullIsIllegal(json.get(PROTOCOL), PROTOCOL + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setProtocol(protocol); + + int minSrcPortRange = nullIsIllegal(json.get(MIN_SRC_PORT_RANGE), MIN_SRC_PORT_RANGE + MISSING_MEMBER_MESSAGE) + .asInt(); + resultBuilder.setMinSrcPortRange(minSrcPortRange); + + int maxSrcPortRange = nullIsIllegal(json.get(MAX_SRC_PORT_RANGE), MAX_SRC_PORT_RANGE + MISSING_MEMBER_MESSAGE) + .asInt(); + resultBuilder.setMaxSrcPortRange(maxSrcPortRange); + + int minDstPortRange = nullIsIllegal(json.get(MIN_DST_PORT_RANGE), MIN_DST_PORT_RANGE + MISSING_MEMBER_MESSAGE) + .asInt(); + resultBuilder.setMinDstPortRange(minDstPortRange); + + int maxDstPortRange = nullIsIllegal(json.get(MAX_DST_PORT_RANGE), MAX_DST_PORT_RANGE + MISSING_MEMBER_MESSAGE) + .asInt(); + resultBuilder.setMaxDstPortRange(maxDstPortRange); + + String srcIpPrefix = nullIsIllegal(json.get(SRC_IP_PREFIX), SRC_IP_PREFIX + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setSrcIpPrefix(IpPrefix.valueOf(srcIpPrefix)); + + String dstIpPrefix = nullIsIllegal(json.get(DST_IP_PREFIX), DST_IP_PREFIX + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setDstIpPrefix(IpPrefix.valueOf(dstIpPrefix)); + + String srcPort = nullIsIllegal(json.get(SRC_PORT), SRC_PORT + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setSrcPort(VirtualPortId.portId(srcPort)); + + String dstPort = nullIsIllegal(json.get(DST_PORT), DST_PORT + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setDstPort(VirtualPortId.portId(dstPort)); + + return resultBuilder.build(); + } + + @Override + public ObjectNode encode(FlowClassifier flowClassifier, CodecContext context) { + checkNotNull(flowClassifier, "flowClassifier cannot be null"); + ObjectNode result = context.mapper().createObjectNode() + .put("FLOW_CLASSIFIER_ID", flowClassifier.flowClassifierId().toString()) + .put("TENANT_ID", flowClassifier.tenantId().toString()) + .put("NAME", flowClassifier.name()) + .put("DESCRIPTION", flowClassifier.description()) + .put("ETHER_TYPE", flowClassifier.etherType()) + .put("PROTOCOL", flowClassifier.protocol()) + .put("MIN_SRC_PORT_RANGE", flowClassifier.minSrcPortRange()) + .put("MAX_SRC_PORT_RANGE", flowClassifier.maxSrcPortRange()) + .put("MIN_DST_PORT_RANGE", flowClassifier.minDstPortRange()) + .put("MAX_DST_PORT_RANGE", flowClassifier.maxDstPortRange()) + .put("SRC_IP_PREFIX", flowClassifier.srcIpPrefix().toString()) + .put("DST_IP_PREFIX", flowClassifier.dstIpPrefix().toString()) + .put("SRC_PORT", flowClassifier.srcPort().toString()) + .put("DST_PORT", flowClassifier.dstPort().toString()); + return result; + } +} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java index 28da5cd1..1e9cf009 100644 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortChainCodec.java @@ -59,7 +59,7 @@ public final class PortChainCodec extends JsonCodec { String id = nullIsIllegal(json.get(ID), ID + MISSING_MEMBER_MESSAGE).asText(); - resultBuilder.setId(PortChainId.portChainId(id)); + resultBuilder.setId(PortChainId.of(id)); String tenantId = nullIsIllegal(json.get(TENANT_ID), TENANT_ID + MISSING_MEMBER_MESSAGE).asText(); @@ -76,14 +76,14 @@ public final class PortChainCodec extends JsonCodec { ArrayNode arrayNode = (ArrayNode) json.path(PORT_PAIR_GROUPS); if (arrayNode != null) { List list = Lists.newArrayList(); - arrayNode.forEach(i -> list.add(PortPairGroupId.portPairGroupId(i.asText()))); + arrayNode.forEach(i -> list.add(PortPairGroupId.of(i.asText()))); resultBuilder.setPortPairGroups(list); } arrayNode = (ArrayNode) json.path(FLOW_CLASSIFIERS); if (arrayNode != null) { List list = Lists.newArrayList(); - arrayNode.forEach(i -> list.add(FlowClassifierId.flowClassifierId(UUID.fromString(i.asText())))); + arrayNode.forEach(i -> list.add(FlowClassifierId.of(UUID.fromString(i.asText())))); resultBuilder.setFlowClassifiers(list); } diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairCodec.java new file mode 100644 index 00000000..691536f4 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairCodec.java @@ -0,0 +1,94 @@ +/* + * 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.vtnweb.web; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.onlab.util.Tools.nullIsIllegal; + +import org.onosproject.codec.CodecContext; +import org.onosproject.codec.JsonCodec; +import org.onosproject.core.CoreService; +import org.onosproject.vtnrsc.DefaultPortPair; +import org.onosproject.vtnrsc.PortPair; +import org.onosproject.vtnrsc.PortPairId; +import org.onosproject.vtnrsc.TenantId; + +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * Port Pair JSON codec. + */ +public final class PortPairCodec extends JsonCodec { + + private static final String ID = "id"; + private static final String TENANT_ID = "tenant_id"; + private static final String NAME = "name"; + private static final String DESCRIPTION = "description"; + private static final String INGRESS = "ingress"; + private static final String EGRESS = "egress"; + private static final String MISSING_MEMBER_MESSAGE = + " member is required in PortPair"; + + @Override + public PortPair decode(ObjectNode json, CodecContext context) { + if (json == null || !json.isObject()) { + return null; + } + + PortPair.Builder resultBuilder = new DefaultPortPair.Builder(); + + CoreService coreService = context.getService(CoreService.class); + + String id = nullIsIllegal(json.get(ID), + ID + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setId(PortPairId.of(id)); + + String tenantId = nullIsIllegal(json.get(TENANT_ID), + TENANT_ID + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setTenantId(TenantId.tenantId(tenantId)); + + String name = nullIsIllegal(json.get(NAME), + NAME + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setName(name); + + String description = nullIsIllegal(json.get(DESCRIPTION), + DESCRIPTION + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setDescription(description); + + String ingressPort = nullIsIllegal(json.get(INGRESS), + INGRESS + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setIngress(ingressPort); + + String egressPort = nullIsIllegal(json.get(EGRESS), + EGRESS + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setEgress(egressPort); + + return resultBuilder.build(); + } + + @Override + public ObjectNode encode(PortPair portPair, CodecContext context) { + checkNotNull(portPair, "port pair cannot be null"); + ObjectNode result = context.mapper().createObjectNode() + .put(ID, portPair.portPairId().toString()) + .put(TENANT_ID, portPair.tenantId().toString()) + .put(NAME, portPair.name()) + .put(DESCRIPTION, portPair.description()) + .put(INGRESS, portPair.ingress()) + .put(EGRESS, portPair.egress()); + return result; + } +} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairGroupCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairGroupCodec.java new file mode 100644 index 00000000..b5ae266b --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/PortPairGroupCodec.java @@ -0,0 +1,95 @@ +/* + * 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.vtnweb.web; + +import static com.google.common.base.Preconditions.checkNotNull; +import static org.onlab.util.Tools.nullIsIllegal; + +import java.util.List; + +import org.onosproject.codec.CodecContext; +import org.onosproject.codec.JsonCodec; +import org.onosproject.core.CoreService; +import org.onosproject.vtnrsc.DefaultPortPairGroup; +import org.onosproject.vtnrsc.PortPairGroup; +import org.onosproject.vtnrsc.PortPairGroupId; +import org.onosproject.vtnrsc.PortPairId; +import org.onosproject.vtnrsc.TenantId; + +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.collect.Lists; + +/** + * Port Pair Group JSON codec. + */ +public final class PortPairGroupCodec extends JsonCodec { + + private static final String ID = "id"; + private static final String TENANT_ID = "tenant_id"; + private static final String NAME = "name"; + private static final String DESCRIPTION = "description"; + private static final String PORT_PAIRS = "port_pairs"; + private static final String MISSING_MEMBER_MESSAGE = + " member is required in PortPairGroup"; + + @Override + public PortPairGroup decode(ObjectNode json, CodecContext context) { + if (json == null || !json.isObject()) { + return null; + } + + PortPairGroup.Builder resultBuilder = new DefaultPortPairGroup.Builder(); + + CoreService coreService = context.getService(CoreService.class); + + String id = nullIsIllegal(json.get(ID), + ID + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setId(PortPairGroupId.of(id)); + + String tenantId = nullIsIllegal(json.get(TENANT_ID), + TENANT_ID + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setTenantId(TenantId.tenantId(tenantId)); + + String name = nullIsIllegal(json.get(NAME), + NAME + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setName(name); + + String description = nullIsIllegal(json.get(DESCRIPTION), + DESCRIPTION + MISSING_MEMBER_MESSAGE).asText(); + resultBuilder.setDescription(description); + + List list = Lists.newArrayList(); + ArrayNode arrayNode = (ArrayNode) json.path(PORT_PAIRS); + arrayNode.forEach(i -> list.add(PortPairId.of(i.asText()))); + resultBuilder.setPortPairs(list); + + return resultBuilder.build(); + } + + @Override + public ObjectNode encode(PortPairGroup portPairGroup, CodecContext context) { + checkNotNull(portPairGroup, "port pair group cannot be null"); + ObjectNode result = context.mapper().createObjectNode() + .put(ID, portPairGroup.portPairGroupId().toString()) + .put(TENANT_ID, portPairGroup.tenantId().toString()) + .put(NAME, portPairGroup.name()) + .put(DESCRIPTION, portPairGroup.description()) + .put(PORT_PAIRS, portPairGroup.portPairs().toString()); + return result; + } +} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/webapp/WEB-INF/web.xml b/framework/src/onos/apps/vtn/vtnweb/src/main/webapp/WEB-INF/web.xml index 4cc12455..97337960 100644 --- a/framework/src/onos/apps/vtn/vtnweb/src/main/webapp/WEB-INF/web.xml +++ b/framework/src/onos/apps/vtn/vtnweb/src/main/webapp/WEB-INF/web.xml @@ -33,6 +33,10 @@ org.onosproject.vtnweb.resources.TenantNetworkWebResource, org.onosproject.vtnweb.resources.SubnetWebResource, org.onosproject.vtnweb.resources.VirtualPortWebResource + org.onosproject.vtnweb.resources.FlowClassifierWebResource + org.onosproject.vtnweb.resources.PortChainWebResource + org.onosproject.vtnweb.resources.PortPairGroupWebResource + org.onosproject.vtnweb.resources.PortPairWebResource 1 diff --git a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairCodecTest.java b/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairCodecTest.java new file mode 100644 index 00000000..7651e098 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/PortPairCodecTest.java @@ -0,0 +1,94 @@ +/* + * 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.vtnweb.web; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; + +import java.io.IOException; +import java.io.InputStream; + +import org.junit.Before; +import org.junit.Test; +import org.onosproject.codec.JsonCodec; +import org.onosproject.vtnrsc.PortPair; +import org.onosproject.vtnrsc.PortPairId; +import org.onosproject.vtnrsc.TenantId; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * Port pair codec unit tests. + */ +public class PortPairCodecTest { + + SfcCodecContext context; + JsonCodec portPairCodec; + /** + * Sets up for each test. Creates a context and fetches the port pair + * codec. + */ + @Before + public void setUp() { + context = new SfcCodecContext(); + portPairCodec = context.codec(PortPair.class); + assertThat(portPairCodec, notNullValue()); + } + + /** + * Reads in a port pair from the given resource and decodes it. + * + * @param resourceName resource to use to read the JSON for the port pair + * @return decoded port pair + * @throws IOException if processing the resource fails + */ + private PortPair getPortPair(String resourceName) throws IOException { + InputStream jsonStream = PortPairCodecTest.class + .getResourceAsStream(resourceName); + ObjectMapper mapper = new ObjectMapper(); + JsonNode json = mapper.readTree(jsonStream); + assertThat(json, notNullValue()); + PortPair portPair = portPairCodec.decode((ObjectNode) json, context); + assertThat(portPair, notNullValue()); + return portPair; + } + + /** + * Checks that a simple port pair decodes properly. + * + * @throws IOException if the resource cannot be processed + */ + @Test + public void codecPortPairTest() throws IOException { + + PortPair portPair = getPortPair("portPair.json"); + + assertThat(portPair, notNullValue()); + + PortPairId portPairId = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae"); + TenantId tenantId = TenantId.tenantId("d382007aa9904763a801f68ecf065cf5"); + + assertThat(portPair.portPairId().toString(), is(portPairId.toString())); + assertThat(portPair.name(), is("PP1")); + assertThat(portPair.tenantId().toString(), is(tenantId.toString())); + assertThat(portPair.description(), is("SF-A")); + assertThat(portPair.ingress().toString(), is("dace4513-24fc-4fae-af4b-321c5e2eb3d1")); + assertThat(portPair.egress().toString(), is("aef3478a-4a56-2a6e-cd3a-9dee4e2ec345")); + } +} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/SfcCodecContext.java b/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/SfcCodecContext.java new file mode 100644 index 00000000..fe9d7995 --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnweb/src/test/java/org/onosproject/vtnweb/web/SfcCodecContext.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.vtnweb.web; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.onosproject.codec.CodecContext; +import org.onosproject.codec.JsonCodec; +import org.onosproject.vtnrsc.FlowClassifier; +import org.onosproject.vtnrsc.PortChain; +import org.onosproject.vtnrsc.PortPair; +import org.onosproject.vtnrsc.PortPairGroup; + +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Mock codec context for use in codec unit tests. + */ +public class SfcCodecContext implements CodecContext { + + private final ObjectMapper mapper = new ObjectMapper(); + private final Map, JsonCodec> codecs = new ConcurrentHashMap<>(); + + /** + * Constructs a new mock codec context. + */ + public SfcCodecContext() { + codecs.clear(); + registerCodec(PortPair.class, new PortPairCodec()); + registerCodec(PortChain.class, new PortChainCodec()); + registerCodec(PortPairGroup.class, new PortPairGroupCodec()); + registerCodec(FlowClassifier.class, new FlowClassifierCodec()); + } + + @Override + public ObjectMapper mapper() { + return mapper; + } + + @SuppressWarnings("unchecked") + @Override + public T getService(Class serviceClass) { + // TODO + return null; + } + + /** + * Registers the specified JSON codec for the given entity class. + * + * @param entityClass entity class + * @param codec JSON codec + * @param entity type + */ + public void registerCodec(Class entityClass, JsonCodec codec) { + codecs.putIfAbsent(entityClass, codec); + } + + @SuppressWarnings("unchecked") + @Override + public JsonCodec codec(Class entityClass) { + return codecs.get(entityClass); + } +} diff --git a/framework/src/onos/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portPair.json b/framework/src/onos/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portPair.json new file mode 100644 index 00000000..f858c88c --- /dev/null +++ b/framework/src/onos/apps/vtn/vtnweb/src/test/resources/org/onosproject/vtnweb/web/portPair.json @@ -0,0 +1,9 @@ +{ + "id": "78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae", + "name": "PP1", + "tenant_id": "d382007aa9904763a801f68ecf065cf5", + "description": "SF-A", + "ingress": "dace4513-24fc-4fae-af4b-321c5e2eb3d1", + "egress": "aef3478a-4a56-2a6e-cd3a-9dee4e2ec345" +} + diff --git a/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPConnectPeer.java b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPConnectPeer.java new file mode 100755 index 00000000..a2a66438 --- /dev/null +++ b/framework/src/onos/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPConnectPeer.java @@ -0,0 +1,28 @@ +/* + * 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.controller; + +import java.util.concurrent.ExecutorService; + +/** + * Abstraction of an BGP connect peer, initiate remote connection to BGP peer on configuration. + */ +public interface BGPConnectPeer { + + /** + * Returns the executor initialized to connect peer. + * + * @return connectExecutor the connection executor + */ + ExecutorService connectExecutor(); +} diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPOpenMsg.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPOpenMsg.java index a8c242b4..bf5d05f4 100644 --- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPOpenMsg.java +++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPOpenMsg.java @@ -71,13 +71,6 @@ public interface BGPOpenMsg extends BGPMessage { @Override BGPOpenMsg build() throws BGPParseException; - /** - * Returns hold time of Open Message. - * - * @return hold time of Open Message - */ - short getHoldTime(); - /** * Sets hold time in Open Message and return its builder. * @@ -86,13 +79,6 @@ public interface BGPOpenMsg extends BGPMessage { */ Builder setHoldTime(short holdtime); - /** - * Returns as number of Open Message. - * - * @return as number of Open Message - */ - short getAsNumber(); - /** * Sets AS number in Open Message and return its builder. * @@ -101,13 +87,6 @@ public interface BGPOpenMsg extends BGPMessage { */ Builder setAsNumber(short asNumber); - /** - * Returns BGP Identifier of Open Message. - * - * @return BGP Identifier of Open Message - */ - int getBgpId(); - /** * Sets BGP Identifier in Open Message and return its builder. * @@ -116,13 +95,6 @@ public interface BGPOpenMsg extends BGPMessage { */ Builder setBgpId(int bgpId); - /** - * Returns capabilities of Open Message. - * - * @return capabilities of Open Message - */ - LinkedList getCapabilityTlv(); - /** * Sets capabilities in Open Message and return its builder. * diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPLinkLSIdentifier.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPLinkLSIdentifier.java new file mode 100755 index 00000000..3229cc11 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPLinkLSIdentifier.java @@ -0,0 +1,252 @@ +/* + * 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.link_state; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +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.types.IPv4AddressTlv; +import org.onosproject.bgpio.types.IPv6AddressTlv; +import org.onosproject.bgpio.types.LinkLocalRemoteIdentifiersTlv; +import org.onosproject.bgpio.types.attr.BgpAttrNodeMultiTopologyId; +import org.onosproject.bgpio.util.UnSupportedAttribute; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; + +/** + * Implementation of local node descriptors, remote node descriptors and link descriptors. + */ +public class BGPLinkLSIdentifier { + private static final Logger log = LoggerFactory.getLogger(BGPLinkLSIdentifier.class); + public static final short IPV4_INTERFACE_ADDRESS_TYPE = 259; + public static final short IPV4_NEIGHBOR_ADDRESS_TYPE = 260; + public static final short IPV6_INTERFACE_ADDRESS_TYPE = 261; + public static final short IPV6_NEIGHBOR_ADDRESS_TYPE = 262; + public static final int TYPE_AND_LEN = 4; + + private NodeDescriptors localNodeDescriptors; + private NodeDescriptors remoteNodeDescriptors; + private List linkDescriptor; + + /** + * Initialize fields. + */ + public BGPLinkLSIdentifier() { + this.localNodeDescriptors = null; + this.remoteNodeDescriptors = null; + this.linkDescriptor = null; + } + + /** + * Constructors to initialize parameters. + * + * @param localNodeDescriptors local node descriptors + * @param remoteNodeDescriptors remote node descriptors + * @param linkDescriptor link descriptors + */ + public BGPLinkLSIdentifier(NodeDescriptors localNodeDescriptors, NodeDescriptors remoteNodeDescriptors, + LinkedList linkDescriptor) { + this.localNodeDescriptors = Preconditions.checkNotNull(localNodeDescriptors); + this.remoteNodeDescriptors = Preconditions.checkNotNull(remoteNodeDescriptors); + this.linkDescriptor = Preconditions.checkNotNull(linkDescriptor); + } + + /** + * Reads channel buffer and parses link identifier. + * + * @param cb ChannelBuffer + * @param protocolId in linkstate nlri + * @return object of BGPLinkLSIdentifier + * @throws BGPParseException while parsing link identifier + */ + public static BGPLinkLSIdentifier parseLinkIdendifier(ChannelBuffer cb, byte protocolId) throws BGPParseException { + //Parse local node descriptor + NodeDescriptors localNodeDescriptors = new NodeDescriptors(); + localNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.LOCAL_NODE_DES_TYPE, protocolId); + + //Parse remote node descriptor + NodeDescriptors remoteNodeDescriptors = new NodeDescriptors(); + remoteNodeDescriptors = parseNodeDescriptors(cb, NodeDescriptors.REMOTE_NODE_DES_TYPE, protocolId); + + //Parse link descriptor + LinkedList linkDescriptor = new LinkedList<>(); + linkDescriptor = parseLinkDescriptors(cb); + return new BGPLinkLSIdentifier(localNodeDescriptors, remoteNodeDescriptors, linkDescriptor); + } + + /** + * Parses Local/Remote node descriptors. + * + * @param cb ChannelBuffer + * @param desType descriptor type + * @param protocolId protocol identifier + * @return object of NodeDescriptors + * @throws BGPParseException while parsing Local/Remote node descriptors + */ + public static NodeDescriptors parseNodeDescriptors(ChannelBuffer cb, short desType, byte protocolId) + throws BGPParseException { + ChannelBuffer tempBuf = cb; + short type = cb.readShort(); + short length = cb.readShort(); + if (cb.readableBytes() < length) { + throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR, + tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN)); + } + NodeDescriptors nodeIdentifier = new NodeDescriptors(); + ChannelBuffer tempCb = cb.readBytes(length); + + if (type == desType) { + nodeIdentifier = NodeDescriptors.read(tempCb, length, desType, protocolId); + } else { + throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.MALFORMED_ATTRIBUTE_LIST, null); + } + return nodeIdentifier; + } + + /** + * Parses link descriptors. + * + * @param cb ChannelBuffer + * @return list of link descriptors + * @throws BGPParseException while parsing link descriptors + */ + public static LinkedList parseLinkDescriptors(ChannelBuffer cb) throws BGPParseException { + LinkedList linkDescriptor = new LinkedList<>(); + BGPValueType tlv = null; + int count = 0; + + while (cb.readableBytes() > 0) { + ChannelBuffer tempBuf = cb; + short type = cb.readShort(); + short length = cb.readShort(); + if (cb.readableBytes() < length) { + throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR, + tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN)); + } + ChannelBuffer tempCb = cb.readBytes(length); + switch (type) { + case LinkLocalRemoteIdentifiersTlv.TYPE: + tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb); + break; + case IPV4_INTERFACE_ADDRESS_TYPE: + tlv = IPv4AddressTlv.read(tempCb, IPV4_INTERFACE_ADDRESS_TYPE); + break; + case IPV4_NEIGHBOR_ADDRESS_TYPE: + tlv = IPv4AddressTlv.read(tempCb, IPV4_NEIGHBOR_ADDRESS_TYPE); + break; + case IPV6_INTERFACE_ADDRESS_TYPE: + tlv = IPv6AddressTlv.read(tempCb, IPV6_INTERFACE_ADDRESS_TYPE); + break; + case IPV6_NEIGHBOR_ADDRESS_TYPE: + tlv = IPv6AddressTlv.read(tempCb, IPV6_NEIGHBOR_ADDRESS_TYPE); + break; + case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY: + tlv = BgpAttrNodeMultiTopologyId.read(tempCb); + count = count++; + //MultiTopologyId TLV cannot repeat more than once + if (count > 1) { + //length + 4 implies data contains type, length and value + throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, + BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length + + TYPE_AND_LEN)); + } + break; + default: + UnSupportedAttribute.skipBytes(tempCb, length); + } + linkDescriptor.add(tlv); + } + return linkDescriptor; + } + + /** + * Returns local node descriptors. + * + * @return local node descriptors + */ + public NodeDescriptors localNodeDescriptors() { + return this.localNodeDescriptors; + } + + /** + * Returns remote node descriptors. + * + * @return remote node descriptors + */ + public NodeDescriptors remoteNodeDescriptors() { + return this.remoteNodeDescriptors; + } + + /** + * Returns link descriptors. + * + * @return link descriptors + */ + public List linkDescriptors() { + return this.linkDescriptor; + } + + @Override + public int hashCode() { + return Objects.hash(linkDescriptor, localNodeDescriptors, remoteNodeDescriptors); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof BGPLinkLSIdentifier) { + int countObjSubTlv = 0; + int countOtherSubTlv = 0; + boolean isCommonSubTlv = true; + BGPLinkLSIdentifier other = (BGPLinkLSIdentifier) obj; + Iterator objListIterator = other.linkDescriptor.iterator(); + countOtherSubTlv = other.linkDescriptor.size(); + countObjSubTlv = linkDescriptor.size(); + if (countObjSubTlv != countOtherSubTlv) { + return false; + } else { + while (objListIterator.hasNext() && isCommonSubTlv) { + BGPValueType subTlv = objListIterator.next(); + isCommonSubTlv = Objects.equals(linkDescriptor.contains(subTlv), + other.linkDescriptor.contains(subTlv)); + } + return isCommonSubTlv && Objects.equals(this.localNodeDescriptors, other.localNodeDescriptors) + && Objects.equals(this.remoteNodeDescriptors, other.remoteNodeDescriptors); + } + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("localNodeDescriptors", localNodeDescriptors) + .add("remoteNodeDescriptors", remoteNodeDescriptors) + .add("linkDescriptor", linkDescriptor) + .toString(); + } +} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java index b50342d6..fccbf5f7 100644 --- a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java +++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/BGPOpenMsgVer4.java @@ -311,8 +311,8 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg { if (this.isLargeAsCapabilityTlvSet) { BGPValueType tlv; - int iValue = this.getAsNumber(); - tlv = new FourOctetAsNumCapabilityTlv(iValue); + int value = this.asNumber; + tlv = new FourOctetAsNumCapabilityTlv(value); this.capabilityTlv.add(tlv); } @@ -332,26 +332,6 @@ public class BGPOpenMsgVer4 implements BGPOpenMsg { return this; } - @Override - public short getHoldTime() { - return this.holdTime; - } - - @Override - public short getAsNumber() { - return this.asNumber; - } - - @Override - public int getBgpId() { - return this.bgpId; - } - - @Override - public LinkedList getCapabilityTlv() { - return this.capabilityTlv; - } - @Override public Builder setHoldTime(short holdTime) { this.holdTime = holdTime; diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java new file mode 100644 index 00000000..d5f03268 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv4AddressTlv.java @@ -0,0 +1,128 @@ +/* + * 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.net.InetAddress; +import java.util.Objects; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onlab.packet.Ip4Address; +import org.onosproject.bgpio.exceptions.BGPParseException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; + +/** + * Provides Implementation of IPv4AddressTlv. + */ +public class IPv4AddressTlv implements BGPValueType { + private static final Logger log = LoggerFactory.getLogger(IPv4AddressTlv.class); + private static final int LENGTH = 4; + + private Ip4Address address; + private short type; + + /** + * Constructor to initialize parameters. + * + * @param address Ipv4 address of interface/neighbor + * @param type address type + */ + public IPv4AddressTlv(Ip4Address address, short type) { + this.address = Preconditions.checkNotNull(address); + this.type = type; + } + + /** + * Returns Ipv4 address of interface/neighbor. + * + * @return Ipv4 address of interface/neighbor + */ + public Ip4Address getValue() { + return address; + } + + @Override + public short getType() { + return this.type; + } + + @Override + public int hashCode() { + return Objects.hash(address); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof IPv4AddressTlv) { + IPv4AddressTlv other = (IPv4AddressTlv) obj; + return Objects.equals(this.address, other.address) && Objects.equals(this.type, other.type); + } + return false; + } + + @Override + public int write(ChannelBuffer cb) { + int iLenStartIndex = cb.writerIndex(); + cb.writeShort(type); + cb.writeShort(LENGTH); + cb.writeInt(address.toInt()); + return cb.writerIndex() - iLenStartIndex; + } + + /** + * Reads the channel buffer and returns object of IPv4AddressTlv. + * + * @param cb channelBuffer + * @param type address type + * @return object of IPv4AddressTlv + * @throws BGPParseException while parsing IPv4AddressTlv + */ + public static IPv4AddressTlv read(ChannelBuffer cb, short type) throws BGPParseException { + //TODO: use Validation.toInetAddress once Validation is merged + InetAddress ipAddress = (InetAddress) cb.readBytes(LENGTH); + if (ipAddress.isMulticastAddress()) { + throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null); + } + Ip4Address address = Ip4Address.valueOf(ipAddress); + return IPv4AddressTlv.of(address, type); + } + + /** + * Returns object of this class with specified values. + * + * @param address Ipv4 interface/neighbor Address + * @param type says Ipv4 address of interface/neighbor tlv type + * @return object of this class + */ + public static IPv4AddressTlv of(final Ip4Address address , final short type) { + return new IPv4AddressTlv(address, type); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("type", type) + .add("LENGTH", LENGTH) + .add("address", address) + .toString(); + } +} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java new file mode 100644 index 00000000..65b7c16d --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPv6AddressTlv.java @@ -0,0 +1,128 @@ +/* + * 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.net.InetAddress; +import java.util.Objects; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.onlab.packet.Ip6Address; +import org.onosproject.bgpio.exceptions.BGPParseException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; + +/** + * Provides Implementation of IPv6AddressTlv. + */ +public class IPv6AddressTlv implements BGPValueType { + private static final Logger log = LoggerFactory.getLogger(IPv6AddressTlv.class); + private static final int LENGTH = 16; + + private final Ip6Address address; + private short type; + + /** + * Constructor to initialize parameters. + * + * @param address Ipv6 address of interface/neighbor + * @param type address type + */ + public IPv6AddressTlv(Ip6Address address, short type) { + this.address = Preconditions.checkNotNull(address); + this.type = type; + } + + /** + * Returns Ipv6 address of interface/neighbor. + * + * @return Ipv6 address of interface/neighbor + */ + public Ip6Address getValue() { + return address; + } + + @Override + public short getType() { + return type; + } + + @Override + public int hashCode() { + return Objects.hash(address); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof IPv6AddressTlv) { + IPv6AddressTlv other = (IPv6AddressTlv) obj; + return Objects.equals(this.address, other.address) && Objects.equals(this.type, other.type); + } + return false; + } + + @Override + public int write(ChannelBuffer cb) { + int iLenStartIndex = cb.writerIndex(); + cb.writeShort(type); + cb.writeShort(LENGTH); + cb.writeBytes(address.toOctets()); + return cb.writerIndex() - iLenStartIndex; + } + + /** + * Reads the channel buffer and returns object of IPv6AddressTlv. + * + * @param cb channelBuffer + * @param type address type + * @return object of IPv6AddressTlv + * @throws BGPParseException while parsing IPv6AddressTlv + */ + public static IPv6AddressTlv read(ChannelBuffer cb, short type) throws BGPParseException { + //TODO: use Validation.toInetAddress once Validation is merged + InetAddress ipAddress = (InetAddress) cb.readBytes(LENGTH); + if (ipAddress.isMulticastAddress()) { + throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null); + } + Ip6Address address = Ip6Address.valueOf(ipAddress); + return IPv6AddressTlv.of(address, type); + } + + /** + * Returns object of this class with specified values. + * + * @param address Ipv6 interface/neighbor address + * @param type says Ipv6 address of interface/neighbor tlv type + * @return object of this class + */ + public static IPv6AddressTlv of(final Ip6Address address , final short type) { + return new IPv6AddressTlv(address, type); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("type", type) + .add("LENGTH", LENGTH) + .add("address", address) + .toString(); + } +} \ No newline at end of file diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java new file mode 100644 index 00000000..988925f5 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/LinkLocalRemoteIdentifiersTlv.java @@ -0,0 +1,131 @@ +/* + * 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.Objects; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.base.MoreObjects; + +/** + * Provides Implementation of Link Local/Remote IdentifiersTlv. + */ +public class LinkLocalRemoteIdentifiersTlv implements BGPValueType { + private static final Logger log = LoggerFactory.getLogger(LinkLocalRemoteIdentifiersTlv.class); + public static final short TYPE = 258; + private static final int LENGTH = 8; + + private final int linkLocalIdentifer; + private final int linkRemoteIdentifer; + + /** + * Constructor to initialize parameters. + * + * @param linkLocalIdentifer link local Identifer + * @param linkRemoteIdentifer link remote Identifer + */ + public LinkLocalRemoteIdentifiersTlv(int linkLocalIdentifer, int linkRemoteIdentifer) { + this.linkLocalIdentifer = linkLocalIdentifer; + this.linkRemoteIdentifer = linkRemoteIdentifer; + } + + /** + * Returns link remote Identifer. + * + * @return link remote Identifer + */ + public int getLinkRemoteIdentifier() { + return linkRemoteIdentifer; + } + + /** + * Returns link local Identifer. + * + * @return link local Identifer + */ + public int getLinkLocalIdentifier() { + return linkLocalIdentifer; + } + + @Override + public short getType() { + return TYPE; + } + + @Override + public int hashCode() { + return Objects.hash(linkLocalIdentifer, linkRemoteIdentifer); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof LinkLocalRemoteIdentifiersTlv) { + LinkLocalRemoteIdentifiersTlv other = (LinkLocalRemoteIdentifiersTlv) obj; + return Objects.equals(this.linkLocalIdentifer, other.linkLocalIdentifer) + && Objects.equals(this.linkRemoteIdentifer, other.linkRemoteIdentifer); + } + return false; + } + + @Override + public int write(ChannelBuffer cb) { + int iLenStartIndex = cb.writerIndex(); + cb.writeShort(TYPE); + cb.writeShort(LENGTH); + cb.writeInt(linkLocalIdentifer); + cb.writeInt(linkRemoteIdentifer); + return cb.writerIndex() - iLenStartIndex; + } + + /** + * Reads the channel buffer and returns object of LinkLocalRemoteIdentifiersTlv. + * + * @param cb channelBuffer + * @return object of LinkLocalRemoteIdentifiersTlv + */ + public static LinkLocalRemoteIdentifiersTlv read(ChannelBuffer cb) { + int linkLocalIdentifer = cb.readInt(); + int linkRemoteIdentifer = cb.readInt(); + return LinkLocalRemoteIdentifiersTlv.of(linkLocalIdentifer, linkRemoteIdentifer); + } + + /** + * Returns object of this class with specified link local identifer and link remote identifer. + * + * @param linkLocalIdentifer link local identifier + * @param linkRemoteIdentifer link remote identifier + * @return object of LinkLocalRemoteIdentifiersTlv + */ + public static LinkLocalRemoteIdentifiersTlv of(final int linkLocalIdentifer, final int linkRemoteIdentifer) { + return new LinkLocalRemoteIdentifiersTlv(linkLocalIdentifer, linkRemoteIdentifer); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("TYPE", TYPE) + .add("LENGTH", LENGTH) + .add("linkLocalIdentifer", linkLocalIdentifer) + .add("linkRemoteIdentifer", linkRemoteIdentifer) + .toString(); + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..3e7c654e --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AreaIdTest.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.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 new file mode 100755 index 00000000..96d05bf3 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/As4PathTest.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.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 new file mode 100644 index 00000000..792164ea --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AsPathTest.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.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 new file mode 100644 index 00000000..c41408de --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/AutonomousSystemTest.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.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 new file mode 100755 index 00000000..57ab9d90 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPKeepaliveMsgTest.java @@ -0,0 +1,70 @@ +/* + * 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 new file mode 100644 index 00000000..5f357815 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPLSIdentifierTest.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.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 new file mode 100755 index 00000000..d010857e --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BGPOpenMsgTest.java @@ -0,0 +1,318 @@ +/* + * 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/BgpLinkAttrMplsProtocolMaskTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrMplsProtocolMaskTest.java new file mode 100644 index 00000000..d218334b --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpLinkAttrMplsProtocolMaskTest.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.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/BgpNotificationMsgTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpNotificationMsgTest.java new file mode 100644 index 00000000..d3e6e49c --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpNotificationMsgTest.java @@ -0,0 +1,228 @@ +/* + * 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 new file mode 100644 index 00000000..5a3662be --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/BgpPrefixAttrMetricTest.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.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/IPReachabilityInformationTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPReachabilityInformationTest.java new file mode 100644 index 00000000..81f4b725 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPReachabilityInformationTest.java @@ -0,0 +1,41 @@ +/* + * 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 new file mode 100755 index 00000000..f3a0469c --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv4AddressTest.java @@ -0,0 +1,41 @@ +/* + * 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 new file mode 100644 index 00000000..2023093f --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IPv6AddressTest.java @@ -0,0 +1,41 @@ +/* + * 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 new file mode 100644 index 00000000..8112b51c --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsNonPseudonodeTest.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.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 new file mode 100644 index 00000000..bbc9e6a2 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/IsIsPseudonodeTest.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.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 new file mode 100644 index 00000000..22b9aba3 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/LinkLocalRemoteIdentifiersTest.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.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/OriginTest.java b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OriginTest.java new file mode 100644 index 00000000..88261ad5 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OriginTest.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.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 new file mode 100644 index 00000000..19002913 --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfNonPseudonodeTest.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.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 new file mode 100644 index 00000000..55b1190b --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfPseudonodeTest.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.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 new file mode 100644 index 00000000..e2fd1eaf --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/test/java/org/onosproject/bgp/OspfRouteTypeTest.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.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/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPMessageDecoder.java b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPMessageDecoder.java index 39f2862d..636b78cc 100755 --- a/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPMessageDecoder.java +++ b/framework/src/onos/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPMessageDecoder.java @@ -24,6 +24,9 @@ import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.handler.codec.frame.FrameDecoder; import org.onosproject.bgpio.protocol.BGPMessage; import org.onlab.util.HexDump; +import org.onosproject.bgpio.protocol.BGPFactories; +import org.onosproject.bgpio.protocol.BGPMessageReader; +import org.onosproject.bgpio.types.BGPHeader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,9 +39,6 @@ public class BGPMessageDecoder extends FrameDecoder { @Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer) throws Exception { - - List msgList = new LinkedList(); - log.debug("MESSAGE IS RECEIVED."); if (!channel.isConnected()) { log.info("Channel is not connected."); @@ -47,7 +47,14 @@ public class BGPMessageDecoder extends FrameDecoder { HexDump.dump(buffer); - // TODO: decode bgp messages + BGPMessageReader reader = BGPFactories.getGenericReader(); + List msgList = new LinkedList(); + + while (buffer.readableBytes() > 0) { + BGPHeader bgpHeader = new BGPHeader(); + BGPMessage message = reader.readFrom(buffer, bgpHeader); + msgList.add(message); + } return msgList; } } \ No newline at end of file diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java index 62cf042a..a33af769 100644 --- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java +++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java @@ -33,6 +33,7 @@ import org.onosproject.cli.AbstractShellCommand; import org.onosproject.core.ApplicationId; import org.onosproject.core.CoreService; import org.onosproject.net.Link; +import org.onosproject.net.PortNumber; import org.onosproject.net.flow.DefaultTrafficSelector; import org.onosproject.net.flow.DefaultTrafficTreatment; import org.onosproject.net.flow.TrafficSelector; @@ -166,7 +167,8 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { required = false, multiValued = false) private String pushVlan = null; - @Option(name = "--setQueue", description = "Set Queue ID", + @Option(name = "--setQueue", description = "Set Queue ID (for OpenFlow 1.0, " + + "also the port has to be specified, i.e., /", required = false, multiValued = false) private String setQueue = null; @@ -332,7 +334,15 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { emptyTreatment = false; } if (!isNullOrEmpty(setQueue)) { - treatmentBuilder.setQueue(Long.parseLong(setQueue)); + // OpenFlow 1.0 notation (for ENQUEUE): / + if (setQueue.contains("/")) { + String[] queueConfig = setQueue.split("/"); + PortNumber port = PortNumber.portNumber(Long.parseLong(queueConfig[0])); + long queueId = Long.parseLong(queueConfig[1]); + treatmentBuilder.setQueue(queueId, port); + } else { + treatmentBuilder.setQueue(Long.parseLong(setQueue)); + } emptyTreatment = false; } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/app/ApplicationService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/app/ApplicationService.java index 73dcc86c..1e543b85 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/app/ApplicationService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/app/ApplicationService.java @@ -67,4 +67,11 @@ public interface ApplicationService */ Set getPermissions(ApplicationId appId); + /** + * Registers application pre-deactivation processing hook. + * + * @param appId application identifier + * @param hook pre-deactivation hook + */ + void registerDeactivateHook(ApplicationId appId, Runnable hook); } diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cfg/ConfigProperty.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cfg/ConfigProperty.java index 36cd22b5..f1b602e8 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cfg/ConfigProperty.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/cfg/ConfigProperty.java @@ -245,7 +245,7 @@ public final class ConfigProperty { @Override public int hashCode() { - return Objects.hash(name); + return name.hashCode(); } /** diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java index 5f3e0e19..3787daa5 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/DefaultControllerNode.java @@ -20,6 +20,7 @@ import org.onlab.packet.IpAddress; import java.util.Objects; import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; /** * Default implementation of a controller instance descriptor. @@ -57,7 +58,7 @@ public class DefaultControllerNode implements ControllerNode { * @param tcpPort TCP port */ public DefaultControllerNode(NodeId id, IpAddress ip, int tcpPort) { - this.id = id; + this.id = checkNotNull(id); this.ip = ip; this.tcpPort = tcpPort; } @@ -79,7 +80,7 @@ public class DefaultControllerNode implements ControllerNode { @Override public int hashCode() { - return Objects.hash(id); + return id.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java index 6cfb42c7..e5ab9dc8 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/cluster/NodeId.java @@ -35,7 +35,7 @@ public class NodeId implements Comparable { @Override public int hashCode() { - return Objects.hash(id); + return id.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java index 303ad395..0825a6d1 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/core/CoreService.java @@ -50,6 +50,7 @@ public interface CoreService { /** * Returns an existing application id from a given id. + * * @param id the short value of the id * @return an application id */ @@ -57,6 +58,7 @@ public interface CoreService { /** * Returns an existing application id from a given id. + * * @param name the name portion of the ID to look up * @return an application id */ @@ -67,10 +69,21 @@ public interface CoreService { * to follow the reverse DNS convention, e.g. * {@code org.flying.circus.app} * - * @param identifier string identifier + * @param name string identifier + * @return the application id + */ + ApplicationId registerApplication(String name); + + /** + * Registers a new application by its name, which is expected + * to follow the reverse DNS convention, e.g. + * {@code org.flying.circus.app}, along with its pre-deactivation hook. + * + * @param name string identifier + * @param preDeactivate pre-deactivation hook * @return the application id */ - ApplicationId registerApplication(String identifier); + ApplicationId registerApplication(String name, Runnable preDeactivate); /** * Returns an id generator for a given topic. diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java index c7b5b2da..aedfb0d3 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultApplicationId.java @@ -58,7 +58,7 @@ public class DefaultApplicationId implements ApplicationId { @Override public int hashCode() { - return Objects.hash(id); + return Short.hashCode(id); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java index 9fa8d2b6..243e5216 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/core/DefaultGroupId.java @@ -42,7 +42,7 @@ public class DefaultGroupId implements GroupId { @Override public int hashCode() { - return Objects.hash(id); + return id; } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java b/framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java index a5377016..06e9e206 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/core/Version.java @@ -127,7 +127,7 @@ public final class Version { @Override public int hashCode() { - return Objects.hash(format); + return format.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java index a4789cac..2da2463a 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DefaultPath.java @@ -88,7 +88,7 @@ public class DefaultPath extends DefaultLink implements Path { @Override public int hashCode() { - return Objects.hash(links); + return links.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java index 5331342e..e2c1214f 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/DeviceId.java @@ -75,7 +75,7 @@ public final class DeviceId extends ElementId { @Override public int hashCode() { - return Objects.hash(str); + return str.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java index 3f782954..a15217c6 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/behaviour/BridgeName.java @@ -52,7 +52,7 @@ public final class BridgeName { @Override public int hashCode() { - return Objects.hash(name); + return name.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java index 6beeecc9..4615a82b 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java @@ -388,7 +388,12 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { @Override public Builder setQueue(long queueId) { - return add(Instructions.setQueue(queueId)); + return add(Instructions.setQueue(queueId, null)); + } + + @Override + public Builder setQueue(long queueId, PortNumber port) { + return add(Instructions.setQueue(queueId, port)); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java index b14ab99c..f1a676ab 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java @@ -270,6 +270,15 @@ public interface TrafficTreatment { */ Builder setQueue(long queueId); + /** + * Sets the Queue ID for a specific port. + * + * @param queueId a queue ID + * @param port a port number + * @return a treatment builder + */ + Builder setQueue(long queueId, PortNumber port); + /** * Sets a meter to be used by this flow. * diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java index aad407c8..4e5d39ab 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java @@ -15,6 +15,7 @@ */ package org.onosproject.net.flow.instructions; +import com.google.common.base.MoreObjects; import org.onlab.packet.EthType; import org.onlab.packet.IpAddress; import org.onlab.packet.MacAddress; @@ -99,11 +100,12 @@ public final class Instructions { * Creates a set-queue instruction. * * @param queueId Queue Id + * @param port Port number * @return set-queue instruction */ - public static SetQueueInstruction setQueue(final long queueId) { + public static SetQueueInstruction setQueue(final long queueId, final PortNumber port) { checkNotNull(queueId, "queue ID cannot be null"); - return new SetQueueInstruction(queueId); + return new SetQueueInstruction(queueId, port); } public static MeterInstruction meterTraffic(final MeterId meterId) { @@ -514,7 +516,7 @@ public final class Instructions { @Override public int hashCode() { - return Objects.hash(type().ordinal()); + return type().ordinal(); } @Override @@ -548,7 +550,7 @@ public final class Instructions { @Override public int hashCode() { - return Objects.hash(type().ordinal()); + return type().ordinal(); } @Override @@ -655,15 +657,26 @@ public final class Instructions { */ public static final class SetQueueInstruction implements Instruction { private final long queueId; + private final PortNumber port; private SetQueueInstruction(long queueId) { this.queueId = queueId; + this.port = null; + } + + private SetQueueInstruction(long queueId, PortNumber port) { + this.queueId = queueId; + this.port = port; } public long queueId() { return queueId; } + public PortNumber port() { + return port; + } + @Override public Type type() { return Type.QUEUE; @@ -671,13 +684,18 @@ public final class Instructions { @Override public String toString() { - return toStringHelper(type().toString()) - .add("queueId", queueId).toString(); + MoreObjects.ToStringHelper toStringHelper = toStringHelper(type().toString()); + toStringHelper.add("queueId", queueId); + + if (port() != null) { + toStringHelper.add("port", port); + } + return toStringHelper.toString(); } @Override public int hashCode() { - return Objects.hash(type().ordinal(), queueId); + return Objects.hash(type().ordinal(), queueId, port); } @Override @@ -687,7 +705,7 @@ public final class Instructions { } if (obj instanceof SetQueueInstruction) { SetQueueInstruction that = (SetQueueInstruction) obj; - return Objects.equals(queueId, that.queueId); + return Objects.equals(queueId, that.queueId) && Objects.equals(port, that.port); } return false; diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java index a6e5903c..4af3d168 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java @@ -114,7 +114,7 @@ public abstract class L0ModificationInstruction implements Instruction { @Override public int hashCode() { - return Objects.hash(lambda); + return lambda.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java index c6847d1c..b72dd7bc 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/flow/instructions/L1ModificationInstruction.java @@ -62,7 +62,7 @@ public abstract class L1ModificationInstruction implements Instruction { @Override public int hashCode() { - return Objects.hash(oduSignalId); + return oduSignalId.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java index 546a4513..97f8aedf 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/group/DefaultGroup.java @@ -186,7 +186,7 @@ public class DefaultGroup extends DefaultGroupDescription */ @Override public int hashCode() { - return super.hashCode() + Objects.hash(id); + return Objects.hash(super.hashCode(), id); } /* diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java index 20ccb55d..444feee4 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java @@ -87,7 +87,7 @@ public final class BandwidthConstraint extends BooleanConstraint { @Override public int hashCode() { - return Objects.hash(bandwidth); + return bandwidth.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java index 9dd813b2..7811a004 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java @@ -69,7 +69,7 @@ public class LambdaConstraint extends BooleanConstraint { @Override public int hashCode() { - return Objects.hash(lambda); + return Objects.hashCode(lambda); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java index 54eb4ea5..aecef879 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java @@ -67,7 +67,7 @@ public class LatencyConstraint implements Constraint { @Override public int hashCode() { - return Objects.hash(latency); + return latency.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java index cb1e6b2b..ca4f3fd3 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java @@ -66,7 +66,7 @@ public class ObstacleConstraint extends BooleanConstraint { @Override public int hashCode() { - return Objects.hash(obstacles); + return obstacles.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java index 1acf6dfe..4839feec 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java @@ -91,7 +91,7 @@ public class WaypointConstraint implements Constraint { @Override public int hashCode() { - return Objects.hash(waypoints); + return waypoints.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java index 74f6e102..05cf28f5 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceAllocation.java @@ -53,7 +53,7 @@ public class BandwidthResourceAllocation implements ResourceAllocation { @Override public int hashCode() { - return Objects.hash(bandwidth); + return bandwidth.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java index e07309cb..722b870f 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/BandwidthResourceRequest.java @@ -53,7 +53,7 @@ public class BandwidthResourceRequest implements ResourceRequest { @Override public int hashCode() { - return Objects.hash(bandwidth); + return bandwidth.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java index 545f025f..161cf455 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/LambdaResourceAllocation.java @@ -53,7 +53,7 @@ public class LambdaResourceAllocation implements ResourceAllocation { @Override public int hashCode() { - return Objects.hash(lambda); + return Objects.hashCode(lambda); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java index 10911539..cc9edc2a 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/resource/link/MplsLabelResourceAllocation.java @@ -54,7 +54,7 @@ public class MplsLabelResourceAllocation implements ResourceAllocation { @Override public int hashCode() { - return Objects.hash(mplsLabel); + return Objects.hashCode(mplsLabel); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java index 676f0068..1e6780fa 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/ClusterId.java @@ -53,7 +53,7 @@ public final class ClusterId { @Override public int hashCode() { - return Objects.hash(id); + return id; } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java index dacb5fd8..99d700e1 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyEdge.java @@ -20,6 +20,7 @@ import org.onosproject.net.Link; import java.util.Objects; import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; /** * Implementation of the topology edge backed by a link. @@ -40,7 +41,7 @@ public class DefaultTopologyEdge implements TopologyEdge { public DefaultTopologyEdge(TopologyVertex src, TopologyVertex dst, Link link) { this.src = src; this.dst = dst; - this.link = link; + this.link = checkNotNull(link); } @Override @@ -60,7 +61,7 @@ public class DefaultTopologyEdge implements TopologyEdge { @Override public int hashCode() { - return Objects.hash(link); + return link.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java index 07a09cbd..4782bc95 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/topology/DefaultTopologyVertex.java @@ -42,7 +42,7 @@ public class DefaultTopologyVertex implements TopologyVertex { @Override public int hashCode() { - return Objects.hash(deviceId); + return deviceId.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java index 0cc7b453..4be7ede7 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/store/service/WallClockTimestamp.java @@ -52,7 +52,7 @@ public class WallClockTimestamp implements Timestamp { } @Override public int hashCode() { - return Objects.hash(unixTimestamp); + return Long.hashCode(unixTimestamp); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiView.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiView.java index 2b8b7fa2..c8671159 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiView.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/UiView.java @@ -138,7 +138,7 @@ public class UiView { @Override public int hashCode() { - return Objects.hash(id); + return id.hashCode(); } @Override diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java index a165be33..c75eccf9 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java @@ -18,7 +18,7 @@ package org.onosproject.ui.topo; import com.google.common.collect.Sets; -import java.text.DecimalFormat; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -28,7 +28,7 @@ import java.util.Set; */ public class PropertyPanel { - private static final DecimalFormat DF0 = new DecimalFormat("#,###"); + private static final NumberFormat NF = NumberFormat.getInstance(); private String title; private String typeId; @@ -48,6 +48,24 @@ public class PropertyPanel { this.typeId = typeId; } + /** + * Returns a number formatter to use for formatting integer and long + * property values. + *

+ * This default implementation uses a formatter for the default + * locale. For example: + *

+     *     Locale.ENGLISH  :  1000 -> "1,000"
+     *     Locale.FRENCH   :  1000 -> "1 000"
+     *     Locale.GERMAN   :  1000 -> "1.000"
+     * 
+ * + * @return the number formatter + */ + protected NumberFormat formatter() { + return NF; + } + /** * Adds an ID field to the panel data, to be included in * the returned JSON data to the client. @@ -80,7 +98,7 @@ public class PropertyPanel { * @return self, for chaining */ public PropertyPanel addProp(String key, int value) { - properties.add(new Prop(key, DF0.format(value))); + properties.add(new Prop(key, formatter().format(value))); return this; } @@ -92,7 +110,7 @@ public class PropertyPanel { * @return self, for chaining */ public PropertyPanel addProp(String key, long value) { - properties.add(new Prop(key, DF0.format(value))); + properties.add(new Prop(key, formatter().format(value))); return this; } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/app/ApplicationServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/app/ApplicationServiceAdapter.java index 479cc59a..96324a91 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/app/ApplicationServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/app/ApplicationServiceAdapter.java @@ -50,6 +50,10 @@ public class ApplicationServiceAdapter implements ApplicationService { return null; } + @Override + public void registerDeactivateHook(ApplicationId appId, Runnable hook) { + } + @Override public void addListener(ApplicationListener listener) { } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/core/CoreServiceAdapter.java b/framework/src/onos/core/api/src/test/java/org/onosproject/core/CoreServiceAdapter.java index 0f6abd68..6d45e8c5 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/core/CoreServiceAdapter.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/core/CoreServiceAdapter.java @@ -43,7 +43,12 @@ public class CoreServiceAdapter implements CoreService { } @Override - public ApplicationId registerApplication(String identifier) { + public ApplicationId registerApplication(String name) { + return null; + } + + @Override + public ApplicationId registerApplication(String name, Runnable preDeactivate) { return null; } diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java index d42e22fa..14201472 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java @@ -192,14 +192,17 @@ public class IntentTestsMocks { new MplsLabelResourceAllocation(MplsLabel.valueOf(10))); } + @Override public IntentId intentId() { return null; } + @Override public Collection links() { return null; } + @Override public Set resources() { return null; } @@ -408,7 +411,7 @@ public class IntentTestsMocks { @Override public int hashCode() { - return Objects.hash(priority); + return priority; } @Override diff --git a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java index 7e6cc227..157cdc74 100644 --- a/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java +++ b/framework/src/onos/core/api/src/test/java/org/onosproject/ui/topo/PropertyPanelTest.java @@ -20,17 +20,38 @@ import org.junit.BeforeClass; import org.junit.Test; import org.onosproject.ui.topo.PropertyPanel.Prop; +import java.text.NumberFormat; import java.util.HashMap; import java.util.Iterator; +import java.util.Locale; import java.util.Map; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; /** * Unit tests for {@link PropertyPanel}. */ public class PropertyPanelTest { + // Modified property panel subclass to use ENGLISH locale formatter so + // we know formatted numbers will use comma for the thousand separator. + private static final class EnglishPropertyPanel extends PropertyPanel { + private static final NumberFormat ENGLISH_FORMATTER = + NumberFormat.getInstance(Locale.ENGLISH); + + public EnglishPropertyPanel(String title, String typeId) { + super(title, typeId); + } + + @Override + protected NumberFormat formatter() { + return ENGLISH_FORMATTER; + } + } + private static final String TITLE_ORIG = "Original Title"; private static final String TYPE_ORIG = "Original type ID"; private static final String TITLE_NEW = "New Title"; @@ -76,7 +97,7 @@ public class PropertyPanelTest { @Test public void basic() { - pp = new PropertyPanel(TITLE_ORIG, TYPE_ORIG); + pp = new EnglishPropertyPanel(TITLE_ORIG, TYPE_ORIG); assertEquals("wrong title", TITLE_ORIG, pp.title()); assertEquals("wrong type", TYPE_ORIG, pp.typeId()); assertNull("id?", pp.id()); diff --git a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java index 2ee41945..500a09c7 100644 --- a/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java +++ b/framework/src/onos/core/common/src/test/java/org/onosproject/store/trivial/SystemClockTimestamp.java @@ -51,7 +51,7 @@ public class SystemClockTimestamp implements Timestamp { } @Override public int hashCode() { - return Objects.hash(nanoTimestamp); + return Long.hashCode(nanoTimestamp); } @Override diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java index 161659f9..a9e928e5 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/app/impl/ApplicationManager.java @@ -15,6 +15,7 @@ */ package org.onosproject.app.impl; +import com.google.common.collect.Maps; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; @@ -30,20 +31,21 @@ import org.onosproject.app.ApplicationService; import org.onosproject.app.ApplicationState; import org.onosproject.app.ApplicationStore; import org.onosproject.app.ApplicationStoreDelegate; -import org.onosproject.event.AbstractListenerManager; import org.onosproject.core.Application; import org.onosproject.core.ApplicationId; +import org.onosproject.event.AbstractListenerManager; import org.onosproject.security.Permission; import org.onosproject.security.SecurityUtil; import org.slf4j.Logger; import java.io.InputStream; +import java.util.Map; import java.util.Set; import static com.google.common.base.Preconditions.checkNotNull; import static org.onosproject.app.ApplicationEvent.Type.*; -import static org.onosproject.security.AppPermission.Type.*; import static org.onosproject.security.AppGuard.checkPermission; +import static org.onosproject.security.AppPermission.Type.APP_READ; import static org.slf4j.LoggerFactory.getLogger; /** @@ -69,6 +71,9 @@ public class ApplicationManager private boolean initializing; + // Application supplied hooks for pre-activation processing. + private final Map deactivateHooks = Maps.newConcurrentMap(); + @Activate public void activate() { eventDispatcher.addSink(ApplicationEvent.class, listenerRegistry); @@ -121,6 +126,14 @@ public class ApplicationManager return store.getPermissions(appId); } + @Override + public void registerDeactivateHook(ApplicationId appId, Runnable hook) { + checkPermission(APP_READ); + checkNotNull(appId, APP_ID_NULL); + checkNotNull(hook, "Hook cannot be null"); + deactivateHooks.put(appId.name(), hook); + } + @Override public Application install(InputStream appDescStream) { checkNotNull(appDescStream, "Application archive stream cannot be null"); @@ -235,6 +248,7 @@ public class ApplicationManager private synchronized boolean uninstallAppFeatures(Application app) throws Exception { boolean changed = false; + invokeHook(deactivateHooks.get(app.id().name()), app.id()); for (String name : app.features()) { Feature feature = featuresService.getFeature(name); if (feature != null && featuresService.isInstalled(feature)) { @@ -247,4 +261,16 @@ public class ApplicationManager return changed; } + // Invokes the specified function, if not null. + private void invokeHook(Runnable hook, ApplicationId appId) { + if (hook != null) { + try { + hook.run(); + } catch (Exception e) { + log.warn("Deactivate hook for application {} encountered an error", + appId.name(), e); + } + } + } + } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java index f4d560a4..ec99c18b 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/core/impl/CoreManager.java @@ -24,6 +24,7 @@ import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.ReferenceCardinality; import org.apache.felix.scr.annotations.Service; import org.onlab.util.SharedExecutors; +import org.onosproject.app.ApplicationService; import org.onosproject.cfg.ComponentConfigService; import org.onosproject.core.ApplicationId; import org.onosproject.core.ApplicationIdStore; @@ -48,7 +49,7 @@ import java.util.Set; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Strings.isNullOrEmpty; import static org.onosproject.security.AppGuard.checkPermission; -import static org.onosproject.security.AppPermission.Type.*; +import static org.onosproject.security.AppPermission.Type.APP_READ; @@ -70,6 +71,9 @@ public class CoreManager implements CoreService { @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected IdBlockStore idBlockStore; + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) + protected ApplicationService appService; + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) protected ComponentConfigService cfgService; @@ -111,28 +115,24 @@ public class CoreManager implements CoreService { @Override public Version version() { checkPermission(APP_READ); - return version; } @Override public Set getAppIds() { checkPermission(APP_READ); - return applicationIdStore.getAppIds(); } @Override public ApplicationId getAppId(Short id) { checkPermission(APP_READ); - return applicationIdStore.getAppId(id); } @Override public ApplicationId getAppId(String name) { checkPermission(APP_READ); - return applicationIdStore.getAppId(name); } @@ -143,6 +143,13 @@ public class CoreManager implements CoreService { return applicationIdStore.registerApplication(name); } + @Override + public ApplicationId registerApplication(String name, Runnable preDeactivate) { + ApplicationId id = registerApplication(name); + appService.registerDeactivateHook(id, preDeactivate); + return id; + } + @Override public IdGenerator getIdGenerator(String topic) { IdBlockAllocator allocator = new StoreBasedIdBlockAllocator(topic, idBlockStore); @@ -185,10 +192,10 @@ public class CoreManager implements CoreService { */ private static Integer getIntegerProperty(Dictionary properties, String propertyName) { - Integer value = null; + Integer value; try { String s = (String) properties.get(propertyName); - value = isNullOrEmpty(s) ? value : Integer.parseInt(s.trim()); + value = isNullOrEmpty(s) ? null : Integer.parseInt(s.trim()); } catch (NumberFormatException | ClassCastException e) { value = null; } diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java index 10fe75ea..1f55b157 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java @@ -55,9 +55,6 @@ public final class ResourceManager implements ResourceService, ResourceAdminServ checkNotNull(consumer); checkNotNull(resources); - // TODO: implement support of resource hierarchy - // allocation for a particular resource implies allocations for all of the sub-resources need to be done - boolean success = store.allocate(resources, consumer); if (!success) { return ImmutableList.of(); diff --git a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java index 4067d017..143f8c2b 100644 --- a/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java +++ b/framework/src/onos/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceRegistrar.java @@ -36,7 +36,7 @@ import static org.onlab.util.Tools.groupedThreads; /** * A class registering resources when they are detected. */ -@Component(immediate = true, enabled = false) +@Component(immediate = true) @Beta public final class ResourceRegistrar { diff --git a/framework/src/onos/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java b/framework/src/onos/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java index 1ce31ac3..5461cf01 100644 --- a/framework/src/onos/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java +++ b/framework/src/onos/core/net/src/test/java/org/onosproject/app/impl/ApplicationManagerTest.java @@ -24,11 +24,11 @@ import org.onosproject.app.ApplicationListener; import org.onosproject.app.ApplicationState; import org.onosproject.app.ApplicationStoreAdapter; import org.onosproject.common.app.ApplicationArchive; +import org.onosproject.common.event.impl.TestEventDispatcher; import org.onosproject.core.Application; import org.onosproject.core.ApplicationId; import org.onosproject.core.DefaultApplication; import org.onosproject.core.DefaultApplicationId; -import org.onosproject.common.event.impl.TestEventDispatcher; import java.io.InputStream; import java.net.URI; @@ -36,7 +36,7 @@ import java.util.HashSet; import java.util.Optional; import java.util.Set; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.*; import static org.onosproject.app.ApplicationEvent.Type.*; import static org.onosproject.app.ApplicationState.ACTIVE; import static org.onosproject.app.ApplicationState.INSTALLED; @@ -53,6 +53,8 @@ public class ApplicationManagerTest { private ApplicationManager mgr = new ApplicationManager(); private ApplicationListener listener = new TestListener(); + private boolean deactivated = false; + @Before public void setUp() { injectEventDispatcher(mgr, new TestEventDispatcher()); @@ -88,6 +90,11 @@ public class ApplicationManagerTest { assertEquals("incorrect app count", 1, mgr.getApplications().size()); assertEquals("incorrect app", app, mgr.getApplication(APP_ID)); assertEquals("incorrect app state", INSTALLED, mgr.getState(APP_ID)); + mgr.registerDeactivateHook(app.id(), this::deactivateHook); + } + + private void deactivateHook() { + deactivated = true; } @Test @@ -102,6 +109,7 @@ public class ApplicationManagerTest { install(); mgr.activate(APP_ID); assertEquals("incorrect app state", ACTIVE, mgr.getState(APP_ID)); + assertFalse("preDeactivate hook wrongly called", deactivated); } @Test @@ -109,6 +117,7 @@ public class ApplicationManagerTest { activate(); mgr.deactivate(APP_ID); assertEquals("incorrect app state", INSTALLED, mgr.getState(APP_ID)); + assertTrue("preDeactivate hook not called", deactivated); } diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java index 9382960f..dfee9980 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/impl/LogicalTimestamp.java @@ -50,7 +50,7 @@ public class LogicalTimestamp implements Timestamp { @Override public int hashCode() { - return Objects.hash(value); + return Long.hashCode(value); } @Override diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java index 885361f0..f6cd198f 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/intent/impl/PartitionId.java @@ -56,7 +56,7 @@ public class PartitionId { @Override public int hashCode() { - return Objects.hash(id); + return id; } @Override diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java index 687576c3..c9aaba5a 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java @@ -29,7 +29,6 @@ import org.onosproject.store.service.ConsistentMap; import org.onosproject.store.service.Serializer; import org.onosproject.store.service.StorageService; import org.onosproject.store.service.TransactionContext; -import org.onosproject.store.service.TransactionException; import org.onosproject.store.service.TransactionalMap; import org.onosproject.store.service.Versioned; import org.slf4j.Logger; @@ -100,29 +99,24 @@ public class ConsistentResourceStore implements ResourceStore { TransactionContext tx = service.transactionContextBuilder().build(); tx.begin(); - try { - TransactionalMap> childTxMap = - tx.getTransactionalMap(CHILD_MAP, SERIALIZER); + TransactionalMap> childTxMap = + tx.getTransactionalMap(CHILD_MAP, SERIALIZER); - Map> resourceMap = resources.stream() - .filter(x -> x.parent().isPresent()) - .collect(Collectors.groupingBy(x -> x.parent().get())); + Map> resourceMap = resources.stream() + .filter(x -> x.parent().isPresent()) + .collect(Collectors.groupingBy(x -> x.parent().get())); - for (Map.Entry> entry: resourceMap.entrySet()) { - if (!isRegistered(childTxMap, entry.getKey())) { - return abortTransaction(tx); - } - - if (!appendValues(childTxMap, entry.getKey(), entry.getValue())) { - return abortTransaction(tx); - } + for (Map.Entry> entry: resourceMap.entrySet()) { + if (!isRegistered(childTxMap, entry.getKey())) { + return abortTransaction(tx); } - return commitTransaction(tx); - } catch (TransactionException e) { - log.error("Exception thrown, abort the transaction", e); - return abortTransaction(tx); + if (!appendValues(childTxMap, entry.getKey(), entry.getValue())) { + return abortTransaction(tx); + } } + + return tx.commit(); } @Override @@ -132,33 +126,28 @@ public class ConsistentResourceStore implements ResourceStore { TransactionContext tx = service.transactionContextBuilder().build(); tx.begin(); - try { - TransactionalMap> childTxMap = - tx.getTransactionalMap(CHILD_MAP, SERIALIZER); - TransactionalMap consumerTxMap = - tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER); - - Map> resourceMap = resources.stream() - .filter(x -> x.parent().isPresent()) - .collect(Collectors.groupingBy(x -> x.parent().get())); - - // even if one of the resources is allocated to a consumer, - // all unregistrations are regarded as failure - for (Map.Entry> entry: resourceMap.entrySet()) { - if (entry.getValue().stream().anyMatch(x -> consumerTxMap.get(x) != null)) { - return abortTransaction(tx); - } - - if (!removeValues(childTxMap, entry.getKey(), entry.getValue())) { - return abortTransaction(tx); - } + TransactionalMap> childTxMap = + tx.getTransactionalMap(CHILD_MAP, SERIALIZER); + TransactionalMap consumerTxMap = + tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER); + + Map> resourceMap = resources.stream() + .filter(x -> x.parent().isPresent()) + .collect(Collectors.groupingBy(x -> x.parent().get())); + + // even if one of the resources is allocated to a consumer, + // all unregistrations are regarded as failure + for (Map.Entry> entry: resourceMap.entrySet()) { + if (entry.getValue().stream().anyMatch(x -> consumerTxMap.get(x) != null)) { + return abortTransaction(tx); } - return commitTransaction(tx); - } catch (TransactionException e) { - log.error("Exception thrown, abort the transaction", e); - return abortTransaction(tx); + if (!removeValues(childTxMap, entry.getKey(), entry.getValue())) { + return abortTransaction(tx); + } } + + return tx.commit(); } @Override @@ -169,28 +158,23 @@ public class ConsistentResourceStore implements ResourceStore { TransactionContext tx = service.transactionContextBuilder().build(); tx.begin(); - try { - TransactionalMap> childTxMap = - tx.getTransactionalMap(CHILD_MAP, SERIALIZER); - TransactionalMap consumerTxMap = - tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER); - - for (ResourcePath resource: resources) { - if (!isRegistered(childTxMap, resource)) { - return abortTransaction(tx); - } - - ResourceConsumer oldValue = consumerTxMap.put(resource, consumer); - if (oldValue != null) { - return abortTransaction(tx); - } + TransactionalMap> childTxMap = + tx.getTransactionalMap(CHILD_MAP, SERIALIZER); + TransactionalMap consumerTxMap = + tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER); + + for (ResourcePath resource: resources) { + if (!isRegistered(childTxMap, resource)) { + return abortTransaction(tx); } - return commitTransaction(tx); - } catch (TransactionException e) { - log.error("Exception thrown, abort the transaction", e); - return abortTransaction(tx); + ResourceConsumer oldValue = consumerTxMap.put(resource, consumer); + if (oldValue != null) { + return abortTransaction(tx); + } } + + return tx.commit(); } @Override @@ -202,28 +186,23 @@ public class ConsistentResourceStore implements ResourceStore { TransactionContext tx = service.transactionContextBuilder().build(); tx.begin(); - try { - TransactionalMap consumerTxMap = - tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER); - Iterator resourceIte = resources.iterator(); - Iterator consumerIte = consumers.iterator(); - - while (resourceIte.hasNext() && consumerIte.hasNext()) { - ResourcePath resource = resourceIte.next(); - ResourceConsumer consumer = consumerIte.next(); - - // if this single release fails (because the resource is allocated to another consumer, - // the whole release fails - if (!consumerTxMap.remove(resource, consumer)) { - return abortTransaction(tx); - } - } + TransactionalMap consumerTxMap = + tx.getTransactionalMap(CONSUMER_MAP, SERIALIZER); + Iterator resourceIte = resources.iterator(); + Iterator consumerIte = consumers.iterator(); + + while (resourceIte.hasNext() && consumerIte.hasNext()) { + ResourcePath resource = resourceIte.next(); + ResourceConsumer consumer = consumerIte.next(); - return commitTransaction(tx); - } catch (TransactionException e) { - log.error("Exception thrown, abort the transaction", e); - return abortTransaction(tx); + // if this single release fails (because the resource is allocated to another consumer, + // the whole release fails + if (!consumerTxMap.remove(resource, consumer)) { + return abortTransaction(tx); + } } + + return tx.commit(); } @Override @@ -277,17 +256,6 @@ public class ConsistentResourceStore implements ResourceStore { return false; } - /** - * Commit the transaction. - * - * @param tx transaction context - * @return always true - */ - private boolean commitTransaction(TransactionContext tx) { - tx.commit(); - return true; - } - /** * Appends the values to the existing values associated with the specified key. * If the map already has all the given values, appending will not happen. diff --git a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java index c332ada5..a38550e4 100644 --- a/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java +++ b/framework/src/onos/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java @@ -59,7 +59,6 @@ import org.onosproject.store.service.ConsistentMap; import org.onosproject.store.service.Serializer; import org.onosproject.store.service.StorageService; import org.onosproject.store.service.TransactionContext; -import org.onosproject.store.service.TransactionException; import org.onosproject.store.service.TransactionalMap; import org.onosproject.store.service.Versioned; @@ -294,7 +293,7 @@ public class ConsistentLinkResourceStore extends intentAllocs.put(allocations.intentId(), allocations); allocations.links().forEach(link -> allocateLinkResource(tx, link, allocations)); tx.commit(); - } catch (TransactionException | ResourceAllocationException e) { + } catch (ResourceAllocationException e) { log.error("Exception thrown, rolling back", e); tx.abort(); } catch (Exception e) { @@ -407,12 +406,8 @@ public class ConsistentLinkResourceStore extends after.remove(allocations); linkAllocs.replace(linkId, before, after); }); - tx.commit(); - success = true; - } catch (TransactionException e) { - log.debug("Transaction failed, retrying", e); - tx.abort(); - } catch (Exception e) { + success = tx.commit(); + } catch (Exception e) { log.error("Exception thrown during releaseResource {}", allocations, e); tx.abort(); throw e; diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CpqdOFDPA2Pipeline.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CpqdOFDPA2Pipeline.java index a830ed49..8f976da3 100644 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CpqdOFDPA2Pipeline.java +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/CpqdOFDPA2Pipeline.java @@ -17,6 +17,13 @@ package org.onosproject.driver.pipeline; import static org.slf4j.LoggerFactory.getLogger; +import java.util.ArrayList; +import java.util.List; + +import org.onlab.packet.VlanId; +import org.onosproject.core.ApplicationId; +import org.onosproject.net.Port; +import org.onosproject.net.PortNumber; import org.onosproject.net.flow.DefaultFlowRule; import org.onosproject.net.flow.DefaultTrafficSelector; import org.onosproject.net.flow.DefaultTrafficTreatment; @@ -25,6 +32,8 @@ import org.onosproject.net.flow.FlowRuleOperations; import org.onosproject.net.flow.FlowRuleOperationsContext; import org.onosproject.net.flow.TrafficSelector; import org.onosproject.net.flow.TrafficTreatment; +import org.onosproject.net.flow.criteria.PortCriterion; +import org.onosproject.net.flow.criteria.VlanIdCriterion; import org.slf4j.Logger; @@ -36,17 +45,59 @@ public class CpqdOFDPA2Pipeline extends OFDPA2Pipeline { private final Logger log = getLogger(getClass()); + @Override + protected List processVlanIdFilter(PortCriterion portCriterion, + VlanIdCriterion vidCriterion, + VlanId assignedVlan, + ApplicationId applicationId) { + List rules = new ArrayList(); + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); + selector.matchVlanId(vidCriterion.vlanId()); + if (vidCriterion.vlanId() == VlanId.NONE) { + // untagged packets are assigned vlans + treatment.pushVlan().setVlanId(assignedVlan); + } + treatment.transition(TMAC_TABLE); + + // ofdpa cannot match on ALL portnumber, so we need to use separate + // rules for each port. + List portnums = new ArrayList(); + if (portCriterion.port() == PortNumber.ALL) { + for (Port port : deviceService.getPorts(deviceId)) { + if (port.number().toLong() > 0 && port.number().toLong() < OFPP_MAX) { + portnums.add(port.number()); + } + } + } else { + portnums.add(portCriterion.port()); + } + for (PortNumber pnum : portnums) { + selector.matchInPort(pnum); + FlowRule rule = DefaultFlowRule.builder() + .forDevice(deviceId) + .withSelector(selector.build()) + .withTreatment(treatment.build()) + .withPriority(DEFAULT_PRIORITY) + .fromApp(applicationId) + .makePermanent() + .forTable(VLAN_TABLE).build(); + rules.add(rule); + } + return rules; + } + + @Override protected void initializePipeline() { processPortTable(); + // vlan table processing not required, as default is to drop packets + // which can be accomplished without a table-miss-entry. processTmacTable(); processIpTable(); + processMplsTable(); processBridgingTable(); processAclTable(); - // XXX implement table miss entries and default groups - //processVlanTable(); - //processMPLSTable(); - //processGroupTable(); } @Override @@ -140,6 +191,49 @@ public class CpqdOFDPA2Pipeline extends OFDPA2Pipeline { })); } + @Override + protected void processMplsTable() { + //table miss entry + FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); + TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); + selector = DefaultTrafficSelector.builder(); + treatment = DefaultTrafficTreatment.builder(); + treatment.transition(MPLS_TABLE_1); + FlowRule rule = DefaultFlowRule.builder() + .forDevice(deviceId) + .withSelector(selector.build()) + .withTreatment(treatment.build()) + .withPriority(LOWEST_PRIORITY) + .fromApp(driverId) + .makePermanent() + .forTable(MPLS_TABLE_0).build(); + ops = ops.add(rule); + + treatment.transition(ACL_TABLE); + rule = DefaultFlowRule.builder() + .forDevice(deviceId) + .withSelector(selector.build()) + .withTreatment(treatment.build()) + .withPriority(LOWEST_PRIORITY) + .fromApp(driverId) + .makePermanent() + .forTable(MPLS_TABLE_1).build(); + ops = ops.add(rule); + + flowRuleService.apply(ops.build(new FlowRuleOperationsContext() { + @Override + public void onSuccess(FlowRuleOperations ops) { + log.info("Initialized MPLS tables"); + } + + @Override + public void onError(FlowRuleOperations ops) { + log.info("Failed to initialize MPLS tables"); + } + })); + } + private void processBridgingTable() { //table miss entry FlowRuleOperations.Builder ops = FlowRuleOperations.builder(); diff --git a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA2Pipeline.java b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA2Pipeline.java index b1a1256a..e63a404c 100644 --- a/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA2Pipeline.java +++ b/framework/src/onos/drivers/src/main/java/org/onosproject/driver/pipeline/OFDPA2Pipeline.java @@ -122,7 +122,7 @@ public class OFDPA2Pipeline extends AbstractHandlerBehaviour implements Pipeline protected static final long OFPP_MAX = 0xffffff00L; private static final int HIGHEST_PRIORITY = 0xffff; - private static final int DEFAULT_PRIORITY = 0x8000; + protected static final int DEFAULT_PRIORITY = 0x8000; protected static final int LOWEST_PRIORITY = 0x0; /* @@ -458,8 +458,9 @@ public class OFDPA2Pipeline extends AbstractHandlerBehaviour implements Pipeline if (vidCriterion.vlanId() == VlanId.NONE) { // untagged packets are assigned vlans treatment.pushVlan().setVlanId(assignedVlan); - // XXX ofdpa may require an additional vlan match on the assigned vlan - // and it may not require the push. + // XXX ofdpa will require an additional vlan match on the assigned vlan + // and it may not require the push. This is not in compliance with OF + // standard. Waiting on what the exact flows are going to look like. } treatment.transition(TMAC_TABLE); diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/DomainEdge.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/DomainEdge.java index 4a42a740..ad5e5d18 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/DomainEdge.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/domain/DomainEdge.java @@ -39,7 +39,7 @@ public class DomainEdge extends AbstractEdge { @Override public int hashCode() { - return 43 * super.hashCode() + Objects.hash(connectPoint); + return 43 * super.hashCode() + connectPoint.hashCode(); } @Override diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/OpticalLogicId.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/OpticalLogicId.java index 90f5eab6..d5994863 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/OpticalLogicId.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/tunnel/OpticalLogicId.java @@ -63,7 +63,7 @@ public final class OpticalLogicId { @Override public int hashCode() { - return Objects.hash(logicId); + return Objects.hashCode(logicId); } @Override diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualDevice.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualDevice.java index 54a22a46..e3339a9a 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualDevice.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualDevice.java @@ -53,7 +53,7 @@ public class DefaultVirtualDevice extends DefaultDevice implements VirtualDevice @Override public int hashCode() { - return 31 * super.hashCode() + Objects.hash(networkId); + return 31 * super.hashCode() + networkId.hashCode(); } @Override diff --git a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/TenantId.java b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/TenantId.java index a00f8807..196c17d4 100644 --- a/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/TenantId.java +++ b/framework/src/onos/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/TenantId.java @@ -59,7 +59,7 @@ public final class TenantId { @Override public int hashCode() { - return Objects.hash(id); + return id.hashCode(); } @Override diff --git a/framework/src/onos/incubator/net/src/test/java/org/onosproject/incubator/net/mcast/impl/MulticastRouteManagerTest.java b/framework/src/onos/incubator/net/src/test/java/org/onosproject/incubator/net/mcast/impl/MulticastRouteManagerTest.java index 545e21d0..bec9cded 100644 --- a/framework/src/onos/incubator/net/src/test/java/org/onosproject/incubator/net/mcast/impl/MulticastRouteManagerTest.java +++ b/framework/src/onos/incubator/net/src/test/java/org/onosproject/incubator/net/mcast/impl/MulticastRouteManagerTest.java @@ -23,10 +23,8 @@ import org.onlab.junit.TestUtils; import org.onlab.packet.IpPrefix; import org.onosproject.common.event.impl.TestEventDispatcher; import org.onosproject.core.ApplicationId; -import org.onosproject.core.CoreService; +import org.onosproject.core.CoreServiceAdapter; import org.onosproject.core.DefaultApplicationId; -import org.onosproject.core.IdGenerator; -import org.onosproject.core.Version; import org.onosproject.net.ConnectPoint; import org.onosproject.net.PortNumber; import org.onosproject.net.mcast.McastEvent; @@ -35,7 +33,6 @@ import org.onosproject.net.mcast.McastRoute; import org.onosproject.store.service.TestStorageService; import java.util.List; -import java.util.Set; import static junit.framework.Assert.fail; import static junit.framework.TestCase.assertEquals; @@ -48,16 +45,16 @@ import static org.onosproject.net.NetTestTools.injectEventDispatcher; public class MulticastRouteManagerTest { McastRoute r1 = new McastRoute(IpPrefix.valueOf("1.1.1.1/8"), - IpPrefix.valueOf("1.1.1.2/8"), - McastRoute.Type.IGMP); + IpPrefix.valueOf("1.1.1.2/8"), + McastRoute.Type.IGMP); McastRoute r11 = new McastRoute(IpPrefix.valueOf("1.1.1.1/8"), - IpPrefix.valueOf("1.1.1.2/8"), - McastRoute.Type.STATIC); + IpPrefix.valueOf("1.1.1.2/8"), + McastRoute.Type.STATIC); McastRoute r2 = new McastRoute(IpPrefix.valueOf("2.2.2.1/8"), - IpPrefix.valueOf("2.2.2.2/8"), - McastRoute.Type.PIM); + IpPrefix.valueOf("2.2.2.2/8"), + McastRoute.Type.PIM); ConnectPoint cp1 = new ConnectPoint(did("1"), PortNumber.portNumber(1)); @@ -75,7 +72,7 @@ public class MulticastRouteManagerTest { injectEventDispatcher(manager, new TestEventDispatcher()); TestUtils.setField(manager, "storageService", new TestStorageService()); TestUtils.setField(manager, "coreService", new TestCoreService()); - events = Lists.newArrayList(); + events = Lists.newArrayList(); manager.activate(); manager.addListener(listener); } @@ -152,49 +149,23 @@ public class MulticastRouteManagerTest { for (int i = 0; i < evs.length; i++) { if (evs[i] != events.get(i).type()) { - fail(String.format("Mismtached events# obtained -> %s : expected %s", + fail(String.format("Mismatched events# obtained -> %s : expected %s", events, evs)); } } } class TestMulticastListener implements McastListener { - @Override public void event(McastEvent event) { events.add(event); } } - private class TestCoreService implements CoreService { - @Override - public Version version() { - return null; - } - - @Override - public Set getAppIds() { - return null; - } - - @Override - public ApplicationId getAppId(Short id) { - return null; - } - - @Override - public ApplicationId getAppId(String name) { - return null; - } - - @Override - public ApplicationId registerApplication(String identifier) { - return new DefaultApplicationId(0, identifier); - } - + private class TestCoreService extends CoreServiceAdapter { @Override - public IdGenerator getIdGenerator(String topic) { - return null; + public ApplicationId registerApplication(String name) { + return new DefaultApplicationId(0, name); } } } diff --git a/framework/src/onos/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java b/framework/src/onos/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java index 9d355156..69c06165 100644 --- a/framework/src/onos/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java +++ b/framework/src/onos/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java @@ -114,23 +114,6 @@ public class Controller { return FACTORY13; } - - public Map getControllerNodeIPs() { - // We return a copy of the mapping so we can guarantee that - // the mapping return is the same as one that will be (or was) - // dispatched to IHAListeners - HashMap retval = new HashMap<>(); - synchronized (controllerNodeIPsCache) { - retval.putAll(controllerNodeIPsCache); - } - return retval; - } - - - public long getSystemStartTime() { - return (this.systemStartTime); - } - // ************** // Initialization // ************** @@ -281,11 +264,15 @@ public class Controller { } - public Long getUptime() { + public Long getSystemUptime() { RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean(); return rb.getUptime(); } + public long getSystemStartTime() { + return (this.systemStartTime); + } + /** * Forward to the driver-manager to get an IOFSwitch instance. * diff --git a/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelAdapter.java b/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelAdapter.java new file mode 100644 index 00000000..75260a1d --- /dev/null +++ b/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelAdapter.java @@ -0,0 +1,159 @@ +/* + * 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.openflow; + +import java.net.SocketAddress; + +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelConfig; +import org.jboss.netty.channel.ChannelFactory; +import org.jboss.netty.channel.ChannelFuture; +import org.jboss.netty.channel.ChannelPipeline; + +/** + * Adapter for testing against a netty channel. + */ +public class ChannelAdapter implements Channel { + @Override + public Integer getId() { + return null; + } + + @Override + public ChannelFactory getFactory() { + return null; + } + + @Override + public Channel getParent() { + return null; + } + + @Override + public ChannelConfig getConfig() { + return null; + } + + @Override + public ChannelPipeline getPipeline() { + return null; + } + + @Override + public boolean isOpen() { + return false; + } + + @Override + public boolean isBound() { + return false; + } + + @Override + public boolean isConnected() { + return false; + } + + @Override + public SocketAddress getLocalAddress() { + return null; + } + + @Override + public SocketAddress getRemoteAddress() { + return null; + } + + @Override + public ChannelFuture write(Object o) { + return null; + } + + @Override + public ChannelFuture write(Object o, SocketAddress socketAddress) { + return null; + } + + @Override + public ChannelFuture bind(SocketAddress socketAddress) { + return null; + } + + @Override + public ChannelFuture connect(SocketAddress socketAddress) { + return null; + } + + @Override + public ChannelFuture disconnect() { + return null; + } + + @Override + public ChannelFuture unbind() { + return null; + } + + @Override + public ChannelFuture close() { + return null; + } + + @Override + public ChannelFuture getCloseFuture() { + return null; + } + + @Override + public int getInterestOps() { + return 0; + } + + @Override + public boolean isReadable() { + return false; + } + + @Override + public boolean isWritable() { + return false; + } + + @Override + public ChannelFuture setInterestOps(int i) { + return null; + } + + @Override + public ChannelFuture setReadable(boolean b) { + return null; + } + + @Override + public Object getAttachment() { + return null; + } + + @Override + public void setAttachment(Object o) { + + } + + @Override + public int compareTo(Channel o) { + return 0; + } +} diff --git a/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelHandlerContextAdapter.java b/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelHandlerContextAdapter.java new file mode 100644 index 00000000..5b6c2a36 --- /dev/null +++ b/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/ChannelHandlerContextAdapter.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.openflow; + +import org.jboss.netty.channel.Channel; +import org.jboss.netty.channel.ChannelEvent; +import org.jboss.netty.channel.ChannelHandler; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.channel.ChannelPipeline; + +/** + * Adapter for testing against a netty channel handler context. + */ +public class ChannelHandlerContextAdapter implements ChannelHandlerContext { + @Override + public Channel getChannel() { + return null; + } + + @Override + public ChannelPipeline getPipeline() { + return null; + } + + @Override + public String getName() { + return null; + } + + @Override + public ChannelHandler getHandler() { + return null; + } + + @Override + public boolean canHandleUpstream() { + return false; + } + + @Override + public boolean canHandleDownstream() { + return false; + } + + @Override + public void sendUpstream(ChannelEvent channelEvent) { + + } + + @Override + public void sendDownstream(ChannelEvent channelEvent) { + + } + + @Override + public Object getAttachment() { + return null; + } + + @Override + public void setAttachment(Object o) { + + } +} diff --git a/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/OfMessageAdapter.java b/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/OfMessageAdapter.java new file mode 100644 index 00000000..e9b38e3a --- /dev/null +++ b/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/OfMessageAdapter.java @@ -0,0 +1,54 @@ +/* + * 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.openflow; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.projectfloodlight.openflow.protocol.OFMessage; +import org.projectfloodlight.openflow.protocol.OFType; +import org.projectfloodlight.openflow.protocol.OFVersion; + +import com.google.common.hash.PrimitiveSink; + +/** + * Adapter for testing against an OpenFlow message. + */ +public class OfMessageAdapter implements OFMessage { + @Override + public OFVersion getVersion() { + return null; + } + + @Override + public OFType getType() { + return null; + } + + @Override + public long getXid() { + return 0; + } + + @Override + public void writeTo(ChannelBuffer channelBuffer) { } + + @Override + public Builder createBuilder() { + return null; + } + + @Override + public void putTo(PrimitiveSink sink) { } +} diff --git a/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java b/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java new file mode 100644 index 00000000..ed1db238 --- /dev/null +++ b/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageDecoderTest.java @@ -0,0 +1,84 @@ +/* + * 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.openflow.controller.impl; + + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.openflow.ChannelAdapter; +import org.onosproject.openflow.ChannelHandlerContextAdapter; +import org.projectfloodlight.openflow.protocol.OFHello; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; + +/** + * Tests for the OpenFlow message decoder. + */ +public class OFMessageDecoderTest { + + static class ConnectedChannel extends ChannelAdapter { + @Override + public boolean isConnected() { + return true; + } + } + + private ChannelBuffer getHelloMessageBuffer() { + // OFHello, OF version 1, xid of 0, total of 8 bytes + byte[] messageData = {0x1, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0}; + ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer(); + channelBuffer.writeBytes(messageData); + return channelBuffer; + } + + /** + * Tests decoding a message on a closed channel. + * + * @throws Exception when an exception is thrown from the decoder + */ + @Test + public void testDecodeNoChannel() throws Exception { + OFMessageDecoder decoder = new OFMessageDecoder(); + ChannelBuffer channelBuffer = getHelloMessageBuffer(); + Object message = + decoder.decode(new ChannelHandlerContextAdapter(), + new ChannelAdapter(), + channelBuffer); + assertThat(message, nullValue()); + } + + /** + * Tests decoding a message. + * + * @throws Exception when an exception is thrown from the decoder + */ + @Test + public void testDecode() throws Exception { + OFMessageDecoder decoder = new OFMessageDecoder(); + ChannelBuffer channelBuffer = getHelloMessageBuffer(); + Object message = + decoder.decode(new ChannelHandlerContextAdapter(), + new ConnectedChannel(), + channelBuffer); + assertThat(message, notNullValue()); + assertThat(message, instanceOf(OFHello.class)); + } + +} diff --git a/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageEncoderTest.java b/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageEncoderTest.java new file mode 100644 index 00000000..59685f16 --- /dev/null +++ b/framework/src/onos/openflow/ctl/src/test/java/org/onosproject/openflow/controller/impl/OFMessageEncoderTest.java @@ -0,0 +1,88 @@ +/* + * 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.openflow.controller.impl; + +import java.nio.charset.StandardCharsets; +import java.util.List; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.junit.Test; +import org.onosproject.openflow.OfMessageAdapter; +import org.projectfloodlight.openflow.protocol.OFMessage; + +import com.google.common.collect.ImmutableList; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; + +/** + * Tests for the OpenFlow message encoder. + */ +public class OFMessageEncoderTest { + + static class MockOfMessage extends OfMessageAdapter { + static int nextId = 1; + final int id; + + MockOfMessage() { + id = nextId++; + } + + @Override + public void writeTo(ChannelBuffer channelBuffer) { + String message = "message" + Integer.toString(id) + " "; + channelBuffer.writeBytes(message.getBytes(StandardCharsets.UTF_8)); + } + } + + /** + * Tests that encoding a non-list returns the object specified. + * + * @throws Exception on exception in the encoder + */ + @Test + public void testNoList() throws Exception { + OFMessageEncoder encoder = new OFMessageEncoder(); + MockOfMessage message = new MockOfMessage(); + OFMessage returnedMessage = + (OFMessage) encoder.encode(null, null, message); + assertThat(message, is(returnedMessage)); + } + + /** + * Tests that encoding a list returns the proper encoded payload. + * + * @throws Exception on exception in the encoder + */ + @Test + public void testList() throws Exception { + OFMessageEncoder encoder = new OFMessageEncoder(); + MockOfMessage message1 = new MockOfMessage(); + MockOfMessage message2 = new MockOfMessage(); + MockOfMessage message3 = new MockOfMessage(); + List messages = ImmutableList.of(message1, message2, message3); + ChannelBuffer returnedChannel = + (ChannelBuffer) encoder.encode(null, null, messages); + assertThat(returnedChannel, notNullValue()); + byte[] channelBytes = returnedChannel.array(); + String expectedListMessage = "message1 message2 message3 "; + String listMessage = + (new String(channelBytes, StandardCharsets.UTF_8)) + .substring(0, expectedListMessage.length()); + assertThat(listMessage, is(expectedListMessage)); + } +} diff --git a/framework/src/onos/openflow/pom.xml b/framework/src/onos/openflow/pom.xml index 437f7437..91fe2f69 100644 --- a/framework/src/onos/openflow/pom.xml +++ b/framework/src/onos/openflow/pom.xml @@ -45,6 +45,24 @@ org.onosproject onlab-junit + + junit + junit + 4.11 + test + + + org.hamcrest + hamcrest-core + 1.3 + test + + + org.hamcrest + hamcrest-library + 1.3 + test + diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridgeName.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridgeName.java index 899799fa..759ec499 100644 --- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridgeName.java +++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbBridgeName.java @@ -49,7 +49,7 @@ public final class OvsdbBridgeName { @Override public int hashCode() { - return Objects.hash(value); + return value.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbDatapathId.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbDatapathId.java index 8ccf45f2..02989afa 100644 --- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbDatapathId.java +++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbDatapathId.java @@ -47,7 +47,7 @@ public final class OvsdbDatapathId { @Override public int hashCode() { - return Objects.hash(value); + return value.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEvent.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEvent.java index 35fac7bc..f68b3c8a 100644 --- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEvent.java +++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbEvent.java @@ -48,7 +48,7 @@ public final class OvsdbEvent { } /** - * Returns the type of the event. + * Returns the type of event. * * @return event type */ @@ -57,7 +57,7 @@ public final class OvsdbEvent { } /** - * Returns the subject of the event. + * Returns the subject of event. * * @return subject to which this event pertains */ diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbIfaceId.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbIfaceId.java index 10ba80bc..bf724fa4 100644 --- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbIfaceId.java +++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbIfaceId.java @@ -47,7 +47,7 @@ public class OvsdbIfaceId { @Override public int hashCode() { - return Objects.hash(value); + return value.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java index f3bba4b8..d7a5f61a 100644 --- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java +++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbNodeId.java @@ -22,8 +22,8 @@ import java.util.Objects; import org.onlab.packet.IpAddress; /** - * The class representing a OpenStack Compute or Network nodeId. This class is - * immutable. + * The class representing a OpenStack Compute or Network nodeId. + * This class is immutable. */ public final class OvsdbNodeId { private static final String SCHEME = "ovsdb"; @@ -31,7 +31,7 @@ public final class OvsdbNodeId { private final String ipAddress; /** - * Creates a new node identifier from a IpAddress ipAddress, a long port. + * Creates a new node identifier from an IpAddress ipAddress, a long port. * * @param ipAddress node IP address * @param port node port @@ -44,7 +44,7 @@ public final class OvsdbNodeId { @Override public int hashCode() { - return Objects.hash(nodeId); + return nodeId.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortName.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortName.java index d9c7c2da..7d40e99f 100644 --- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortName.java +++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortName.java @@ -49,7 +49,7 @@ public final class OvsdbPortName { @Override public int hashCode() { - return Objects.hash(value); + return value.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortNumber.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortNumber.java index bd094d04..86fc887a 100644 --- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortNumber.java +++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortNumber.java @@ -47,7 +47,7 @@ public final class OvsdbPortNumber { @Override public int hashCode() { - return Objects.hash(value); + return Objects.hashCode(value); } @Override diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortType.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortType.java index bf05fc73..fb7cdb00 100644 --- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortType.java +++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbPortType.java @@ -21,14 +21,15 @@ import static com.google.common.base.Preconditions.checkNotNull; import java.util.Objects; /** - * The class representing a port type. This class is immutable. + * The class representing a port type. + * This class is immutable. */ public class OvsdbPortType { private final String value; /** - * Constructor from a String port type. + * Constructor from a String. * * @param value the port type to use */ @@ -38,9 +39,9 @@ public class OvsdbPortType { } /** - * Gets the value of the port type. + * Gets the value of port type. * - * @return the value of the port type + * @return the value of port type */ public String value() { return value; @@ -48,7 +49,7 @@ public class OvsdbPortType { @Override public int hashCode() { - return Objects.hash(value); + return value.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnelName.java b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnelName.java index 80befab3..490d640b 100644 --- a/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnelName.java +++ b/framework/src/onos/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/OvsdbTunnelName.java @@ -48,7 +48,7 @@ public final class OvsdbTunnelName { @Override public int hashCode() { - return Objects.hash(value); + return value.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdate.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdate.java index 812a034c..0673b79e 100644 --- a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdate.java +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdate.java @@ -85,7 +85,7 @@ public final class TableUpdate { @Override public int hashCode() { - return Objects.hash(rows); + return rows.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdates.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdates.java index 8938beea..e161016b 100644 --- a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdates.java +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/message/TableUpdates.java @@ -67,7 +67,7 @@ public final class TableUpdates { @Override public int hashCode() { - return Objects.hash(result); + return result.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbMap.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbMap.java index fce3f69f..a62ab0db 100644 --- a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbMap.java +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbMap.java @@ -61,7 +61,7 @@ public final class OvsdbMap { @Override public int hashCode() { - return Objects.hash(map); + return map.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbSet.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbSet.java index fa5abe83..21f0b72b 100644 --- a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbSet.java +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/OvsdbSet.java @@ -63,7 +63,7 @@ public final class OvsdbSet { @Override public int hashCode() { - return Objects.hash(set); + return set.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/UUID.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/UUID.java index 463b75de..0177eea3 100644 --- a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/UUID.java +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/notation/UUID.java @@ -62,7 +62,7 @@ public final class UUID { @Override public int hashCode() { - return Objects.hash(value); + return value.hashCode(); } @Override diff --git a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/AbstractOvsdbTableService.java b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/AbstractOvsdbTableService.java index 6b7c7971..af1a01d6 100644 --- a/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/AbstractOvsdbTableService.java +++ b/framework/src/onos/ovsdb/rfc/src/main/java/org/onosproject/ovsdb/rfc/tableservice/AbstractOvsdbTableService.java @@ -210,7 +210,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService { return null; } ColumnDescription columnDesc = new ColumnDescription("_uuid", "getTableUuidColumn"); - return (Column) getColumnHandler(columnDesc); + return getColumnHandler(columnDesc); } @Override @@ -228,7 +228,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService { return null; } ColumnDescription columnDesc = new ColumnDescription("_version", "getTableVersionColumn"); - return (Column) getColumnHandler(columnDesc); + return getColumnHandler(columnDesc); } /** @@ -260,7 +260,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService { @Override public int hashCode() { - return Objects.hash(row); + return row.hashCode(); } @Override @@ -277,7 +277,7 @@ public abstract class AbstractOvsdbTableService implements OvsdbTableService { @Override public String toString() { - TableSchema schema = (TableSchema) getTableSchema(); + TableSchema schema = getTableSchema(); String tableName = schema.name(); return toStringHelper(this).add("tableName", tableName).add("row", row).toString(); } diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/AdministrativeGroupTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/AdministrativeGroupTlvTest.java deleted file mode 100644 index b3ff2cbb..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/AdministrativeGroupTlvTest.java +++ /dev/null @@ -1,38 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.AdministrativeGroupTlv; - -/** - * Test of the AdministrativeGroupTlv. - */ -public class AdministrativeGroupTlvTest { - private final AdministrativeGroupTlv tlv1 = AdministrativeGroupTlv.of(1); - private final AdministrativeGroupTlv sameAsTlv1 = AdministrativeGroupTlv.of(1); - private final AdministrativeGroupTlv tlv2 = AdministrativeGroupTlv.of(2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/AutonomousSystemTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/AutonomousSystemTlvTest.java deleted file mode 100644 index 7a0078f9..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/AutonomousSystemTlvTest.java +++ /dev/null @@ -1,38 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.AutonomousSystemTlv; - -/** - * Test of the AutonomousSystemTlv. - */ -public class AutonomousSystemTlvTest { - private final AutonomousSystemTlv tlv1 = AutonomousSystemTlv.of(1); - private final AutonomousSystemTlv sameAsTlv1 = AutonomousSystemTlv.of(1); - private final AutonomousSystemTlv tlv2 = AutonomousSystemTlv.of(2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/BGPLSidentifierTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/BGPLSidentifierTlvTest.java deleted file mode 100644 index d7a1f852..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/BGPLSidentifierTlvTest.java +++ /dev/null @@ -1,38 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.BGPLSidentifierTlv; - -/** - * Test of the BGPLSidentifierTlv. - */ -public class BGPLSidentifierTlvTest { - private final BGPLSidentifierTlv tlv1 = BGPLSidentifierTlv.of(1); - private final BGPLSidentifierTlv sameAsTlv1 = BGPLSidentifierTlv.of(1); - private final BGPLSidentifierTlv tlv2 = BGPLSidentifierTlv.of(2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/GmplsCapabilityTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/GmplsCapabilityTlvTest.java deleted file mode 100644 index 3a5c972b..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/GmplsCapabilityTlvTest.java +++ /dev/null @@ -1,38 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.GmplsCapabilityTlv; - -/** - * Test of the GmplsCapabilityTlv. - */ -public class GmplsCapabilityTlvTest { - private final GmplsCapabilityTlv tlv1 = GmplsCapabilityTlv.of(1); - private final GmplsCapabilityTlv sameAsTlv1 = GmplsCapabilityTlv.of(1); - private final GmplsCapabilityTlv tlv2 = GmplsCapabilityTlv.of(2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IGPMetricTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IGPMetricTlvTest.java deleted file mode 100644 index 583b7049..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IGPMetricTlvTest.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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.IGPMetricTlv; - -/** - * Test of the IGPMetricTlv. - */ -public class IGPMetricTlvTest { - private final byte[] b1 = new byte[] {0x01, 0x02}; - private final byte[] b2 = new byte[] {0x01, 0x02}; - private final IGPMetricTlv tlv1 = IGPMetricTlv.of(b1, (short) 2); - private final IGPMetricTlv sameAsTlv1 = IGPMetricTlv.of(b1, (short) 2); - private final IGPMetricTlv tlv2 = IGPMetricTlv.of(b2, (short) 2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4InterfaceAddressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4InterfaceAddressTlvTest.java deleted file mode 100644 index c25a6b5b..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4InterfaceAddressTlvTest.java +++ /dev/null @@ -1,39 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv4InterfaceAddressTlv; - -/** - * Test of the IPv4InterfaceAddressTlv. - */ -public class IPv4InterfaceAddressTlvTest { - - private final IPv4InterfaceAddressTlv tlv1 = IPv4InterfaceAddressTlv.of(2); - private final IPv4InterfaceAddressTlv sameAsTlv1 = IPv4InterfaceAddressTlv.of(2); - private final IPv4InterfaceAddressTlv tlv2 = IPv4InterfaceAddressTlv.of(3); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4NeighborAddressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4NeighborAddressTlvTest.java deleted file mode 100644 index 60a4f120..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4NeighborAddressTlvTest.java +++ /dev/null @@ -1,39 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv4NeighborAddressTlv; - -/** - * Test of the IPv4NeighborAddressTlv. - */ -public class IPv4NeighborAddressTlvTest { - - private final IPv4NeighborAddressTlv tlv1 = IPv4NeighborAddressTlv.of(2); - private final IPv4NeighborAddressTlv sameAsTlv1 = IPv4NeighborAddressTlv.of(2); - private final IPv4NeighborAddressTlv tlv2 = IPv4NeighborAddressTlv.of(3); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4SubObjectTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4SubObjectTest.java deleted file mode 100644 index 08b49879..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4SubObjectTest.java +++ /dev/null @@ -1,39 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv4SubObject; - -/** - * Test of the IPv4SubObject. - */ -public class IPv4SubObjectTest { - - private final IPv4SubObject subObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0); - private final IPv4SubObject sameAsSubObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0); - private final IPv4SubObject subObj2 = IPv4SubObject.of(3, (byte) 16, (byte) 0); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(subObj1, sameAsSubObj1) - .addEqualityGroup(subObj2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfLocalNodeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfLocalNodeTlvTest.java deleted file mode 100644 index d04be239..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfLocalNodeTlvTest.java +++ /dev/null @@ -1,39 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv4TERouterIdOfLocalNodeTlv; - -/** - * Test of the IPv4TERouterIdOfLocalNodeTlv. - */ -public class IPv4TERouterIdOfLocalNodeTlvTest { - - private final IPv4TERouterIdOfLocalNodeTlv tlv1 = IPv4TERouterIdOfLocalNodeTlv.of(2); - private final IPv4TERouterIdOfLocalNodeTlv sameAsTlv1 = IPv4TERouterIdOfLocalNodeTlv.of(2); - private final IPv4TERouterIdOfLocalNodeTlv tlv2 = IPv4TERouterIdOfLocalNodeTlv.of(3); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfRemoteNodeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfRemoteNodeTlvTest.java deleted file mode 100644 index fb8c9653..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv4TERouterIdOfRemoteNodeTlvTest.java +++ /dev/null @@ -1,39 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv4TERouterIdOfRemoteNodeTlv; - -/** - * Test of the IPv4TERouterIdOfRemoteNodeTlv. - */ -public class IPv4TERouterIdOfRemoteNodeTlvTest { - - private final IPv4TERouterIdOfRemoteNodeTlv tlv1 = IPv4TERouterIdOfRemoteNodeTlv.of(2); - private final IPv4TERouterIdOfRemoteNodeTlv sameAsTlv1 = IPv4TERouterIdOfRemoteNodeTlv.of(2); - private final IPv4TERouterIdOfRemoteNodeTlv tlv2 = IPv4TERouterIdOfRemoteNodeTlv.of(3); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6InterfaceAddressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6InterfaceAddressTlvTest.java deleted file mode 100644 index 6eb771da..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6InterfaceAddressTlvTest.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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv6InterfaceAddressTlv; - -/** - * Test of the IPv6InterfaceAddressTlv. - */ -public class IPv6InterfaceAddressTlvTest { - - private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00}; - private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; - - private final IPv6InterfaceAddressTlv tlv1 = IPv6InterfaceAddressTlv.of(b1); - private final IPv6InterfaceAddressTlv sameAsTlv1 = IPv6InterfaceAddressTlv.of(b1); - private final IPv6InterfaceAddressTlv tlv2 = IPv6InterfaceAddressTlv.of(b2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6NeighborAddressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6NeighborAddressTlvTest.java deleted file mode 100644 index 17fa9a3b..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6NeighborAddressTlvTest.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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv6NeighborAddressTlv; - -/** - * Test of the IPv6NeighborAddressTlv. - */ -public class IPv6NeighborAddressTlvTest { - - private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00}; - private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; - - private final IPv6NeighborAddressTlv tlv1 = IPv6NeighborAddressTlv.of(b1); - private final IPv6NeighborAddressTlv sameAsTlv1 = IPv6NeighborAddressTlv.of(b1); - private final IPv6NeighborAddressTlv tlv2 = IPv6NeighborAddressTlv.of(b2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6SubObjectTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6SubObjectTest.java deleted file mode 100644 index 08a47237..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6SubObjectTest.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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv6SubObject; - -/** - * Test of the IPv6SubObject. - */ -public class IPv6SubObjectTest { - - private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00}; - private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; - - private final IPv6SubObject subObj1 = IPv6SubObject.of(b1); - private final IPv6SubObject sameAsSubObj1 = IPv6SubObject.of(b1); - private final IPv6SubObject subObj2 = IPv6SubObject.of(b2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(subObj1, sameAsSubObj1).addEqualityGroup(subObj2).testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofLocalNodeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofLocalNodeTlvTest.java deleted file mode 100644 index b37cb3d8..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofLocalNodeTlvTest.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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv6TERouterIdofLocalNodeTlv; - -/** - * Test of the IPv6TERouterIdofLocalNodeTlv. - */ -public class IPv6TERouterIdofLocalNodeTlvTest { - - private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00}; - private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; - - private final IPv6TERouterIdofLocalNodeTlv tlv1 = IPv6TERouterIdofLocalNodeTlv.of(b1); - private final IPv6TERouterIdofLocalNodeTlv sameAsTlv1 = IPv6TERouterIdofLocalNodeTlv.of(b1); - private final IPv6TERouterIdofLocalNodeTlv tlv2 = IPv6TERouterIdofLocalNodeTlv.of(b2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofRemoteNodeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofRemoteNodeTlvTest.java deleted file mode 100644 index e572e358..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/IPv6TERouterIdofRemoteNodeTlvTest.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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv6TERouterIdofRemoteNodeTlv; - -/** - * Test of the IPv6TERouterIdofRemoteNodeTlv. - */ -public class IPv6TERouterIdofRemoteNodeTlvTest { - - private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00}; - private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; - - private final IPv6TERouterIdofRemoteNodeTlv tlv1 = IPv6TERouterIdofRemoteNodeTlv.of(b1); - private final IPv6TERouterIdofRemoteNodeTlv sameAsTlv1 = IPv6TERouterIdofRemoteNodeTlv.of(b1); - private final IPv6TERouterIdofRemoteNodeTlv tlv2 = IPv6TERouterIdofRemoteNodeTlv.of(b2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/ISISAreaIdentifierTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/ISISAreaIdentifierTlvTest.java deleted file mode 100644 index 7bea1a9b..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/ISISAreaIdentifierTlvTest.java +++ /dev/null @@ -1,42 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.ISISAreaIdentifierTlv; - -/** - * Test of the ISISAreaIdentifierTlv. - */ -public class ISISAreaIdentifierTlvTest { - - private final byte[] b1 = new byte[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; - private final byte[] b2 = new byte[] {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }; - - private final ISISAreaIdentifierTlv tlv1 = ISISAreaIdentifierTlv.of(b1, (short) 20); - private final ISISAreaIdentifierTlv sameAsTlv1 = ISISAreaIdentifierTlv.of(b1, (short) 20); - private final ISISAreaIdentifierTlv tlv2 = ISISAreaIdentifierTlv.of(b2, (short) 20); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LabelSubObjectTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LabelSubObjectTest.java deleted file mode 100644 index 41d1f4ba..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LabelSubObjectTest.java +++ /dev/null @@ -1,39 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.LabelSubObject; - -/** - * Test of the LabelSubObject. - */ -public class LabelSubObjectTest { - - private final LabelSubObject subObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20); - private final LabelSubObject sameAsSubObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20); - private final LabelSubObject subObj2 = LabelSubObject.of((byte) 0, (byte) 1, 30); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(subObj1, sameAsSubObj1) - .addEqualityGroup(subObj2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkLocalRemoteIdentifiersTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkLocalRemoteIdentifiersTlvTest.java deleted file mode 100644 index 1d04b47c..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkLocalRemoteIdentifiersTlvTest.java +++ /dev/null @@ -1,39 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.LinkLocalRemoteIdentifiersTlv; - -/** - * Test of the LinkLocalRemoteIdentifiersTlv. - */ -public class LinkLocalRemoteIdentifiersTlvTest { - - private final LinkLocalRemoteIdentifiersTlv tlv1 = LinkLocalRemoteIdentifiersTlv.of(10, 20); - private final LinkLocalRemoteIdentifiersTlv sameAsTlv1 = LinkLocalRemoteIdentifiersTlv.of(10, 20); - private final LinkLocalRemoteIdentifiersTlv tlv2 = LinkLocalRemoteIdentifiersTlv.of(20, 30); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkNameTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkNameTlvTest.java deleted file mode 100644 index 5236be9d..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkNameTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.LinkNameTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Equality test for LinkNameTlv. - */ -public class LinkNameTlvTest { - private final byte[] rawValue1 = new byte[] {0x01, 0x00}; - private final byte[] rawValue2 = new byte[] {0x02, 0x00}; - - private final LinkNameTlv tlv1 = new LinkNameTlv(rawValue1, (short) rawValue1.length); - private final LinkNameTlv sameAsTlv1 = LinkNameTlv.of(tlv1.getValue(), tlv1.getLength()); - private final LinkNameTlv tlv2 = new LinkNameTlv(rawValue2, (short) 0); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkProtectionTypeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkProtectionTypeTlvTest.java deleted file mode 100644 index 4eea1b00..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LinkProtectionTypeTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.LinkProtectionTypeTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test of the LinkProtectionTypeTlv. - */ -public class LinkProtectionTypeTlvTest { - private final byte rawValue1 = 0x0A; - private final byte rawValue2 = 0x0B; - - private final LinkProtectionTypeTlv tlv1 = new LinkProtectionTypeTlv(rawValue1); - private final LinkProtectionTypeTlv sameAsTlv1 = new LinkProtectionTypeTlv(rawValue1); - private final LinkProtectionTypeTlv tlv2 = new LinkProtectionTypeTlv(rawValue2, (byte) 0); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LocalTENodeDescriptorsTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LocalTENodeDescriptorsTlvTest.java deleted file mode 100644 index 3311a96c..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/LocalTENodeDescriptorsTlvTest.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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; - -import java.util.LinkedList; - -import org.onosproject.pcepio.types.LocalTENodeDescriptorsTlv; -import org.onosproject.pcepio.types.AutonomousSystemTlv; -import org.onosproject.pcepio.types.BGPLSidentifierTlv; -import org.onosproject.pcepio.types.PcepValueType; - -/** - * Test of the LocalTENodeDescriptorsTlv. - */ -public class LocalTENodeDescriptorsTlvTest { - - private final AutonomousSystemTlv baAutoSysTlvRawValue1 = new AutonomousSystemTlv(1); - private final BGPLSidentifierTlv baBgplsIdRawValue1 = new BGPLSidentifierTlv(1); - - private final AutonomousSystemTlv baAutoSysTlvRawValue2 = new AutonomousSystemTlv(2); - private final BGPLSidentifierTlv baBgplsIdRawValue2 = new BGPLSidentifierTlv(2); - - private final LinkedList llNodeDescriptorSubTLVs1 = new LinkedList(); - private final boolean a = llNodeDescriptorSubTLVs1.add(baAutoSysTlvRawValue1); - private final boolean b = llNodeDescriptorSubTLVs1.add(baBgplsIdRawValue1); - - private final LinkedList llNodeDescriptorSubTLVs2 = new LinkedList(); - private final boolean c = llNodeDescriptorSubTLVs2.add(baAutoSysTlvRawValue2); - private final boolean d = llNodeDescriptorSubTLVs2.add(baBgplsIdRawValue2); - - private final LocalTENodeDescriptorsTlv tlv1 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1); - private final LocalTENodeDescriptorsTlv sameAstlv1 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1); - private final LocalTENodeDescriptorsTlv tlv2 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MPLSProtocolMaskTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MPLSProtocolMaskTlvTest.java deleted file mode 100644 index eda99a38..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MPLSProtocolMaskTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.MPLSProtocolMaskTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test of the MPLSProtocolMaskTlv. - */ -public class MPLSProtocolMaskTlvTest { - private final byte rawValue1 = 0x0A; - private final byte rawValue2 = 0x0B; - - private final MPLSProtocolMaskTlv tlv1 = new MPLSProtocolMaskTlv(rawValue1); - private final MPLSProtocolMaskTlv sameAsTlv1 = new MPLSProtocolMaskTlv(rawValue1); - private final MPLSProtocolMaskTlv tlv2 = MPLSProtocolMaskTlv.of(rawValue2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumLinkBandwidthTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumLinkBandwidthTlvTest.java deleted file mode 100644 index 50902acb..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumLinkBandwidthTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.MaximumLinkBandwidthTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test of the MaximumLinkBandwidthTlv. - */ -public class MaximumLinkBandwidthTlvTest { - private final int rawValue1 = 0x0A; - private final int rawValue2 = 0x0B; - - private final MaximumLinkBandwidthTlv tlv1 = new MaximumLinkBandwidthTlv(rawValue1); - private final MaximumLinkBandwidthTlv sameAsTlv1 = new MaximumLinkBandwidthTlv(rawValue1); - private final MaximumLinkBandwidthTlv tlv2 = MaximumLinkBandwidthTlv.of(rawValue2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumReservableLinkBandwidthTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumReservableLinkBandwidthTlvTest.java deleted file mode 100644 index da72c5ff..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/MaximumReservableLinkBandwidthTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.MaximumReservableLinkBandwidthTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test of the MaximumReservableLinkBandwidthTlv. - */ -public class MaximumReservableLinkBandwidthTlvTest { - private final int rawValue1 = 0x0A; - private final int rawValue2 = 0x0B; - - private final MaximumReservableLinkBandwidthTlv tlv1 = new MaximumReservableLinkBandwidthTlv(rawValue1); - private final MaximumReservableLinkBandwidthTlv sameAsTlv1 = new MaximumReservableLinkBandwidthTlv(rawValue1); - private final MaximumReservableLinkBandwidthTlv tlv2 = MaximumReservableLinkBandwidthTlv.of(rawValue2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv4addressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv4addressTlvTest.java deleted file mode 100644 index 27539fae..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv4addressTlvTest.java +++ /dev/null @@ -1,39 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.NexthopIPv4addressTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Equality test for NexthopIPv4addressTlv. - */ -public class NexthopIPv4addressTlvTest { - - private final NexthopIPv4addressTlv tlv1 = new NexthopIPv4addressTlv(0x0A); - private final NexthopIPv4addressTlv sameAsTlv1 = new NexthopIPv4addressTlv(0x0A); - private final NexthopIPv4addressTlv tlv2 = NexthopIPv4addressTlv.of(0x0B); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv6addressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv6addressTlvTest.java deleted file mode 100644 index a543d651..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopIPv6addressTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.NexthopIPv6addressTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Equality test for NexthopIPv6addressTlv. - */ -public class NexthopIPv6addressTlvTest { - - private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00 }; - private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; - - private final NexthopIPv6addressTlv tlv1 = NexthopIPv6addressTlv.of(b1); - private final NexthopIPv6addressTlv sameAsTlv1 = NexthopIPv6addressTlv.of(b1); - private final NexthopIPv6addressTlv tlv2 = NexthopIPv6addressTlv.of(b2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopUnnumberedIPv4IDTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopUnnumberedIPv4IDTlvTest.java deleted file mode 100644 index 457b9347..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NexthopUnnumberedIPv4IDTlvTest.java +++ /dev/null @@ -1,39 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.NexthopUnnumberedIPv4IDTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Equality test for NexthopUnnumberedIPv4IDTlv. - */ -public class NexthopUnnumberedIPv4IDTlvTest { - - private final NexthopUnnumberedIPv4IDTlv tlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A); - private final NexthopUnnumberedIPv4IDTlv sameAsTlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A); - private final NexthopUnnumberedIPv4IDTlv tlv2 = NexthopUnnumberedIPv4IDTlv.of(0x0B, 0x0B); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeFlagBitsTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeFlagBitsTlvTest.java deleted file mode 100644 index a50062ae..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeFlagBitsTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.NodeFlagBitsTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test of the NodeFlagBitsTlv. - */ -public class NodeFlagBitsTlvTest { - private final byte rawValue1 = 0x0A; - private final byte rawValue2 = 0x0B; - - private final NodeFlagBitsTlv tlv1 = new NodeFlagBitsTlv(rawValue1); - private final NodeFlagBitsTlv sameAsTlv1 = new NodeFlagBitsTlv(rawValue1); - private final NodeFlagBitsTlv tlv2 = NodeFlagBitsTlv.of(rawValue2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeNameTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeNameTlvTest.java deleted file mode 100644 index bb35ed90..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/NodeNameTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.NodeNameTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test of the NodeNameTlv. - */ -public class NodeNameTlvTest { - private final byte[] rawValue1 = new byte[] {0x01, 0x02}; - private final byte[] rawValue2 = new byte[] {0x14, 0x15}; - - private final NodeNameTlv tlv1 = new NodeNameTlv(rawValue1, (short) rawValue1.length); - private final NodeNameTlv sameAsTlv1 = NodeNameTlv.of(tlv1.getValue(), tlv1.getLength()); - private final NodeNameTlv tlv2 = new NodeNameTlv(rawValue2, (short) 0); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/OSPFareaIDsubTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/OSPFareaIDsubTlvTest.java deleted file mode 100644 index 4b67a900..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/OSPFareaIDsubTlvTest.java +++ /dev/null @@ -1,38 +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.pcepio; - -import com.google.common.testing.EqualsTester; - -import org.junit.Test; -import org.onosproject.pcepio.types.OSPFareaIDsubTlv; - -/** - * Test of the OSPFareaIDsubTlv. - */ -public class OSPFareaIDsubTlvTest { - private final int rawValue1 = 0x0A; - - private final OSPFareaIDsubTlv tlv1 = new OSPFareaIDsubTlv(rawValue1); - private final OSPFareaIDsubTlv tlv2 = OSPFareaIDsubTlv.of(tlv1.getInt()); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/OpaqueLinkAttributeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/OpaqueLinkAttributeTlvTest.java deleted file mode 100644 index cda77a02..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/OpaqueLinkAttributeTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.OpaqueLinkAttributeTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test of the OpaqueLinkAttributeTlv. - */ -public class OpaqueLinkAttributeTlvTest { - private final byte[] rawValue1 = new byte[] {0x01, 0x02}; - private final byte[] rawValue2 = new byte[] {0x14, 0x15}; - - private final OpaqueLinkAttributeTlv tlv1 = new OpaqueLinkAttributeTlv(rawValue1, (short) rawValue1.length); - private final OpaqueLinkAttributeTlv sameAsTlv1 = OpaqueLinkAttributeTlv.of(tlv1.getValue(), tlv1.getLength()); - private final OpaqueLinkAttributeTlv tlv2 = new OpaqueLinkAttributeTlv(rawValue2, (short) 0); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathKeySubObjectTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathKeySubObjectTest.java deleted file mode 100644 index cab43794..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathKeySubObjectTest.java +++ /dev/null @@ -1,39 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.PathKeySubObject; - -import com.google.common.testing.EqualsTester; - -/** - * Test of the PathKeySubObject. - */ -public class PathKeySubObjectTest { - - private final PathKeySubObject tlv1 = new PathKeySubObject((short) 0x0A, 0x0A); - private final PathKeySubObject sameAsTlv1 = PathKeySubObject.of((short) 0x0A, 0x0A); - private final PathKeySubObject tlv2 = new PathKeySubObject((short) 0x0B, 0x0B); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathSetupTypeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathSetupTypeTlvTest.java deleted file mode 100644 index e56c96e5..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PathSetupTypeTlvTest.java +++ /dev/null @@ -1,36 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.PathSetupTypeTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test of the PathSetupTypeTlv. - */ -public class PathSetupTypeTlvTest { - - private final PathSetupTypeTlv tlv1 = PathSetupTypeTlv.of(0x0A); - private final PathSetupTypeTlv sameAsTlv1 = PathSetupTypeTlv.of(0x0A); - private final PathSetupTypeTlv tlv2 = PathSetupTypeTlv.of(0x0B); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PceccCapabilityTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PceccCapabilityTlvTest.java deleted file mode 100644 index a8d521a9..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PceccCapabilityTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.PceccCapabilityTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test of the PceccCapabilityTlv. - */ -public class PceccCapabilityTlvTest { - private final int rawValue1 = 0x0A; - private final int rawValue2 = 0x0B; - - private final PceccCapabilityTlv tlv1 = new PceccCapabilityTlv(rawValue1); - private final PceccCapabilityTlv sameAsTlv1 = new PceccCapabilityTlv(rawValue1); - private final PceccCapabilityTlv tlv2 = PceccCapabilityTlv.of(rawValue2); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, sameAsTlv1) - .addEqualityGroup(tlv2) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepCloseMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepCloseMsgTest.java deleted file mode 100644 index 8faab559..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepCloseMsgTest.java +++ /dev/null @@ -1,60 +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.pcepio; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Test; -import org.onosproject.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepCloseMsg; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.core.Is.is; - -public class PcepCloseMsgTest { - - /** - * Common header, reason to close. - */ - @Test - public void closeMessageTest1() throws PcepParseException { - - byte[] closeMsg = new byte[] {0x20, 0x07, 0x00, 0x0C, 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02 }; - - byte[] testCloseMsg = {0 }; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(closeMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message; - - message = reader.readFrom(buffer); - assertThat(message, instanceOf(PcepCloseMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testCloseMsg = buf.array(); - - int readLen = buf.writerIndex(); - testCloseMsg = new byte[readLen]; - buf.readBytes(testCloseMsg, 0, readLen); - assertThat(testCloseMsg, is(closeMsg)); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepErrorMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepErrorMsgTest.java deleted file mode 100644 index 2fc1fedf..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepErrorMsgTest.java +++ /dev/null @@ -1,739 +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.pcepio; - - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Test; -import org.onosproject.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepErrorMsg; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.core.Is.is; - -/** - * Test cases for PCEP ERROR Message. - */ -public class PcepErrorMsgTest { - - /** - * This test case checks for - * PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, - * PCECC-CAPABILITY-TLV, TED Capability TLV) - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest1() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x28, // OPEN object header - 0x20, 0x05, 0x1E, 0x01, // OPEN object - 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY - 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x03, 0x00, (byte) 0x84, 0x00, 0x04, // TED Capability TLV - 0x00, 0x00, 0x00, 0x00}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, - * PCECC-CAPABILITY-TLV, TED Capability TLV) - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest2() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x28, // OPEN object header - 0x20, 0x05, 0x1E, 0x01, // OPEN object - 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY - 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x03, 0x00, (byte) 0x84, 0x00, 0x04, // TED Capability TLV - 0x00, 0x00, 0x00, 0x00}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, - * PCECC-CAPABILITY-TLV) - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest3() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x20, // OPEN object header - 0x20, 0x05, 0x1E, 0x01, // OPEN object - 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY - 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x03}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV) - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest4() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2c, // common header - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x18, // OPEN object header - 0x20, 0x05, 0x1E, 0x01, // OPEN object - 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY - 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x00}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY) - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest5() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x10, // OPEN object header - 0x20, 0x05, 0x1E, 0x01, // OPEN object - 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY - 0x00, 0x00, 0x00, 0x05}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest6() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x1C, // common header - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x08, // OPEN object header - 0x20, 0x05, 0x1E, 0x01 // OPEN object - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, OPEN Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest7() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x08, // OPEN object header - 0x20, 0x05, 0x1E, 0x01 // OPEN object - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, RP Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest8() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x20, // common header - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x03}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest9() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header - 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest10() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header - 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * TE Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest11() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header - 0x65, 0x13, 0x00, 0x0C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * RP Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest12() throws PcepParseException { - - //RP Object, PCEP-ERROR Object - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header - 0x02, 0x10, 0x00, 0x0C, // RP Object Header - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * RP Object, RP Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest13() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header - 0x02, 0x10, 0x00, 0x0C, // RP Object Header - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * TE Object, TE Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest14() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header - 0x65, 0x10, 0x00, 0x0C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x65, 0x10, 0x00, 0x0C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID - 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, TE Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest15() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x20, // common header - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x01, 0x65, 0x10, 0x00, 0x0C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x03}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest16() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header - 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x03}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, TE Object, TE Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest17() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header - 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01, 0x65, 0x10, 0x00, 0x0C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x65, 0x10, 0x00, 0x0C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID - 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x03}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest18() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header - 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x06}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, PCEP-ERROR Object, TE Object, TE Object, PCEP-ERROR Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest19() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x03, 0x65, 0x10, 0x00, 0x0C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x65, 0x10, 0x00, 0x0C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x06}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } - - /** - * This test case checks for - * PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object, - * TE Object, PCEP-ERROR Object - * in PcepErrorMsg message. - */ - @Test - public void errorMessageTest20() throws PcepParseException { - - byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x48, // common header - 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header - 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x06, 0x65, 0x10, 0x00, 0x0C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header - 0x00, 0x00, 0x01, 0x06}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(errorMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testErrorMsg = {0}; - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - assertThat(message, instanceOf(PcepErrorMsg.class)); - - message.writeTo(buf); - int iReadLen = buf.writerIndex(); - testErrorMsg = new byte[iReadLen]; - buf.readBytes(testErrorMsg, 0, iReadLen); - - assertThat(testErrorMsg, is(errorMsg)); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgExtTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgExtTest.java deleted file mode 100644 index 9da4c62e..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgExtTest.java +++ /dev/null @@ -1,1686 +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.pcepio; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Test; -import org.onosproject.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepInitiateMsg; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.Matchers.instanceOf; - -public class PcepInitiateMsgExtTest { - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), - * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST objects in PcInitiate message. - */ - @Test - public void initiateMessageTest1() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, - * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA4, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, //Metric object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, - * StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest2() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, - * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA8, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x48, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv - 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, - * ERO, LSPA, BANDWIDTH objects in PcInitiate message. - */ - @Test - public void initiateMessageTest3() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, - * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv - //0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), - * END-POINTS, ERO, LSPA objects in PcInitiate message. - */ - @Test - public void initiateMessageTest4() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, - * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv - // 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest5() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, - * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, - * BANDWIDTH OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest6() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, - * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, - * LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest7() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, - * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x98, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest8() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv), - * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x90, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest9() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv), - * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest10() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), - * END-POINTS, ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA OBJECT - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest11() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv), - * END-POINTS, ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7C, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest12() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), - * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x78, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest13() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv), - * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), - * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest14() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), - * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7c, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), - * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest15() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), - * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), - * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest16() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), - * END-POINTS, ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest17() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, - * BANDWIDTH OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest18() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, - * BANDWIDTH, METRIC OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest19() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x74, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, - * BANDWIDTH, METRIC OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest20() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, - * BANDWIDTH OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest21() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, - * LSPA OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest22() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), - * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest23() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), - * END-POINTS, ERO, LSPA BANDWIDTH OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest25() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA BANDWIDTH OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, - * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest26() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, - * ERO, LSPA, BANDWIDTH, METRIC OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x6C, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, - * BANDWIDTH, METRIC OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest27() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, - * LSPA, BANDWIDTH OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest28() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), - * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest29() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x4C, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), - * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest30() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5C, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest31() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, - * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest32() throws PcepParseException { - - /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, - * ERO, LSPA, BANDWIDTH, METRIC OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, - * ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest33() throws PcepParseException { - - /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, - * ERO, LSPA, BANDWIDTH OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, - * ERO, LSPA OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest34() throws PcepParseException { - - /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, - * ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, - * ERO, LSPA OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest35() throws PcepParseException { - - /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, - * ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, - * ERO, LSPA OBJECT objects in PcInitiate message. - */ - @Test - public void initiateMessageTest36() throws PcepParseException { - - /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, - * ERO, LSPA OBJECT. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object - 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } -} - diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgTest.java deleted file mode 100644 index a27b781f..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepInitiateMsgTest.java +++ /dev/null @@ -1,1335 +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.pcepio; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Test; -import org.onosproject.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepInitiateMsg; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.core.Is.is; - -public class PcepInitiateMsgTest { - - /** - * This test case checks for srp, lsp, end-point, ERO objects in PcInitiate message. - */ - @Test - public void initiateMessageTest1() throws PcepParseException { - - /* srp, lsp, end-point, ERO. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, 0x54, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x00, 0x08, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for srp and lsp objects in PcInitiate message. - */ - @Test - public void initiateMessageTest2() throws PcepParseException { - /* srp, lsp. - */ - byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x34, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x20, 0x10, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - 0x01, 0x01, 0x01, 0x01, 0x00, 0x43, (byte) 0x83, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33}; //SymbolicPathTlv - - byte[] testInitiateDeletionMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateDeletionMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testInitiateDeletionMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateDeletionMsg = new byte[iReadLen]; - buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); - - assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO objects - * in PcInitiate message. - */ - @Test - public void initiateMessageTest3() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv), END-POINT, ERO objects in PcInitiate message. - */ - @Test - public void initiateMessageTest4() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv), END-POINT, ERO. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), - * END-POINT, ERO objects in PcInitiate message. - */ - @Test - public void initiateMessageTest5() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), - * END-POINT, ERO. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5c, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), - * END-POINT, ERO objects in PcInitiate message. - */ - @Test - public void initiateMessageTest6() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), - * END-POINT, ERO. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5c, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), - * END-POINT, ERO objects in PcInitiate message. - */ - @Test - public void initiateMessageTest7() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), - * END-POINT, ERO. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * END-POINT, ERO objects in PcInitiate message. - */ - @Test - public void initiateMessageTest8() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * END-POINT, ERO. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x4c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * END-POINT, ERO objects in PcInitiate message. - */ - @Test - public void initiateMessageTest9() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * END-POINT, ERO. - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x3c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, StatefulRsvpErrorSpecTlv) - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest10() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, StatefulRsvpErrorSpecTlv). - */ - byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x44, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, - (byte) 0xb6, 0x02, 0x4e, 0x20, 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08 //StatefulLspErrorCodeTlv - }; - - byte[] testInitiateDeletionMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateDeletionMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateDeletionMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateDeletionMsg = new byte[iReadLen]; - buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); - - assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv) objects in PcInitiate message. - */ - @Test - public void initiateMessageTest11() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - StatefulLspErrorCodeTlv).*/ - byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x44, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08}; //StatefulLspErrorCodeTlv - - byte[] testInitiateDeletionMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateDeletionMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateDeletionMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateDeletionMsg = new byte[iReadLen]; - buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); - - assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv) - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest12() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv). - */ - byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x3c, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00 //SymbolicPathNameTlv - }; - - byte[] testInitiateDeletionMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateDeletionMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateDeletionMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateDeletionMsg = new byte[iReadLen]; - buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); - - assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv) - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest13() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv). - */ - byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x3c, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00}; //SymbolicPathNameTlv - - byte[] testInitiateDeletionMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateDeletionMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateDeletionMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateDeletionMsg = new byte[iReadLen]; - buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); - - assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv) - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest14() throws PcepParseException { - - /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv). - */ - byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x34, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20}; - - byte[] testInitiateDeletionMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateDeletionMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateDeletionMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateDeletionMsg = new byte[iReadLen]; - buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); - - assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv) - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest15() throws PcepParseException { - - /* SRP, LSP (StatefulIPv4LspIdentidiersTlv). - */ - byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x2c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20}; - - byte[] testInitiateDeletionMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateDeletionMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateDeletionMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateDeletionMsg = new byte[iReadLen]; - buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); - - assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); - } - - /** - * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest16() throws PcepParseException { - - //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest17() throws PcepParseException { - - //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest18() throws PcepParseException { - //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for srp,lsp(all tlvs),end-point,ero,lspa,bandwidth,metric-list - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest19() throws PcepParseException { - //srp,lsp(all tlvs),end-point,ero,lspa,bandwidth,metric-list - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x74, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x04, //ERO object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for srp,lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, srp, - * lsp(SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv) objects in PcInitiate message. - */ - @Test - public void initiateMessageTest20() throws PcepParseException { - /* srp,lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, srp, - * lsp(SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv). - */ - byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x64, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20}; - - byte[] testInitiateDeletionMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateDeletionMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateDeletionMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateDeletionMsg = new byte[iReadLen]; - buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); - - assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); - } - - /** - * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest21() throws PcepParseException { - /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, - * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x94, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest22() throws PcepParseException { - /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, - * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA8, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest23() throws PcepParseException { - /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, - * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth - */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xB0, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest24() throws PcepParseException { - /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, - * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth*/ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xBC, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth, - * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest25() throws PcepParseException { - - /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth, - * srp,lsp(StatefulIPv4LspIdentidiersTlv), - * end-point,ero,lspa,bandwidth,metric-list */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xC4, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,metric-list, - * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest26() throws PcepParseException { - - /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,metric-list, - * srp,lsp(StatefulIPv4LspIdentidiersTlv), - * end-point,ero,lspa,bandwidth,metric-list */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xD0, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } - - /** - * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list, - * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list - * objects in PcInitiate message. - */ - @Test - public void initiateMessageTest27() throws PcepParseException { - - /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list, - * srp,lsp(StatefulIPv4LspIdentidiersTlv), - * end-point,ero,lspa,bandwidth,metric-list */ - byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xE4, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, - 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object - - byte[] testInitiateCreationMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(initiateCreationMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepInitiateMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testInitiateCreationMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testInitiateCreationMsg = new byte[iReadLen]; - buf.readBytes(testInitiateCreationMsg, 0, iReadLen); - - assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepKeepaliveMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepKeepaliveMsgTest.java deleted file mode 100644 index a35c8af5..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepKeepaliveMsgTest.java +++ /dev/null @@ -1,63 +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.pcepio; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Assert; -import org.junit.Test; -import org.onosproject.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepKeepaliveMsg; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.core.Is.is; - -public class PcepKeepaliveMsgTest { - - /** - * Common header for keep alive message. - */ - @Test - public void keepaliveMessageTest1() throws PcepParseException { - - byte[] keepaliveMsg = new byte[] {0x20, 0x02, 0x00, 0x04 }; - - byte[] testKeepaliveMsg = {0 }; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(keepaliveMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - assertThat(message, instanceOf(PcepKeepaliveMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - - message.writeTo(buf); - - testKeepaliveMsg = buf.array(); - - int iReadLen = buf.writerIndex(); - testKeepaliveMsg = new byte[iReadLen]; - buf.readBytes(testKeepaliveMsg, 0, iReadLen); - - Assert.assertThat(testKeepaliveMsg, is(keepaliveMsg)); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepLabelUpdateMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepLabelUpdateMsgTest.java deleted file mode 100644 index d6ec350c..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepLabelUpdateMsgTest.java +++ /dev/null @@ -1,406 +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.pcepio; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Test; -import org.onosproject.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepLabelUpdateMsg; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.Matchers.is; - -public class PcepLabelUpdateMsgTest { - - /** - * This test case checks for - * SRP, LSP, LABEL Object. - * in PcepLabelUpdate message. - */ - @Test - public void labelUpdateMessageTest1() throws PcepParseException { - - byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x24, // common header - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, - 0x20, 0x10, 0x00, 0x08, // LSP Object Header - 0x00, 0x01, 0x00, 0x00, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(labelUpdate); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testLabelUpdateMsg = {0}; - assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); - - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testLabelUpdateMsg = new byte[readLen]; - buf.readBytes(testLabelUpdateMsg, 0, readLen); - - assertThat(testLabelUpdateMsg, is(labelUpdate)); - } - - /** - * This test case checks for - * SRP, LSP, LABEL Object, LABEL Object. - * in PcepLabelUpdate message. - */ - @Test - public void labelUpdateMessageTest2() throws PcepParseException { - - byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x30, // common header - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, - 0x20, 0x10, 0x00, 0x08, // LSP Object Header - 0x00, 0x01, 0x00, 0x00, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x77}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(labelUpdate); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testLabelUpdateMsg = {0}; - assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testLabelUpdateMsg = new byte[readLen]; - buf.readBytes(testLabelUpdateMsg, 0, readLen); - - assertThat(testLabelUpdateMsg, is(labelUpdate)); - } - - /** - * This test case checks for - * SRP, LABEL, FEC Object. - * in PcepLabelUpdate message. - */ - @Test - public void labelUpdateMessageTest3() throws PcepParseException { - - byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x24, // common header - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, - 0x24, 0x10, 0x00, 0x08, // FEC Object Header - 0x0A, 0x0A, 0x0B, 0x0B}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(labelUpdate); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testLabelUpdateMsg = {0}; - assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testLabelUpdateMsg = new byte[readLen]; - buf.readBytes(testLabelUpdateMsg, 0, readLen); - - assertThat(testLabelUpdateMsg, is(labelUpdate)); - } - - /** - * This test case checks for - * SRP, LSP, LABEL, LABEL, SRP, LSP, LABEL - * in PcepLabelUpdate message. - */ - @Test - public void labelUpdateMessageTest4() throws PcepParseException { - - byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, - 0x20, 0x10, 0x00, 0x08, // LSP Object Header - 0x00, 0x01, 0x00, 0x00, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x77, - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x11, - 0x20, 0x10, 0x00, 0x08, // LSP Object Header - 0x00, 0x02, 0x00, 0x00, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x44}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(labelUpdate); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testLabelUpdateMsg = {0}; - assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testLabelUpdateMsg = new byte[readLen]; - buf.readBytes(testLabelUpdateMsg, 0, readLen); - - assertThat(testLabelUpdateMsg, is(labelUpdate)); - } - - /** - * This test case checks for - * SRP, LABEL, FEC, SRP, LABEL, FEC. - * in PcepLabelUpdate message. - */ - @Test - public void labelUpdateMessageTest5() throws PcepParseException { - - byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x44, // common header - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x66, - 0x24, 0x10, 0x00, 0x08, // FEC Object Header - 0x0A, 0x0A, 0x0B, 0x0B, - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x11, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, - 0x24, 0x10, 0x00, 0x08, // FEC Object Header - 0x0A, 0x0A, 0x0C, 0x0C}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(labelUpdate); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testLabelUpdateMsg = {0}; - assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testLabelUpdateMsg = new byte[readLen]; - buf.readBytes(testLabelUpdateMsg, 0, readLen); - - assertThat(testLabelUpdateMsg, is(labelUpdate)); - } - - /** - * This test case checks for - * SRP, LSP, LABEL, LABEL, SRP, LABEL, FEC. - * in PcepLabelUpdate message. - */ - @Test - public void labelUpdateMessageTest6() throws PcepParseException { - - byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, - 0x20, 0x10, 0x00, 0x08, // LSP Object Header - 0x00, 0x01, 0x00, 0x00, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x77, - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x12, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, - 0x24, 0x10, 0x00, 0x08, // FEC Object Header - 0x0A, 0x0A, 0x0D, 0x0D}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(labelUpdate); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testLabelUpdateMsg = {0}; - assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testLabelUpdateMsg = new byte[readLen]; - buf.readBytes(testLabelUpdateMsg, 0, readLen); - - assertThat(testLabelUpdateMsg, is(labelUpdate)); - } - - /** - * This test case checks for - * SRP, LABEL, FEC, SRP, LSP, LABEL, LABEL. - * in PcepLabelUpdate message. - */ - @Test - public void labelUpdateMessageTest7() throws PcepParseException { - - byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x12, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, - 0x24, 0x10, 0x00, 0x08, // FEC Object Header - 0x0A, 0x0A, 0x0D, 0x0D, - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, - 0x20, 0x10, 0x00, 0x08, // LSP Object Header - 0x00, 0x01, 0x00, 0x00, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x77}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(labelUpdate); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testLabelUpdateMsg = {0}; - assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testLabelUpdateMsg = new byte[readLen]; - buf.readBytes(testLabelUpdateMsg, 0, readLen); - - assertThat(testLabelUpdateMsg, is(labelUpdate)); - } - - /** - * This test case checks for - * SRP, LABEL, FEC, SRP, LSP, LABEL, LABEL. - * SRP, LSP, LABEL, LABEL. - * in PcepLabelUpdate message. - */ - @Test - public void labelUpdateMessageTest8() throws PcepParseException { - - byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x7C, // common header - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x12, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, - 0x24, 0x10, 0x00, 0x08, // FEC Object Header - 0x0A, 0x0A, 0x0D, 0x0D, - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, - 0x20, 0x10, 0x00, 0x08, // LSP Object Header - 0x00, 0x01, 0x00, 0x00, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x77, - 0x21, 0x10, 0x00, 0x0C, // SRP Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, - 0x20, 0x10, 0x00, 0x08, // LSP Object Header - 0x00, 0x01, 0x00, 0x00, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x66, - 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x77}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(labelUpdate); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testLabelUpdateMsg = {0}; - - assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testLabelUpdateMsg = new byte[readLen]; - buf.readBytes(testLabelUpdateMsg, 0, readLen); - - assertThat(testLabelUpdateMsg, is(labelUpdate)); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4AdjacencyTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4AdjacencyTest.java deleted file mode 100644 index 390f5738..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4AdjacencyTest.java +++ /dev/null @@ -1,38 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.PcepNaiIpv4Adjacency; - -import com.google.common.testing.EqualsTester; - -/** - * Equality test for PcepNaiIpv4Adjacency. - */ -public class PcepNaiIpv4AdjacencyTest { - - private final PcepNaiIpv4Adjacency obj1 = PcepNaiIpv4Adjacency.of(2, 16); - private final PcepNaiIpv4Adjacency sameAsObj1 = PcepNaiIpv4Adjacency.of(2, 16); - private final PcepNaiIpv4Adjacency obj2 = PcepNaiIpv4Adjacency.of(3, 16); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(obj1, sameAsObj1).addEqualityGroup(obj2).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4NodeIdTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4NodeIdTest.java deleted file mode 100644 index bcd69bea..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv4NodeIdTest.java +++ /dev/null @@ -1,36 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.PcepNaiIpv4NodeId; - -import com.google.common.testing.EqualsTester; - -public class PcepNaiIpv4NodeIdTest { - - private final PcepNaiIpv4NodeId tlv1 = PcepNaiIpv4NodeId.of(1); - private final PcepNaiIpv4NodeId tlv2 = PcepNaiIpv4NodeId.of(1); - private final PcepNaiIpv4NodeId tlv3 = PcepNaiIpv4NodeId.of(3); - - @Test - public void basics() { - new EqualsTester() - .addEqualityGroup(tlv1, tlv2) - .addEqualityGroup(tlv3) - .testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6AdjacencyTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6AdjacencyTest.java deleted file mode 100644 index 5b68193d..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6AdjacencyTest.java +++ /dev/null @@ -1,39 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.PcepNaiIpv6Adjacency; - -import com.google.common.testing.EqualsTester; - -public class PcepNaiIpv6AdjacencyTest { - private final byte[] localIpv6Addr1 = {(byte) 0x01010101 }; - private final byte[] remoteIpv6Addr1 = {(byte) 0x02020202 }; - private final byte[] localIpv6Addr2 = {(byte) 0x01010101 }; - private final byte[] remoteIpv6Addr2 = {(byte) 0x02020202 }; - private final byte[] localIpv6Addr3 = {(byte) 0x05050505 }; - private final byte[] remoteIpv6Addr3 = {(byte) 0x06060606 }; - - private final PcepNaiIpv6Adjacency tlv1 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1); - private final PcepNaiIpv6Adjacency tlv2 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1); - private final PcepNaiIpv6Adjacency tlv3 = PcepNaiIpv6Adjacency.of(localIpv6Addr3, remoteIpv6Addr3); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6NodeIdTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6NodeIdTest.java deleted file mode 100644 index bf458940..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiIpv6NodeIdTest.java +++ /dev/null @@ -1,45 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.PcepNaiIpv6NodeId; - -import com.google.common.testing.EqualsTester; - -/** - * Equality test for PcepNaiIpv6NodeId. - */ -public class PcepNaiIpv6NodeIdTest { - - private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, - 0x00, 0x00 }; - private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, - (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, - 0x00, 0x00 }; - - private final PcepNaiIpv6NodeId tlv1 = PcepNaiIpv6NodeId.of(b1); - private final PcepNaiIpv6NodeId sameAsTlv1 = PcepNaiIpv6NodeId.of(b1); - private final PcepNaiIpv6NodeId tlv2 = PcepNaiIpv6NodeId.of(b2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiUnnumberedAdjacencyIpv4Test.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiUnnumberedAdjacencyIpv4Test.java deleted file mode 100644 index d45bae8b..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepNaiUnnumberedAdjacencyIpv4Test.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.PcepNaiUnnumberedAdjacencyIpv4; - -import com.google.common.testing.EqualsTester; - -public class PcepNaiUnnumberedAdjacencyIpv4Test { - - private final int localNodeId1 = 1; - private final int localInterfaceId1 = 1; - private final int remoteNodeId1 = 1; - private final int remoteInterfaceId1 = 1; - private final PcepNaiUnnumberedAdjacencyIpv4 tlv1 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId1, - localInterfaceId1, remoteNodeId1, remoteInterfaceId1); - - private final int localNodeId2 = 1; - private final int localInterfaceId2 = 1; - private final int remoteNodeId2 = 1; - private final int remoteInterfaceId2 = 1; - private final PcepNaiUnnumberedAdjacencyIpv4 tlv2 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId2, - localInterfaceId2, remoteNodeId2, remoteInterfaceId2); - - private final int localNodeId3 = 2; - private final int localInterfaceId3 = 2; - private final int remoteNodeId3 = 2; - private final int remoteInterfaceId3 = 2; - - private final PcepNaiUnnumberedAdjacencyIpv4 tlv3 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId3, - localInterfaceId3, remoteNodeId3, remoteInterfaceId3); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepOpenMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepOpenMsgTest.java deleted file mode 100644 index 1aff4962..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepOpenMsgTest.java +++ /dev/null @@ -1,562 +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.pcepio; - -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.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; -import org.onosproject.pcepio.protocol.PcepOpenMsg; -/** - * Test cases for PCEP OPEN Message. - */ -public class PcepOpenMsgTest { - - /** - * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, - * PCECC-CAPABILITY-TLV in Pcep Open message. - */ - @Test - public void openMessageTest1() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x10, 0x00, 0x20, 0x20, 0x1e, 0x78, (byte) 0xbd, - 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY - 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV - 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV - }; - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with STATEFUL-PCE-CAPABILITY-TLV in Pcep Open message. - */ - @Test - public void openMessageTest2() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header - 0x01, 0x10, 0x00, 0x10, // common object header - 0x20, 0x1E, 0x78, 0x01, // OPEN object - 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f}; // STATEFUL-PCE-CAPABILITY - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with GmplsCapability tlv in Pcep Open message. - */ - @Test - public void openMessageTest3() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header - 0x01, 0x10, 0x00, 0x10, // common object header - 0x20, 0x1E, 0x78, 0x01, // OPEN object - 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}; //GMPLS-CAPABILITY-TLV - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with StatefulLspDbVer Tlv in Pcep Open message. - */ - @Test - public void openMessageTest4() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18, - 0x01, 0x10, 0x00, 0x14, 0x20, 0x1e, 0x78, 0x20, - 0x00, 0x17, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; //StatefulLspDbVerTlv - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with no tlv's in Pcep Open message. - */ - @Test - public void openMessageTest5() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0C, - 0x01, 0x10, 0x00, 0x08, 0x20, 0x1e, 0x78, (byte) 0xbd }; // no Tlvs in open messsage - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV - * with I bit set in Pcep Open message. - */ - @Test - public void openMessageTest6() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x11, 0x00, 0x20, //p bit not set & i bit set - 0x20, 0x1e, 0x78, (byte) 0xbd, - 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, // STATEFUL-PCE-CAPABILITY - 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV - 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV - }; - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV - * with P bit set in Pcep Open message. - */ - @Test - public void openMessageTest7() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x12, 0x00, 0x20, //p bit set & i bit not set - 0x20, 0x1e, 0x78, (byte) 0xbd, - 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY - 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV - 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV - }; - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV - * with P & I bits set in Pcep Open message. - */ - @Test - public void openMessageTest8() throws PcepParseException { - - /* OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV) - with p bit set & i bit set. - */ - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x13, 0x00, 0x20, //p bit set & i bit set - 0x20, 0x1e, 0x78, (byte) 0xbd, - 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY - 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV - 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV - }; - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV - * with P & I bits set and invalid session id in Pcep Open message. - */ - @Test - public void openMessageTest9() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x13, 0x00, 0x20, //p bit set & i bit set - 0x20, 0x1e, 0x78, 0x00, //invalid sessionID - 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY - 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV - 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV - }; - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV - * in Pcep Open message. - */ - @Test - public void openMessageTest10() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1C, // common header - 0x01, 0x10, 0x00, 0x18, // common object header - 0x20, 0x05, 0x1E, 0x01, // OPEN object - 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY - 0x00, 0x00, 0x00, 0x05, - 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x00}; - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, - * PCECC-CAPABILITY-TLV, TED Capability TLV in Pcep Open message. - */ - @Test - public void openMessageTest11() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x2C, // common header - 0x01, 0x10, 0x00, 0x28, // common object header - 0x20, 0x05, 0x1E, 0x01, // OPEN object - 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY - 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x03, 0x00, (byte) 0x84, 0x00, 0x04, // TED Capability TLV - 0x00, 0x00, 0x00, 0x00 }; - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, - * PCECC-CAPABILITY-TLV in Pcep Open message. - */ - @Test - public void openMessageTest12() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, // common header - 0x01, 0x10, 0x00, 0x20, // common object header - 0x20, 0x05, 0x1E, 0x01, // OPEN object - 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY - 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x03}; - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV - * in Pcep Open message. - */ - @Test - public void openMessageTest13() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1c, // common header - 0x01, 0x10, 0x00, 0x18, // common object header - 0x20, 0x05, 0x1E, 0x01, // OPEN object - 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY - 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV - 0x00, 0x00, 0x00, 0x00}; - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with STATEFUL-PCE-CAPABILITY in Pcep Open message. - */ - @Test - public void openMessageTest14() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header - 0x01, 0x10, 0x00, 0x10, // common object header - 0x20, 0x05, 0x1E, 0x01, // OPEN object - 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY - 0x00, 0x00, 0x00, 0x05}; - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - - assertThat(testOpenMsg, is(openMsg)); - - } - - /** - * This test case checks open object with no tlv Pcep Open message. - */ - @Test - public void openMessageTest15() throws PcepParseException { - - byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0c, // common header - 0x01, 0x10, 0x00, 0x08, // common object header - 0x20, 0x05, 0x1E, 0x01 // OPEN object - }; - - byte[] testOpenMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(openMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepOpenMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testOpenMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testOpenMsg = new byte[readLen]; - buf.readBytes(testOpenMsg, 0, readLen); - assertThat(testOpenMsg, is(openMsg)); - - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepReportMsgExtTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepReportMsgExtTest.java deleted file mode 100644 index 346caf87..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepReportMsgExtTest.java +++ /dev/null @@ -1,221 +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.pcepio; - -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.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; -import org.onosproject.pcepio.protocol.PcepReportMsg; - -public class PcepReportMsgExtTest { - - /** - * This test case checks forSRP Object,LSP Object(symbolic path tlv),ERO Object - * SRP Object,LSP Object(symbolic path tlv,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest39() throws PcepParseException { - - byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x98, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object - * SRP Object,LSP Object(symbolic path tlv),ERO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest40() throws PcepParseException { - - byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x64, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object - * SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object - * in PcRpt message. - */ - @Test - public void reportMessageTest41() throws PcepParseException { - - byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x8c, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object, - * Metric-list SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,Metric-list, - * RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest42() throws PcepParseException { - - byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0xE8, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv - 0x07, 0x10, 0x00, 0x14, //ERO object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepReportMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepReportMsgTest.java deleted file mode 100644 index 237e617f..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepReportMsgTest.java +++ /dev/null @@ -1,1601 +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.pcepio; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Test; -import org.onosproject.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; -import org.onosproject.pcepio.protocol.PcepReportMsg; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.core.Is.is; - -public class PcepReportMsgTest { - - /** - * This test case checks for SRP object, LSP object(Symbolic path name tlv), ERO object - * in PcRpt message. - */ - @Test - public void reportMessageTest1() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, 0x24, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x04}; //ERO Object - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv - * StatefulLspErrorCodeTlv) ERO Object, LSPA Object, Metric-list, IRO object - * in PcRpt message. - */ - @Test - public void reportMessageTest2() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x7c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object // LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, // IPv4SubObjects - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - }; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv,StatefulLspErrorCodeTlv) - * ERO Object, LSPA Object, Metric-list, IRO object - * in PcRpt message. - */ - @Test - public void reportMessageTest3() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70, - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //Ipv4SubObjects - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric Objects - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - }; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv,StatefulLspErrorCodeTlv) - * ERO Object, LSPA Object, Metric-list - * in PcRpt message. - */ - @Test - public void reportMessageTest4() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x64, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv - * StatefulLspErrorCodeTlv) ERO Object, IRO object - * in PcRpt message. - */ - @Test - public void reportMessageTest5() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x50, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv - * StatefulLspErrorCodeTlv) ERO Object, LSPA Object, Metric-list. - * in PcRpt message. - */ - @Test - public void reportMessageTest6() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x04, //ERO Object - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - }; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for LSP Object, ERO Object, LSPA Object, Metric-list, IRO object - * in PcRpt message. - */ - @Test - public void reportMessageTest7() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x58, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, // Metric objects - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP object, LSP object( StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv) ERO object, LSPA object, Metric object - * in PcRpt message. - */ - @Test - public void reportMessageTest8() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv, - * StatefulLspErrorCodeTlv ),ERO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest9() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x44, - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(StatefulIPv4LspIdentidiersTlv)ERO Object,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest10() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(SymbolicPathNameTlv)ERO Object,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest11() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object, ERO Object,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest12() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x60, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(StatefulLspErrorCodeTlv)ERO Object,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest13() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(StatefulRsvpErrorSpecTlv),ERO Object,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest14() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x60, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(symbolic path tlv),LSPA Object,ERO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest15() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x7C, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(symbolic path tlv),BandWidth Object,ERO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest16() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object,ERO Object,LSPA Object,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest17() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object,ERO Object,BandWidth Object,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest18() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object,ERO Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest19() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6C, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest20() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x88, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv, - * StatefulLspErrorCodeTlv ) ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest21() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xac, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) - * ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest22() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xA0, - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) - * ERO Object,BandWidth Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest23() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8c, - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) - * ERO Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest24() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x84, - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) - * ERO Object,LSPA Object,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest25() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8c, - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) - * ERO Object,LSPA Object - * in PcRpt message. - */ - @Test - public void reportMessageTest26() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x58, - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv) - * ERO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest27() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x44, - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) - * LSPA Object,BandWidth Object,Metric-list,ERO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest28() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6c, - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest29() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object - * SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest30() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xE4, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object - * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv) - * ERO Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest31() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, 0x00, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object - * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv) - * ERO Object,LSPA Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest32() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, (byte) 0x14, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object - * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv) - * ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object - * in PcRpt message. - */ - @Test - public void reportMessageTest33() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, (byte) 0x1c, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, - 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object(symbolic path Tlv),ERO Object,LSPA Object - * BandWidth Object,Metric-list,SRP Object,LSP Object(symbolic path tlv) - * ERO Object,LSPA Object,BandWidth Object,Metric-list - * in PcRpt message. - */ - @Test - public void reportMessageTest34() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xB4, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x04, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } - - /** - * This test case checks for SRP Object,LSP Object)Symbolic path tlv),ERO Object,SRP Object - * LSP Object(symbolic path tlv) ERO Object,LSPA Object, BandWidth Object,Metric-list - * in PcRpt message. - */ - @Test - public void reportMessageTest35() throws PcepParseException { - - byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8C, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, //ERO Object - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, //LSPA Object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object - - byte[] testReportMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(reportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(reportMsg)); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepTEReportMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepTEReportMsgTest.java deleted file mode 100644 index b800e05e..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepTEReportMsgTest.java +++ /dev/null @@ -1,1600 +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.pcepio; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Test; -import org.onosproject.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; -import org.onosproject.pcepio.protocol.PcepTEReportMsg; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; -import static org.hamcrest.core.Is.is; - -public class PcepTEReportMsgTest { - - /** - * This test case checks for - * TE Object (Routing Universe TLV, Local TE Node Descriptors TLV(AutonomousSystemTlv)). - * in PcTERpt message. - */ - @Test - public void teReportMessageTest1() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x28, // common header - 0x0E, 0x10, 0x00, 0x24, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x08, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystem Tlv - 0x00, 0x00, 0x00, 0x11}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * T E Object (Routing Universe TLV, Local TE Node Descriptors TLV(AutonomousSystemTlv)) with different TE-ID. - * in PcTERpt message. - */ - @Test - public void teReportMessageTest2() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x28, // common header - 0x0E, 0x10, 0x00, 0x24, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x08, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for TE Object (Routing Universe TLV) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest3() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x1c, // common header - 0x0E, 0x10, 0x00, 0x18, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv. - * OSPFareaIDsubTlv, RouterIDSubTlv)). - * in PcTERpt message. - */ - @Test - public void teReportMessageTest4() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x44, // common header - 0x0E, 0x10, 0x00, 0x40, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest5() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x3C, // common header - 0x0E, 0x10, 0x00, 0x38, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x1C, // Local TE Node Descriptors TLV - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(OSPFareaIDsubTlv, - * RouterIDSubTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest6() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x34, // common header - 0x0E, 0x10, 0x00, 0x30, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x14, // Local TE Node Descriptors TLV - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(RouterIDSubTlv)). - * in PcTERpt message. - */ - @Test - public void teReportMessageTest7() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x2C, // common header - 0x0E, 0x10, 0x00, 0x28, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x0C, // Local TE Node Descriptors TLV - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11}; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for TE Object (Routing Universe TLV,Local TE Node Descriptors TLV) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest8() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x20, // common header - 0x0E, 0x10, 0x00, 0x1C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x00 // Local TE Node Descriptors TLV - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv. - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv. - * OSPFareaIDsubTlv, RouterIDSubTlv)). - * in PcTERpt message. - */ - @Test - public void teReportMessageTest9() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x6C, // common header - 0x0E, 0x10, 0x00, 0x68, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest10() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x64, // common header - 0x0E, 0x10, 0x00, 0x60, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x1C, //RemoteTENodeDescriptorsTLV - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(OSPFareaIDsubTlv, RouterIDSubTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest11() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x5C, // common header - 0x0E, 0x10, 0x00, 0x58, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x14, //RemoteTENodeDescriptorsTLV - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(RouterIDSubTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest12() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x54, // common header - 0x0E, 0x10, 0x00, 0x50, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x0c, //RemoteTENodeDescriptorsTLV - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest13() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x48, // common header - 0x0E, 0x10, 0x00, 0x44, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x00, //RemoteTENodeDescriptorsTLV - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv - * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest14() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x8C, // common header - 0x0E, 0x10, 0x00, (byte) 0x88, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV - 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv - 0x01, 0x11, 0x00, 0x09, - 0x01, 0x21, 0x00, 0x09, - 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv - 0x01, 0x011, 0x01, 0x10 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV( - * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest15() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x80, // common header - 0x0E, 0x10, 0x00, (byte) 0x7C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x10, //TELinkDescriptorsTLV - 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv - 0x01, 0x011, 0x01, 0x10 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(IPv4NeighborAddressTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest16() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x78, // common header - 0x0E, 0x10, 0x00, (byte) 0x74, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x08, //TELinkDescriptorsTLV - 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv - 0x01, 0x011, 0x01, 0x10 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest17() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x70, // common header - 0x0E, 0x10, 0x00, (byte) 0x6C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x00, //TELinkDescriptorsTLV - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv - * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest18() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xC0, // common header - 0x0E, 0x10, 0x00, (byte) 0xbC, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV - 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv - 0x01, 0x11, 0x00, 0x09, - 0x01, 0x21, 0x00, 0x09, - 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv - 0x01, 0x011, 0x01, 0x10, - 0x04, (byte) 0xF3, 0x00, 0x30, //TENodeAttributesTlv - 0x00, 0x0E, 0x00, 0x01, //NodeFlagBitsTlv - (byte) 0x90, 0x00, 0x00, 0x00, - 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv - 0x01, 0x011, 0x01, 0x10, - 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv - 0x08, 0x00, 0x01, 0x09, - 0x08, 0x00, 0x01, 0x09, - 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv - 0x20, 0x01, 0x22, 0x01, - 0x20, 0x01, 0x22, 0x01, - 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv - 0x00, 0x01, 0x01, 0x02 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv - * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv - * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest19() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xC0, // common header - 0x0E, 0x10, 0x00, (byte) 0xBC, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV - 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv - 0x01, 0x11, 0x00, 0x09, - 0x01, 0x21, 0x00, 0x09, - 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv - 0x01, 0x011, 0x01, 0x10, - 0x04, (byte) 0xF3, 0x00, 0x30, //TENodeAttributesTlv - 0x00, 0x0E, 0x00, 0x01, //NodeFlagBitsTlv - (byte) 0x90, 0x00, 0x00, 0x00, - 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv - 0x01, 0x011, 0x01, 0x10, - 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv - 0x08, 0x00, 0x01, 0x09, - 0x08, 0x00, 0x01, 0x09, - 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv - 0x20, 0x01, 0x22, 0x01, - 0x20, 0x01, 0x22, 0x01, - 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv - 0x00, 0x01, 0x01, 0x02 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv - * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(OpaqueNodeAttributeTlv - * NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest20() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xB8, // common header - 0x0E, 0x10, 0x00, (byte) 0xB4, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV - 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv - 0x01, 0x11, 0x00, 0x09, - 0x01, 0x21, 0x00, 0x09, - 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv - 0x01, 0x011, 0x01, 0x10, - 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv - 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv - 0x01, 0x011, 0x01, 0x10, - 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv - 0x08, 0x00, 0x01, 0x09, - 0x08, 0x00, 0x01, 0x09, - 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv - 0x20, 0x01, 0x22, 0x01, - 0x20, 0x01, 0x22, 0x01, - 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv - 0x00, 0x01, 0x01, 0x02 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv. - * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(OpaqueNodeAttributeTlv - * ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest21() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xAC, // common header - 0x0E, 0x10, 0x00, (byte) 0xA8, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV - 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv - 0x01, 0x11, 0x00, 0x09, - 0x01, 0x21, 0x00, 0x09, - 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv - 0x01, 0x011, 0x01, 0x10, - 0x04, (byte) 0xF3, 0x00, 0x1C, //TENodeAttributesTlv - 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv - 0x01, 0x011, 0x01, 0x10, - 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv - 0x20, 0x01, 0x22, 0x01, - 0x20, 0x01, 0x22, 0x01, - 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv - 0x00, 0x01, 0x01, 0x02 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv. - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv. - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv. - * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv. - * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv). - * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv. - * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv. - * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv:, SharedRiskLinkGroupTlv. - * OpaqueLinkAttributeTlv, LinkNameTlv)). - * in PcTERpt message. - */ - @Test - public void teReportMessageTest22() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x120, // common header - 0x0E, 0x10, 0x01, (byte) 0x1C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV - 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv - 0x01, 0x11, 0x00, 0x09, - 0x01, 0x21, 0x00, 0x09, - 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv - 0x01, 0x011, 0x01, 0x10, - 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv - 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv - 0x01, 0x011, 0x01, 0x10, - 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv - 0x08, 0x00, 0x01, 0x09, - 0x08, 0x00, 0x01, 0x09, - 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv - 0x20, 0x01, 0x22, 0x01, - 0x20, 0x01, 0x22, 0x01, - 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv - 0x00, 0x01, 0x01, 0x02, - 0x07, 0x69, 0x00, 0x64, //TELinkAttributesTlv - 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv - 0x00, 0x07, 0x08, 0x00, - 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv - 0x00, 0x09, 0x08, 0x00, - 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv - 0x00, 0x09, 0x00, 0x00, - 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv - 0x00, 0x10, 0x00, 0x00, - 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv - 0x00, 0x00, (byte) 0x90, 0x00, - 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv - 0x00, (byte) 0x99, 0x09, 0x00, - 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv - 0x09, 0x00, 0x00, 0x00, - 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv - (byte) 0x80, 0x00, 0x00, 0x00, - 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv - 0x09, (byte) 0x89, 0x07, 0x00, - 0x04, 0x48, 0x00, 0x08, //SharedRiskLinkGroupTlv - 0x04, 0x47, 0x00, 0x03, - 0x04, 0x47, 0x00, 0x03, //OpaqueLinkAttributeTlv - 0x04, 0x49, 0x00, 0x04, - 0x04, 0x47, 0x00, 0x03, - 0x04, 0x4A, 0x00, 0x04, //LinkNameTlv - 0x04, 0x47, 0x00, 0x03 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv - * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv - * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv) - * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv - * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv - * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv:, SharedRiskLinkGroupTlv - * OpaqueLinkAttributeTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest23() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x118, // common header - 0x0E, 0x10, 0x01, (byte) 0x14, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV - 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv - 0x01, 0x11, 0x00, 0x09, - 0x01, 0x21, 0x00, 0x09, - 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv - 0x01, 0x011, 0x01, 0x10, - 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv - 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv - 0x01, 0x011, 0x01, 0x10, - 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv - 0x08, 0x00, 0x01, 0x09, - 0x08, 0x00, 0x01, 0x09, - 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv - 0x20, 0x01, 0x22, 0x01, - 0x20, 0x01, 0x22, 0x01, - 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv - 0x00, 0x01, 0x01, 0x02, - 0x07, 0x69, 0x00, 0x5C, //TELinkAttributesTlv - 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv - 0x00, 0x07, 0x08, 0x00, - 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv - 0x00, 0x09, 0x08, 0x00, - 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv - 0x00, 0x09, 0x00, 0x00, - 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv - 0x00, 0x10, 0x00, 0x00, - 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv - 0x00, 0x00, (byte) 0x90, 0x00, - 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv - 0x00, (byte) 0x99, 0x09, 0x00, - 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv - 0x09, 0x00, 0x00, 0x00, - 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv - (byte) 0x80, 0x00, 0x00, 0x00, - 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv - 0x09, (byte) 0x89, 0x07, 0x00, - 0x04, 0x48, 0x00, 0x08, //SharedRiskLinkGroupTlv - 0x04, 0x47, 0x00, 0x03, - 0x04, 0x47, 0x00, 0x03, //OpaqueLinkAttributeTlv - 0x04, 0x49, 0x00, 0x04, - 0x04, 0x47, 0x00, 0x03 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv - * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv - * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv) - * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv - * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv - * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv:, SharedRiskLinkGroupTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest24() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x110, // common header - 0x0E, 0x10, 0x01, (byte) 0x0C, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV - 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv - 0x01, 0x11, 0x00, 0x09, - 0x01, 0x21, 0x00, 0x09, - 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv - 0x01, 0x011, 0x01, 0x10, - 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv - 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv - 0x01, 0x011, 0x01, 0x10, - 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv - 0x08, 0x00, 0x01, 0x09, - 0x08, 0x00, 0x01, 0x09, - 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv - 0x20, 0x01, 0x22, 0x01, - 0x20, 0x01, 0x22, 0x01, - 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv - 0x00, 0x01, 0x01, 0x02, - 0x07, 0x69, 0x00, 0x54, //TELinkAttributesTlv - 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv - 0x00, 0x07, 0x08, 0x00, - 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv - 0x00, 0x09, 0x08, 0x00, - 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv - 0x00, 0x09, 0x00, 0x00, - 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv - 0x00, 0x10, 0x00, 0x00, - 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv - 0x00, 0x00, (byte) 0x90, 0x00, - 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv - 0x00, (byte) 0x99, 0x09, 0x00, - 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv - 0x09, 0x00, 0x00, 0x00, - 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv - (byte) 0x80, 0x00, 0x00, 0x00, - 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv - 0x09, (byte) 0x89, 0x07, 0x00, - 0x04, 0x48, 0x00, 0x08, //SharedRiskLinkGroupTlv - 0x04, 0x47, 0x00, 0x03, - 0x04, 0x47, 0x00, 0x03 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } - - /** - * This test case checks for - * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv - * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv - * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv - * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv) - * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv - * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv - * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv)) - * in PcTERpt message. - */ - @Test - public void teReportMessageTest25() throws PcepParseException { - - byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x104, // common header - 0x0E, 0x10, 0x01, 0x00, // TE Object Header - 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID - 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV - 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv - 0x00, 0x00, 0x00, 0x11, - 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv - 0x00, 0x00, 0x00, 0x11, - 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv - 0x00, 0x00, 0x00, 0x11, - 0x00, 0x00, 0x00, 0x11, - 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV - 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv - 0x01, 0x11, 0x00, 0x09, - 0x01, 0x21, 0x00, 0x09, - 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv - 0x01, 0x01, 0x01, 0x01, - 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv - 0x01, 0x011, 0x01, 0x10, - 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv - 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv - 0x01, 0x011, 0x01, 0x10, - 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv - 0x08, 0x00, 0x01, 0x09, - 0x08, 0x00, 0x01, 0x09, - 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv - 0x20, 0x01, 0x22, 0x01, - 0x20, 0x01, 0x22, 0x01, - 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv - 0x00, 0x01, 0x01, 0x02, - 0x07, 0x69, 0x00, 0x48, //TELinkAttributesTlv - 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv - 0x00, 0x07, 0x08, 0x00, - 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv - 0x00, 0x09, 0x08, 0x00, - 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv - 0x00, 0x09, 0x00, 0x00, - 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv - 0x00, 0x10, 0x00, 0x00, - 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv - 0x00, 0x00, (byte) 0x90, 0x00, - 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv - 0x00, (byte) 0x99, 0x09, 0x00, - 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv - 0x09, 0x00, 0x00, 0x00, - 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv - (byte) 0x80, 0x00, 0x00, 0x00, - 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv - 0x09, (byte) 0x89, 0x07, 0x00 - }; - - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(teReportMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - byte[] testReportMsg = {0}; - - assertThat(message, instanceOf(PcepTEReportMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - - int readLen = buf.writerIndex(); - testReportMsg = new byte[readLen]; - buf.readBytes(testReportMsg, 0, readLen); - - assertThat(testReportMsg, is(teReportMsg)); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgExtTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgExtTest.java deleted file mode 100644 index 1f956173..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgExtTest.java +++ /dev/null @@ -1,1275 +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.pcepio; - -import static org.hamcrest.core.Is.is; -import static org.hamcrest.Matchers.instanceOf; - -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; - -import static org.hamcrest.MatcherAssert.assertThat; - -import org.junit.Test; -import org.onosproject.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; -import org.onosproject.pcepio.protocol.PcepUpdateMsg; - -/** - * Test cases for PCEP update message. - */ -public class PcepUpdateMsgExtTest { - - /** - * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object, - * Metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest1() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x8c, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object, - * LSPA, Bandwidth object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest2() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSP object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object, ERO object, LSPA, bandwidth object - * Metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest3() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,bandwidth object - * Metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest4() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,bandwidth object - * Metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest5() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object, LSPA, bandwidth object - * Metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest6() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object, - * bandwidth object Metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest7() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA - * bandwidth object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest8() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA - * bandwidth object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest9() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x18, 0x00, 0x00, 0x10, 0x03, - 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv - 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA - * bandwidth object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest10() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPa object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA - * bandwidth object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest11() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA - * bandwidth object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest12() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,LSPA - * bandwidth object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest13() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA - * metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest14() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object, ERO object,LSPA - * metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest15() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //lspa object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,LSPA - * metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest16() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA - * metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest17() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA - * metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest18() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object, - * metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest19() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object, - * Bandwidth , metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest20() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object, ERO object, - * Bandwidth , metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest21() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object, - * Bandwidth , metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest22() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object, - * Bandwidth , metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest23() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object, - * Bandwidth , metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest24() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object, - * Bandwidth , metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest25() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object, - * LSPA object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest26() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 }; - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object, ERO object, - * bandwidth object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest27() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x34, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object, - * metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest28() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object, - * lspa object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest29() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 }; - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object, - * bandwidth object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest30() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object, - * metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest31() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object, - * Metric object in PcepUpdate message. - */ - @Test - public void pcepUpdateMsgTest32() throws PcepParseException { - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } -} - diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgTest.java deleted file mode 100644 index e965bfeb..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/PcepUpdateMsgTest.java +++ /dev/null @@ -1,1427 +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.pcepio; - -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 static org.hamcrest.MatcherAssert.assertThat; -import org.junit.Test; -import org.onosproject.pcepio.exceptions.PcepParseException; -import org.onosproject.pcepio.protocol.PcepFactories; -import org.onosproject.pcepio.protocol.PcepMessage; -import org.onosproject.pcepio.protocol.PcepMessageReader; -import org.onosproject.pcepio.protocol.PcepUpdateMsg; - -public class PcepUpdateMsgTest { - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), ERO in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest1() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x30, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv - 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x04 }; //ERO object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP(SymbolicPathNameTlv), LSP (StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO, LSPA, Metric-list in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest2() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x94, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object // lsp object - 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv - 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x24, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, - 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), - * ERO objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest3() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x38, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x04 }; //ERO object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv), ERO objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest4() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x04 }; //ERO object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv), ERO objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest5() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x04 }; //ERO object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv), ERO objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest6() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x04 }; - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv), ERO objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest7() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x04}; //ERO object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv), ERO (IPv4SubObject) objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest8() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x0c, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00 }; - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject) objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest9() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00 }; - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject), LSPA objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest10() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x6c, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 }; - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest11() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest12() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest13() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), - * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric Object objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest14() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), - * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest15() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest16() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * ERO (IPv4SubObject, IPv4SubObject),LSPA objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest17() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x05, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 }; - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * ERO (IPv4SubObject, IPv4SubObject),Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest18() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * ERO (IPv4SubObject, IPv4SubObject),Metric-list objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest19() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv),ERO (IPv4SubObject, IPv4SubObject),LSPA, Bandwidth, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest20() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * ERO (IPv4SubObject, IPv4SubObject), Bandwidth objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest21() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest22() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5C, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest23() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv) - * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest24() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv) - * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest25() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, - * Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest26() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, - * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, - * Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest27() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, - * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject), - * LSPA, Bandwidth, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest28() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), - * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest29() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv - (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, - (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP, - * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest30() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (StatefulLspErrorCodeTlv), - * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest31() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP, - * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest32() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x8, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv), - * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest33() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, - 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } - - /** - * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), - * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. - */ - @Test - public void pcepUpdateMsgTest34() throws PcepParseException { - - byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64, - 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object - 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv - 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, - 0x01, 0x01, 0x04, 0x00, - 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, - 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object - 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object - - byte[] testupdateMsg = {0}; - ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); - buffer.writeBytes(updateMsg); - - PcepMessageReader reader = PcepFactories.getGenericReader(); - PcepMessage message = null; - - message = reader.readFrom(buffer); - - assertThat(message, instanceOf(PcepUpdateMsg.class)); - ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); - message.writeTo(buf); - testupdateMsg = buf.array(); - - int readLen = buf.writerIndex() - 0; - testupdateMsg = new byte[readLen]; - buf.readBytes(testupdateMsg, 0, readLen); - - assertThat(testupdateMsg, is(updateMsg)); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RemoteTENodeDescriptorsTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RemoteTENodeDescriptorsTlvTest.java deleted file mode 100644 index 3b189c0b..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RemoteTENodeDescriptorsTlvTest.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.pcepio; - -import java.util.LinkedList; - -import org.junit.Test; -import org.onosproject.pcepio.types.AutonomousSystemTlv; -import org.onosproject.pcepio.types.BGPLSidentifierTlv; -import org.onosproject.pcepio.types.PcepValueType; -import org.onosproject.pcepio.types.RemoteTENodeDescriptorsTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test case for Remote TE Node Descriptors tlv. - */ -public class RemoteTENodeDescriptorsTlvTest { - - private final AutonomousSystemTlv autonomousSystemTlv1 = new AutonomousSystemTlv(10); - private final BGPLSidentifierTlv bGPLSidentifierTlv1 = new BGPLSidentifierTlv(20); - - private final AutonomousSystemTlv autonomousSystemTlv2 = new AutonomousSystemTlv(20); - private final BGPLSidentifierTlv bGPLSidentifierTlv2 = new BGPLSidentifierTlv(30); - - private final LinkedList llRemoteTENodeDescriptorSubTLV1 = new LinkedList<>(); - private final boolean a = llRemoteTENodeDescriptorSubTLV1.add(autonomousSystemTlv1); - private final boolean b = llRemoteTENodeDescriptorSubTLV1.add(bGPLSidentifierTlv1); - - private final LinkedList llRemoteTENodeDescriptorSubTLV2 = new LinkedList<>(); - private final boolean c = llRemoteTENodeDescriptorSubTLV2.add(autonomousSystemTlv2); - private final boolean d = llRemoteTENodeDescriptorSubTLV2.add(bGPLSidentifierTlv2); - - private final RemoteTENodeDescriptorsTlv tlv1 = RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1); - private final RemoteTENodeDescriptorsTlv sameAsTlv1 = - RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1); - private final RemoteTENodeDescriptorsTlv tlv2 = RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RouterIDSubTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RouterIDSubTlvTest.java deleted file mode 100644 index 022fd414..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RouterIDSubTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.RouterIDSubTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test case for Router ID Sub tlv. - */ -public class RouterIDSubTlvTest { - - private final byte[] value1 = {1, 2 }; - private final Short length1 = 2; - private final RouterIDSubTlv tlv1 = RouterIDSubTlv.of(value1, length1); - - private final Short length2 = 2; - private final RouterIDSubTlv tlv2 = RouterIDSubTlv.of(value1, length2); - - private final byte[] value3 = {1, 2, 3 }; - private final Short length3 = 3; - private final RouterIDSubTlv tlv3 = RouterIDSubTlv.of(value3, length3); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RoutingUniverseTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RoutingUniverseTlvTest.java deleted file mode 100644 index 9b119c90..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/RoutingUniverseTlvTest.java +++ /dev/null @@ -1,37 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.RoutingUniverseTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Equality test for RoutingUniverseTlv. - */ -public class RoutingUniverseTlvTest { - - private final RoutingUniverseTlv tlv1 = RoutingUniverseTlv.of(2); - private final RoutingUniverseTlv tlv2 = RoutingUniverseTlv.of(2); - private final RoutingUniverseTlv tlv3 = RoutingUniverseTlv.of(3); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SharedRiskLinkGroupTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SharedRiskLinkGroupTlvTest.java deleted file mode 100644 index ad62f61b..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SharedRiskLinkGroupTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.SharedRiskLinkGroupTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test case for Shared Risk Link Group tlv. - */ -public class SharedRiskLinkGroupTlvTest { - - private final int[] raw = {1 }; - private final Short hLength = 2; - private final SharedRiskLinkGroupTlv tlv1 = SharedRiskLinkGroupTlv.of(raw, hLength); - - private final SharedRiskLinkGroupTlv sameAsTlv1 = SharedRiskLinkGroupTlv.of(raw, hLength); - - private final int[] raw2 = {2 }; - private final Short hLength2 = 3; - private final SharedRiskLinkGroupTlv tlv2 = SharedRiskLinkGroupTlv.of(raw2, hLength2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SrEroSubObjectTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SrEroSubObjectTest.java deleted file mode 100644 index 47ea5842..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SrEroSubObjectTest.java +++ /dev/null @@ -1,61 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.protocol.PcepNai; -import org.onosproject.pcepio.types.SrEroSubObject; - -import com.google.common.testing.EqualsTester; - -public class SrEroSubObjectTest { - - private final boolean bFFlag = false; - private final boolean bSFlag = false; - private final boolean bCFlag = false; - private final boolean bMFlag = false; - private final byte st = 1; - private final int sID = 1; - private final PcepNai nai = null; - - private final SrEroSubObject tlv1 = SrEroSubObject.of(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai); - - private final boolean bFFlag1 = false; - private final boolean bSFlag1 = false; - private final boolean bCFlag1 = false; - private final boolean bMFlag1 = false; - private final byte st1 = 1; - private final int sID1 = 1; - private final PcepNai nai1 = null; - - private final SrEroSubObject tlv2 = SrEroSubObject.of(st1, bFFlag1, bSFlag1, bCFlag1, bMFlag1, sID1, nai1); - - private final boolean bFFlag2 = true; - private final boolean bSFlag2 = true; - private final boolean bCFlag2 = true; - private final boolean bMFlag2 = true; - private final byte st2 = 2; - private final int sID2 = 2; - private final PcepNai nai2 = null; - - private final SrEroSubObject tlv3 = SrEroSubObject.of(st2, bFFlag2, bSFlag2, bCFlag2, bMFlag2, sID2, nai2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulIPv4LspIdentidiersTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulIPv4LspIdentidiersTlvTest.java deleted file mode 100644 index f03c8ba3..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulIPv4LspIdentidiersTlvTest.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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; - -import com.google.common.testing.EqualsTester; - -public class StatefulIPv4LspIdentidiersTlvTest { - - private final int ipv4IngressAddress = 1; - private final short lspId = 1; - private final short tunnelId = 1; - private final int extendedTunnelId = 1; - private final int ipv4EgressAddress = 1; - - private final StatefulIPv4LspIdentidiersTlv tlv1 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress, lspId, - tunnelId, extendedTunnelId, ipv4EgressAddress); - - private final int ipv4IngressAddress1 = 1; - private final short lspId1 = 1; - private final short tunnelId1 = 1; - private final int extendedTunnelId1 = 1; - private final int ipv4EgressAddress1 = 1; - - private final StatefulIPv4LspIdentidiersTlv tlv2 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress1, lspId1, - tunnelId1, extendedTunnelId1, ipv4EgressAddress1); - - private final int ipv4IngressAddress2 = 2; - private final short lspId2 = 2; - private final short tunnelId2 = 2; - private final int extendedTunnelId2 = 2; - private final int ipv4EgressAddress2 = 2; - - private final StatefulIPv4LspIdentidiersTlv tlv3 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress2, lspId2, - tunnelId2, extendedTunnelId2, ipv4EgressAddress2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspDbVerTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspDbVerTlvTest.java deleted file mode 100644 index 21bb3468..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspDbVerTlvTest.java +++ /dev/null @@ -1,37 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.StatefulLspDbVerTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test case for Stateful Lsp Db Ver tlv. - */ -public class StatefulLspDbVerTlvTest { - - private final StatefulLspDbVerTlv tlv1 = StatefulLspDbVerTlv.of(1); - private final StatefulLspDbVerTlv tlv2 = StatefulLspDbVerTlv.of(1); - private final StatefulLspDbVerTlv tlv3 = StatefulLspDbVerTlv.of(2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspErrorCodeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspErrorCodeTlvTest.java deleted file mode 100644 index 8137ca0c..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulLspErrorCodeTlvTest.java +++ /dev/null @@ -1,32 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.StatefulLspErrorCodeTlv; -import com.google.common.testing.EqualsTester; - -public class StatefulLspErrorCodeTlvTest { - - private final StatefulLspErrorCodeTlv tlv1 = StatefulLspErrorCodeTlv.of(1); - private final StatefulLspErrorCodeTlv tlv2 = StatefulLspErrorCodeTlv.of(1); - private final StatefulLspErrorCodeTlv tlv3 = StatefulLspErrorCodeTlv.of(2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulPceCapabilityTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulPceCapabilityTlvTest.java deleted file mode 100644 index 29018d55..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/StatefulPceCapabilityTlvTest.java +++ /dev/null @@ -1,35 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.StatefulPceCapabilityTlv; -import com.google.common.testing.EqualsTester; - -/** - * Test case for Stateful Pce Capability tlv. - */ -public class StatefulPceCapabilityTlvTest { - - private final StatefulPceCapabilityTlv tlv1 = StatefulPceCapabilityTlv.of(1); - private final StatefulPceCapabilityTlv tlv2 = StatefulPceCapabilityTlv.of(1); - private final StatefulPceCapabilityTlv tlv3 = StatefulPceCapabilityTlv.of(2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SymbolicPathNameTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SymbolicPathNameTlvTest.java deleted file mode 100644 index 718bbb66..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/SymbolicPathNameTlvTest.java +++ /dev/null @@ -1,45 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.SymbolicPathNameTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test case for Symbolic path tlv. - */ -public class SymbolicPathNameTlvTest { - - private final byte[] value1 = {0x41 }; - private final Short length1 = 2; - private final SymbolicPathNameTlv tlv1 = SymbolicPathNameTlv.of(value1, length1); - - private final byte[] value2 = {0x41 }; - private final Short length2 = 2; - private final SymbolicPathNameTlv tlv2 = SymbolicPathNameTlv.of(value1, length2); - - private final byte[] value3 = {0x41, 0x43 }; - private final Short length3 = 3; - private final SymbolicPathNameTlv tlv3 = SymbolicPathNameTlv.of(value3, length3); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TEDefaultMetricTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TEDefaultMetricTlvTest.java deleted file mode 100644 index 32fa0af8..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TEDefaultMetricTlvTest.java +++ /dev/null @@ -1,36 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.TEDefaultMetricTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test case for TE Default Metric tlv. - */ -public class TEDefaultMetricTlvTest { - - private final TEDefaultMetricTlv tlv1 = TEDefaultMetricTlv.of(1); - private final TEDefaultMetricTlv tlv2 = TEDefaultMetricTlv.of(1); - private final TEDefaultMetricTlv tlv3 = TEDefaultMetricTlv.of(2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } -} \ No newline at end of file diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkAttributesTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkAttributesTlvTest.java deleted file mode 100644 index 1e2101a9..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkAttributesTlvTest.java +++ /dev/null @@ -1,59 +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.pcepio; - -import java.util.LinkedList; - -import org.junit.Test; -import org.onosproject.pcepio.types.AdministrativeGroupTlv; -import org.onosproject.pcepio.types.MaximumReservableLinkBandwidthTlv; -import org.onosproject.pcepio.types.PcepValueType; -import org.onosproject.pcepio.types.TELinkAttributesTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test case for TE Link Attribute Tlv. - */ -public class TELinkAttributesTlvTest { - - private final AdministrativeGroupTlv administrativeGroupTlv1 = new AdministrativeGroupTlv(10); - private final MaximumReservableLinkBandwidthTlv maximumReservableLinkBandwidthTlv1 = - new MaximumReservableLinkBandwidthTlv(20); - - private final AdministrativeGroupTlv administrativeGroupTlv2 = new AdministrativeGroupTlv(20); - private final MaximumReservableLinkBandwidthTlv maximumReservableLinkBandwidthTlv2 = - new MaximumReservableLinkBandwidthTlv(30); - - private final LinkedList llLinkAttributesSubTLV1 = new LinkedList<>(); - private final boolean a = llLinkAttributesSubTLV1.add(administrativeGroupTlv1); - private final boolean b = llLinkAttributesSubTLV1.add(maximumReservableLinkBandwidthTlv1); - - private final LinkedList llLinkAttributesSubTLV2 = new LinkedList<>(); - - private final boolean c = llLinkAttributesSubTLV2.add(administrativeGroupTlv2); - private final boolean d = llLinkAttributesSubTLV2.add(maximumReservableLinkBandwidthTlv2); - - private final TELinkAttributesTlv tlv1 = TELinkAttributesTlv.of(llLinkAttributesSubTLV1); - private final TELinkAttributesTlv sameAsTlv1 = TELinkAttributesTlv.of(llLinkAttributesSubTLV1); - private final TELinkAttributesTlv tlv2 = TELinkAttributesTlv.of(llLinkAttributesSubTLV2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkDescriptorsTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkDescriptorsTlvTest.java deleted file mode 100644 index 89565b3f..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TELinkDescriptorsTlvTest.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.pcepio; - -import java.util.LinkedList; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv4InterfaceAddressTlv; -import org.onosproject.pcepio.types.LinkLocalRemoteIdentifiersTlv; -import org.onosproject.pcepio.types.PcepValueType; -import org.onosproject.pcepio.types.TELinkDescriptorsTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test case for TE link descriptors Tlv. - */ -public class TELinkDescriptorsTlvTest { - private final LinkLocalRemoteIdentifiersTlv linkLocalRemoteIdentifiersTlv1 = new - LinkLocalRemoteIdentifiersTlv(10, 10); - private final IPv4InterfaceAddressTlv iPv4InterfaceAddressTlv1 = new IPv4InterfaceAddressTlv(0x01010101); - - private final LinkLocalRemoteIdentifiersTlv linkLocalRemoteIdentifiersTlv2 = new - LinkLocalRemoteIdentifiersTlv(20, 20); - private final IPv4InterfaceAddressTlv iPv4InterfaceAddressTlv2 = new IPv4InterfaceAddressTlv(0x02020202); - - private final LinkedList llLinkDescriptorsSubTLVs1 = new LinkedList<>(); - private final boolean a = llLinkDescriptorsSubTLVs1.add(linkLocalRemoteIdentifiersTlv1); - private final boolean b = llLinkDescriptorsSubTLVs1.add(iPv4InterfaceAddressTlv1); - - private final LinkedList llLinkDescriptorsSubTLVs2 = new LinkedList<>(); - private final boolean c = llLinkDescriptorsSubTLVs2.add(linkLocalRemoteIdentifiersTlv2); - private final boolean d = llLinkDescriptorsSubTLVs2.add(iPv4InterfaceAddressTlv2); - - private final TELinkDescriptorsTlv tlv1 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1); - private final TELinkDescriptorsTlv sameAstlv1 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1); - private final TELinkDescriptorsTlv tlv2 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TENodeAttributesTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TENodeAttributesTlvTest.java deleted file mode 100644 index 17d44091..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TENodeAttributesTlvTest.java +++ /dev/null @@ -1,59 +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.pcepio; - -import java.util.LinkedList; - -import org.junit.Test; -import org.onosproject.pcepio.types.IPv4TERouterIdOfLocalNodeTlv; -import org.onosproject.pcepio.types.NodeFlagBitsTlv; -import org.onosproject.pcepio.types.PcepValueType; -import org.onosproject.pcepio.types.TENodeAttributesTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test case for TE Node Attribute tlv. - */ -public class TENodeAttributesTlvTest { - - private final NodeFlagBitsTlv nodeFlagBitsTlv1 = new NodeFlagBitsTlv((byte) 10); - private final IPv4TERouterIdOfLocalNodeTlv iPv4TERouterIdOfLocalNodeTlv1 = new - IPv4TERouterIdOfLocalNodeTlv(0x01010101); - - private final NodeFlagBitsTlv nodeFlagBitsTlv2 = new NodeFlagBitsTlv((byte) 20); - private final IPv4TERouterIdOfLocalNodeTlv iPv4TERouterIdOfLocalNodeTlv2 = new - IPv4TERouterIdOfLocalNodeTlv(0x02020202); - - private final LinkedList llNodeAttributesSubTLV1 = new LinkedList<>(); - private final boolean a = llNodeAttributesSubTLV1.add(nodeFlagBitsTlv1); - private final boolean b = llNodeAttributesSubTLV1.add(iPv4TERouterIdOfLocalNodeTlv1); - - private final LinkedList llNodeAttributesSubTLV2 = new LinkedList<>(); - - private final boolean c = llNodeAttributesSubTLV2.add(nodeFlagBitsTlv2); - private final boolean d = llNodeAttributesSubTLV2.add(iPv4TERouterIdOfLocalNodeTlv2); - - private final TENodeAttributesTlv tlv1 = TENodeAttributesTlv.of(llNodeAttributesSubTLV1); - private final TENodeAttributesTlv sameAsTlv1 = TENodeAttributesTlv.of(llNodeAttributesSubTLV1); - private final TENodeAttributesTlv tlv2 = TENodeAttributesTlv.of(llNodeAttributesSubTLV2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TedCapabilityTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TedCapabilityTlvTest.java deleted file mode 100644 index 4e18e867..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/TedCapabilityTlvTest.java +++ /dev/null @@ -1,36 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.TedCapabilityTlv; - -import com.google.common.testing.EqualsTester; - -/** - * Test case for TED Capability tlv. - */ -public class TedCapabilityTlvTest { - - private final TedCapabilityTlv tlv1 = TedCapabilityTlv.of(1); - private final TedCapabilityTlv tlv2 = TedCapabilityTlv.of(1); - private final TedCapabilityTlv tlv3 = TedCapabilityTlv.of(2); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/UnreservedBandwidthTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/UnreservedBandwidthTlvTest.java deleted file mode 100644 index e4cb9b15..00000000 --- a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/UnreservedBandwidthTlvTest.java +++ /dev/null @@ -1,37 +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.pcepio; - -import org.junit.Test; -import org.onosproject.pcepio.types.UnreservedBandwidthTlv; -import com.google.common.testing.EqualsTester; - -/** - * Unit Test case for Unreserved Bandwidth Tlv. - */ -public class UnreservedBandwidthTlvTest { - - // Objects of unreserved bandwidth tlv - private final UnreservedBandwidthTlv tlv1 = UnreservedBandwidthTlv.of(100); - private final UnreservedBandwidthTlv tlv2 = UnreservedBandwidthTlv.of(100); - private final UnreservedBandwidthTlv tlv3 = UnreservedBandwidthTlv.of(200); - - @Test - public void basics() { - new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); - } - -} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java new file mode 100644 index 00000000..33c00ddf --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepCloseMsgTest.java @@ -0,0 +1,56 @@ +/* + * 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.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +public class PcepCloseMsgTest { + + /** + * Common header, reason to close. + */ + @Test + public void closeMessageTest1() throws PcepParseException { + + byte[] closeMsg = new byte[] {0x20, 0x07, 0x00, 0x0C, 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02 }; + + byte[] testCloseMsg = {0 }; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(closeMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message; + + message = reader.readFrom(buffer); + assertThat(message, instanceOf(PcepCloseMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testCloseMsg = buf.array(); + + int readLen = buf.writerIndex(); + testCloseMsg = new byte[readLen]; + buf.readBytes(testCloseMsg, 0, readLen); + assertThat(testCloseMsg, is(closeMsg)); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java new file mode 100644 index 00000000..234cea67 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java @@ -0,0 +1,735 @@ +/* + * 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.pcepio.protocol; + + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +/** + * Test cases for PCEP ERROR Message. + */ +public class PcepErrorMsgTest { + + /** + * This test case checks for + * PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, + * PCECC-CAPABILITY-TLV, TED Capability TLV) + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest1() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x28, // OPEN object header + 0x20, 0x05, 0x1E, 0x01, // OPEN object + 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY + 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x03, 0x00, (byte) 0x84, 0x00, 0x04, // TED Capability TLV + 0x00, 0x00, 0x00, 0x00}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, + * PCECC-CAPABILITY-TLV, TED Capability TLV) + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest2() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x28, // OPEN object header + 0x20, 0x05, 0x1E, 0x01, // OPEN object + 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY + 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x03, 0x00, (byte) 0x84, 0x00, 0x04, // TED Capability TLV + 0x00, 0x00, 0x00, 0x00}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, + * PCECC-CAPABILITY-TLV) + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest3() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x34, // common header + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x20, // OPEN object header + 0x20, 0x05, 0x1E, 0x01, // OPEN object + 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY + 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x03}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV) + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest4() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2c, // common header + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x18, // OPEN object header + 0x20, 0x05, 0x1E, 0x01, // OPEN object + 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY + 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x00}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object (STATEFUL-PCE-CAPABILITY) + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest5() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x10, // OPEN object header + 0x20, 0x05, 0x1E, 0x01, // OPEN object + 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY + 0x00, 0x00, 0x00, 0x05}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, PCEP-ERROR Object, OPEN Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest6() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x1C, // common header + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x03, 0x01, 0x10, 0x00, 0x08, // OPEN object header + 0x20, 0x05, 0x1E, 0x01 // OPEN object + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, OPEN Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest7() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x01, 0x01, 0x10, 0x00, 0x08, // OPEN object header + 0x20, 0x05, 0x1E, 0x01 // OPEN object + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, RP Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest8() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x20, // common header + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x03}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest9() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header + 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest10() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x14, // common header + 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * TE Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest11() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header + 0x65, 0x13, 0x00, 0x0C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * RP Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest12() throws PcepParseException { + + //RP Object, PCEP-ERROR Object + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x18, // common header + 0x02, 0x10, 0x00, 0x0C, // RP Object Header + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * RP Object, RP Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest13() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header + 0x02, 0x10, 0x00, 0x0C, // RP Object Header + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * TE Object, TE Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest14() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x24, // common header + 0x65, 0x10, 0x00, 0x0C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x65, 0x10, 0x00, 0x0C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID + 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, TE Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest15() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x20, // common header + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x01, 0x65, 0x10, 0x00, 0x0C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x03}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest16() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header + 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x03}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, TE Object, TE Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest17() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x2C, // common header + 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01, 0x65, 0x10, 0x00, 0x0C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x65, 0x10, 0x00, 0x0C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID + 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x03}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest18() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header + 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x06}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, PCEP-ERROR Object, TE Object, TE Object, PCEP-ERROR Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest19() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x3C, // common header + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x01, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x03, 0x65, 0x10, 0x00, 0x0C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x65, 0x10, 0x00, 0x0C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x11, // TE-ID + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x06}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } + + /** + * This test case checks for + * PCEP-ERROR Object, RP Object, RP Object, PCEP-ERROR Object, PCEP-ERROR Object, + * TE Object, PCEP-ERROR Object + * in PcepErrorMsg message. + */ + @Test + public void errorMessageTest20() throws PcepParseException { + + byte[] errorMsg = new byte[]{0x20, 0x06, 0x00, 0x48, // common header + 0x0D, 0x10, 0x00, 0x08, // PCEP-ERROR Object Header + 0x00, 0x00, 0x01, 0x01, 0x02, 0x10, 0x00, 0x0C, // RP Object Header + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x02, 0x10, 0x00, 0x0C, // RP Object Header + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x04, 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x06, 0x65, 0x10, 0x00, 0x0C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x0D, 0x10, 0x00, 0x08, // PCERR Object Header + 0x00, 0x00, 0x01, 0x06}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(errorMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testErrorMsg = {0}; + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + assertThat(message, instanceOf(PcepErrorMsg.class)); + + message.writeTo(buf); + int iReadLen = buf.writerIndex(); + testErrorMsg = new byte[iReadLen]; + buf.readBytes(testErrorMsg, 0, iReadLen); + + assertThat(testErrorMsg, is(errorMsg)); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java new file mode 100644 index 00000000..9341f326 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgExtTest.java @@ -0,0 +1,1683 @@ +/* + * 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.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +public class PcepInitiateMsgExtTest { + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), + * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST objects in PcInitiate message. + */ + @Test + public void initiateMessageTest1() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, + * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA4, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, //Metric object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, + * StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest2() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, + * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA8, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x48, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv + 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, + * ERO, LSPA, BANDWIDTH objects in PcInitiate message. + */ + @Test + public void initiateMessageTest3() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, + * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv + //0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), + * END-POINTS, ERO, LSPA objects in PcInitiate message. + */ + @Test + public void initiateMessageTest4() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, + * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv + // 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest5() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, + * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, + * BANDWIDTH OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest6() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, + * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x8c, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspDbVerTlv, StatefulLspErrorCodeTlv), END-POINTS, ERO, + * LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest7() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv, + * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x98, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest8() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv), + * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x90, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest9() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv), + * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest10() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), + * END-POINTS, ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA OBJECT + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest11() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv), + * END-POINTS, ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7C, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest12() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), + * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x78, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspDbVerTlv), END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest13() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv), + * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x84, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), + * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest14() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), + * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x7c, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), + * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest15() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), + * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x70, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), + * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest16() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), + * END-POINTS, ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest17() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, + * BANDWIDTH OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest18() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x68, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, + * BANDWIDTH, METRIC OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest19() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x74, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, + * BANDWIDTH, METRIC OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest20() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, + * BANDWIDTH OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest21() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, + * LSPA OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest22() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), + * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest23() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), + * END-POINTS, ERO, LSPA BANDWIDTH OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest25() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA BANDWIDTH OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, + * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest26() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, + * ERO, LSPA, BANDWIDTH, METRIC OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x6C, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, + * BANDWIDTH, METRIC OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest27() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, + * LSPA, BANDWIDTH OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest28() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), + * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest29() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x4C, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), + * END-POINTS, ERO, LSPA OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest30() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5C, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest31() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, + * ERO, LSPA, BANDWIDTH, METRIC OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest32() throws PcepParseException { + + /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, + * ERO, LSPA, BANDWIDTH, METRIC OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01}; //Metric object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, + * ERO, LSPA, BANDWIDTH OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest33() throws PcepParseException { + + /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, + * ERO, LSPA, BANDWIDTH OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, + * ERO, LSPA OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest34() throws PcepParseException { + + /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, + * ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, + * ERO, LSPA OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest35() throws PcepParseException { + + /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, + * ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x60, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, + * ERO, LSPA OBJECT objects in PcInitiate message. + */ + @Test + public void initiateMessageTest36() throws PcepParseException { + + /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS, + * ERO, LSPA OBJECT. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x0C, 0x01, //ERO object + 0x01, 0x01, 0x00, 0x00, 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } +} + diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java new file mode 100644 index 00000000..0f8bb7ba --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepInitiateMsgTest.java @@ -0,0 +1,1331 @@ +/* + * 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.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +public class PcepInitiateMsgTest { + + /** + * This test case checks for srp, lsp, end-point, ERO objects in PcInitiate message. + */ + @Test + public void initiateMessageTest1() throws PcepParseException { + + /* srp, lsp, end-point, ERO. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, 0x54, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x00, 0x08, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for srp and lsp objects in PcInitiate message. + */ + @Test + public void initiateMessageTest2() throws PcepParseException { + /* srp, lsp. + */ + byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x34, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x20, 0x10, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + 0x01, 0x01, 0x01, 0x01, 0x00, 0x43, (byte) 0x83, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33}; //SymbolicPathTlv + + byte[] testInitiateDeletionMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateDeletionMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testInitiateDeletionMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateDeletionMsg = new byte[iReadLen]; + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); + + assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO objects + * in PcInitiate message. + */ + @Test + public void initiateMessageTest3() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv), END-POINT, ERO objects in PcInitiate message. + */ + @Test + public void initiateMessageTest4() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv), END-POINT, ERO. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), + * END-POINT, ERO objects in PcInitiate message. + */ + @Test + public void initiateMessageTest5() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), + * END-POINT, ERO. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5c, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), + * END-POINT, ERO objects in PcInitiate message. + */ + @Test + public void initiateMessageTest6() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), + * END-POINT, ERO. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x5c, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), + * END-POINT, ERO objects in PcInitiate message. + */ + @Test + public void initiateMessageTest7() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), + * END-POINT, ERO. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * END-POINT, ERO objects in PcInitiate message. + */ + @Test + public void initiateMessageTest8() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * END-POINT, ERO. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x4c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * END-POINT, ERO objects in PcInitiate message. + */ + @Test + public void initiateMessageTest9() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * END-POINT, ERO. + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x3c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, StatefulRsvpErrorSpecTlv) + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest10() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, StatefulRsvpErrorSpecTlv). + */ + byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x44, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, + (byte) 0xb6, 0x02, 0x4e, 0x20, 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08 //StatefulLspErrorCodeTlv + }; + + byte[] testInitiateDeletionMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateDeletionMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateDeletionMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateDeletionMsg = new byte[iReadLen]; + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); + + assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv) objects in PcInitiate message. + */ + @Test + public void initiateMessageTest11() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + StatefulLspErrorCodeTlv).*/ + byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x44, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08}; //StatefulLspErrorCodeTlv + + byte[] testInitiateDeletionMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateDeletionMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateDeletionMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateDeletionMsg = new byte[iReadLen]; + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); + + assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv) + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest12() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv). + */ + byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x3c, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00 //SymbolicPathNameTlv + }; + + byte[] testInitiateDeletionMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateDeletionMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateDeletionMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateDeletionMsg = new byte[iReadLen]; + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); + + assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv) + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest13() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv). + */ + byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x3c, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00}; //SymbolicPathNameTlv + + byte[] testInitiateDeletionMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateDeletionMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateDeletionMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateDeletionMsg = new byte[iReadLen]; + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); + + assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv) + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest14() throws PcepParseException { + + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv). + */ + byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x34, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20}; + + byte[] testInitiateDeletionMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateDeletionMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateDeletionMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateDeletionMsg = new byte[iReadLen]; + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); + + assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv) + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest15() throws PcepParseException { + + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv). + */ + byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x2c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20}; + + byte[] testInitiateDeletionMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateDeletionMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateDeletionMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateDeletionMsg = new byte[iReadLen]; + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); + + assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); + } + + /** + * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest16() throws PcepParseException { + + //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x50, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest17() throws PcepParseException { + + //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x58, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest18() throws PcepParseException { + //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x64, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for srp,lsp(all tlvs),end-point,ero,lspa,bandwidth,metric-list + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest19() throws PcepParseException { + //srp,lsp(all tlvs),end-point,ero,lspa,bandwidth,metric-list + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x74, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x04, //ERO object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for srp,lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, srp, + * lsp(SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv) objects in PcInitiate message. + */ + @Test + public void initiateMessageTest20() throws PcepParseException { + /* srp,lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, srp, + * lsp(SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv). + */ + byte[] initiateDeletionMsg = new byte[]{0x20, 0x0C, 0x00, 0x64, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20}; + + byte[] testInitiateDeletionMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateDeletionMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateDeletionMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateDeletionMsg = new byte[iReadLen]; + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen); + + assertThat(testInitiateDeletionMsg, is(initiateDeletionMsg)); + } + + /** + * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest21() throws PcepParseException { + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, + * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0x94, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest22() throws PcepParseException { + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, + * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xA8, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest23() throws PcepParseException { + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, + * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth + */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xB0, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest24() throws PcepParseException { + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero, + * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth*/ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xBC, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth, + * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest25() throws PcepParseException { + + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth, + * srp,lsp(StatefulIPv4LspIdentidiersTlv), + * end-point,ero,lspa,bandwidth,metric-list */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xC4, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,metric-list, + * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest26() throws PcepParseException { + + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,metric-list, + * srp,lsp(StatefulIPv4LspIdentidiersTlv), + * end-point,ero,lspa,bandwidth,metric-list */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xD0, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } + + /** + * This test case checks for srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list, + * srp,lsp(StatefulIPv4LspIdentidiersTlv), end-point,ero,lspa,bandwidth,metric-list + * objects in PcInitiate message. + */ + @Test + public void initiateMessageTest27() throws PcepParseException { + + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list, + * srp,lsp(StatefulIPv4LspIdentidiersTlv), + * end-point,ero,lspa,bandwidth,metric-list */ + byte[] initiateCreationMsg = new byte[]{0x20, 0x0C, 0x00, (byte) 0xE4, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00, + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object + + byte[] testInitiateCreationMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(initiateCreationMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepInitiateMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testInitiateCreationMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testInitiateCreationMsg = new byte[iReadLen]; + buf.readBytes(testInitiateCreationMsg, 0, iReadLen); + + assertThat(testInitiateCreationMsg, is(initiateCreationMsg)); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java new file mode 100644 index 00000000..56cf06b4 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepKeepaliveMsgTest.java @@ -0,0 +1,59 @@ +/* + * 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.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Assert; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +public class PcepKeepaliveMsgTest { + + /** + * Common header for keep alive message. + */ + @Test + public void keepaliveMessageTest1() throws PcepParseException { + + byte[] keepaliveMsg = new byte[] {0x20, 0x02, 0x00, 0x04 }; + + byte[] testKeepaliveMsg = {0 }; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(keepaliveMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + assertThat(message, instanceOf(PcepKeepaliveMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + + message.writeTo(buf); + + testKeepaliveMsg = buf.array(); + + int iReadLen = buf.writerIndex(); + testKeepaliveMsg = new byte[iReadLen]; + buf.readBytes(testKeepaliveMsg, 0, iReadLen); + + Assert.assertThat(testKeepaliveMsg, is(keepaliveMsg)); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java new file mode 100644 index 00000000..e1947bd7 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java @@ -0,0 +1,402 @@ +/* + * 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.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; + +public class PcepLabelUpdateMsgTest { + + /** + * This test case checks for + * SRP, LSP, LABEL Object. + * in PcepLabelUpdate message. + */ + @Test + public void labelUpdateMessageTest1() throws PcepParseException { + + byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x24, // common header + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, + 0x20, 0x10, 0x00, 0x08, // LSP Object Header + 0x00, 0x01, 0x00, 0x00, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(labelUpdate); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testLabelUpdateMsg = {0}; + assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); + + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testLabelUpdateMsg = new byte[readLen]; + buf.readBytes(testLabelUpdateMsg, 0, readLen); + + assertThat(testLabelUpdateMsg, is(labelUpdate)); + } + + /** + * This test case checks for + * SRP, LSP, LABEL Object, LABEL Object. + * in PcepLabelUpdate message. + */ + @Test + public void labelUpdateMessageTest2() throws PcepParseException { + + byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x30, // common header + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, + 0x20, 0x10, 0x00, 0x08, // LSP Object Header + 0x00, 0x01, 0x00, 0x00, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x77}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(labelUpdate); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testLabelUpdateMsg = {0}; + assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testLabelUpdateMsg = new byte[readLen]; + buf.readBytes(testLabelUpdateMsg, 0, readLen); + + assertThat(testLabelUpdateMsg, is(labelUpdate)); + } + + /** + * This test case checks for + * SRP, LABEL, FEC Object. + * in PcepLabelUpdate message. + */ + @Test + public void labelUpdateMessageTest3() throws PcepParseException { + + byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x24, // common header + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, + 0x24, 0x10, 0x00, 0x08, // FEC Object Header + 0x0A, 0x0A, 0x0B, 0x0B}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(labelUpdate); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testLabelUpdateMsg = {0}; + assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testLabelUpdateMsg = new byte[readLen]; + buf.readBytes(testLabelUpdateMsg, 0, readLen); + + assertThat(testLabelUpdateMsg, is(labelUpdate)); + } + + /** + * This test case checks for + * SRP, LSP, LABEL, LABEL, SRP, LSP, LABEL + * in PcepLabelUpdate message. + */ + @Test + public void labelUpdateMessageTest4() throws PcepParseException { + + byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, + 0x20, 0x10, 0x00, 0x08, // LSP Object Header + 0x00, 0x01, 0x00, 0x00, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x77, + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x11, + 0x20, 0x10, 0x00, 0x08, // LSP Object Header + 0x00, 0x02, 0x00, 0x00, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x44}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(labelUpdate); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testLabelUpdateMsg = {0}; + assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testLabelUpdateMsg = new byte[readLen]; + buf.readBytes(testLabelUpdateMsg, 0, readLen); + + assertThat(testLabelUpdateMsg, is(labelUpdate)); + } + + /** + * This test case checks for + * SRP, LABEL, FEC, SRP, LABEL, FEC. + * in PcepLabelUpdate message. + */ + @Test + public void labelUpdateMessageTest5() throws PcepParseException { + + byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x44, // common header + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x66, + 0x24, 0x10, 0x00, 0x08, // FEC Object Header + 0x0A, 0x0A, 0x0B, 0x0B, + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x11, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, + 0x24, 0x10, 0x00, 0x08, // FEC Object Header + 0x0A, 0x0A, 0x0C, 0x0C}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(labelUpdate); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testLabelUpdateMsg = {0}; + assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testLabelUpdateMsg = new byte[readLen]; + buf.readBytes(testLabelUpdateMsg, 0, readLen); + + assertThat(testLabelUpdateMsg, is(labelUpdate)); + } + + /** + * This test case checks for + * SRP, LSP, LABEL, LABEL, SRP, LABEL, FEC. + * in PcepLabelUpdate message. + */ + @Test + public void labelUpdateMessageTest6() throws PcepParseException { + + byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, + 0x20, 0x10, 0x00, 0x08, // LSP Object Header + 0x00, 0x01, 0x00, 0x00, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x77, + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x12, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, + 0x24, 0x10, 0x00, 0x08, // FEC Object Header + 0x0A, 0x0A, 0x0D, 0x0D}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(labelUpdate); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testLabelUpdateMsg = {0}; + assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testLabelUpdateMsg = new byte[readLen]; + buf.readBytes(testLabelUpdateMsg, 0, readLen); + + assertThat(testLabelUpdateMsg, is(labelUpdate)); + } + + /** + * This test case checks for + * SRP, LABEL, FEC, SRP, LSP, LABEL, LABEL. + * in PcepLabelUpdate message. + */ + @Test + public void labelUpdateMessageTest7() throws PcepParseException { + + byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x50, // common header + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x12, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, + 0x24, 0x10, 0x00, 0x08, // FEC Object Header + 0x0A, 0x0A, 0x0D, 0x0D, + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, + 0x20, 0x10, 0x00, 0x08, // LSP Object Header + 0x00, 0x01, 0x00, 0x00, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x77}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(labelUpdate); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testLabelUpdateMsg = {0}; + assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testLabelUpdateMsg = new byte[readLen]; + buf.readBytes(testLabelUpdateMsg, 0, readLen); + + assertThat(testLabelUpdateMsg, is(labelUpdate)); + } + + /** + * This test case checks for + * SRP, LABEL, FEC, SRP, LSP, LABEL, LABEL. + * SRP, LSP, LABEL, LABEL. + * in PcepLabelUpdate message. + */ + @Test + public void labelUpdateMessageTest8() throws PcepParseException { + + byte[] labelUpdate = new byte[]{0x20, 0x0D, 0x00, 0x7C, // common header + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x12, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, + 0x24, 0x10, 0x00, 0x08, // FEC Object Header + 0x0A, 0x0A, 0x0D, 0x0D, + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, + 0x20, 0x10, 0x00, 0x08, // LSP Object Header + 0x00, 0x01, 0x00, 0x00, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x77, + 0x21, 0x10, 0x00, 0x0C, // SRP Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, + 0x20, 0x10, 0x00, 0x08, // LSP Object Header + 0x00, 0x01, 0x00, 0x00, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x66, + 0x23, 0x10, 0x00, 0x0C, // LABEL Object Header + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x77}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(labelUpdate); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testLabelUpdateMsg = {0}; + + assertThat(message, instanceOf(PcepLabelUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testLabelUpdateMsg = new byte[readLen]; + buf.readBytes(testLabelUpdateMsg, 0, readLen); + + assertThat(testLabelUpdateMsg, is(labelUpdate)); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java new file mode 100644 index 00000000..6e0a0596 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java @@ -0,0 +1,558 @@ +/* + * 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.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; +/** + * Test cases for PCEP OPEN Message. + */ +public class PcepOpenMsgTest { + + /** + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, + * PCECC-CAPABILITY-TLV in Pcep Open message. + */ + @Test + public void openMessageTest1() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x10, 0x00, 0x20, 0x20, 0x1e, 0x78, (byte) 0xbd, + 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY + 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV + 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV + }; + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with STATEFUL-PCE-CAPABILITY-TLV in Pcep Open message. + */ + @Test + public void openMessageTest2() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header + 0x01, 0x10, 0x00, 0x10, // common object header + 0x20, 0x1E, 0x78, 0x01, // OPEN object + 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f}; // STATEFUL-PCE-CAPABILITY + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with GmplsCapability tlv in Pcep Open message. + */ + @Test + public void openMessageTest3() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header + 0x01, 0x10, 0x00, 0x10, // common object header + 0x20, 0x1E, 0x78, 0x01, // OPEN object + 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}; //GMPLS-CAPABILITY-TLV + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with StatefulLspDbVer Tlv in Pcep Open message. + */ + @Test + public void openMessageTest4() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18, + 0x01, 0x10, 0x00, 0x14, 0x20, 0x1e, 0x78, 0x20, + 0x00, 0x17, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 }; //StatefulLspDbVerTlv + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with no tlv's in Pcep Open message. + */ + @Test + public void openMessageTest5() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0C, + 0x01, 0x10, 0x00, 0x08, 0x20, 0x1e, 0x78, (byte) 0xbd }; // no Tlvs in open messsage + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV + * with I bit set in Pcep Open message. + */ + @Test + public void openMessageTest6() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x11, 0x00, 0x20, //p bit not set & i bit set + 0x20, 0x1e, 0x78, (byte) 0xbd, + 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, // STATEFUL-PCE-CAPABILITY + 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV + 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV + }; + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV + * with P bit set in Pcep Open message. + */ + @Test + public void openMessageTest7() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x12, 0x00, 0x20, //p bit set & i bit not set + 0x20, 0x1e, 0x78, (byte) 0xbd, + 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY + 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV + 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV + }; + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV + * with P & I bits set in Pcep Open message. + */ + @Test + public void openMessageTest8() throws PcepParseException { + + /* OPEN OBJECT (STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV) + with p bit set & i bit set. + */ + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x13, 0x00, 0x20, //p bit set & i bit set + 0x20, 0x1e, 0x78, (byte) 0xbd, + 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY + 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV + 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV + }; + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, PCECC-CAPABILITY-TLV + * with P & I bits set and invalid session id in Pcep Open message. + */ + @Test + public void openMessageTest9() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x13, 0x00, 0x20, //p bit set & i bit set + 0x20, 0x1e, 0x78, 0x00, //invalid sessionID + 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY + 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV + 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV + }; + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV + * in Pcep Open message. + */ + @Test + public void openMessageTest10() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1C, // common header + 0x01, 0x10, 0x00, 0x18, // common object header + 0x20, 0x05, 0x1E, 0x01, // OPEN object + 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY + 0x00, 0x00, 0x00, 0x05, + 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x00}; + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, + * PCECC-CAPABILITY-TLV, TED Capability TLV in Pcep Open message. + */ + @Test + public void openMessageTest11() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x2C, // common header + 0x01, 0x10, 0x00, 0x28, // common object header + 0x20, 0x05, 0x1E, 0x01, // OPEN object + 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY + 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x03, 0x00, (byte) 0x84, 0x00, 0x04, // TED Capability TLV + 0x00, 0x00, 0x00, 0x00 }; + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV, + * PCECC-CAPABILITY-TLV in Pcep Open message. + */ + @Test + public void openMessageTest12() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, // common header + 0x01, 0x10, 0x00, 0x20, // common object header + 0x20, 0x05, 0x1E, 0x01, // OPEN object + 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY + 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x03}; + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with STATEFUL-PCE-CAPABILITY, GMPLS-CAPABILITY-TLV + * in Pcep Open message. + */ + @Test + public void openMessageTest13() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x1c, // common header + 0x01, 0x10, 0x00, 0x18, // common object header + 0x20, 0x05, 0x1E, 0x01, // OPEN object + 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY + 0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV + 0x00, 0x00, 0x00, 0x00}; + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with STATEFUL-PCE-CAPABILITY in Pcep Open message. + */ + @Test + public void openMessageTest14() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x14, // common header + 0x01, 0x10, 0x00, 0x10, // common object header + 0x20, 0x05, 0x1E, 0x01, // OPEN object + 0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY + 0x00, 0x00, 0x00, 0x05}; + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + + assertThat(testOpenMsg, is(openMsg)); + + } + + /** + * This test case checks open object with no tlv Pcep Open message. + */ + @Test + public void openMessageTest15() throws PcepParseException { + + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x0c, // common header + 0x01, 0x10, 0x00, 0x08, // common object header + 0x20, 0x05, 0x1E, 0x01 // OPEN object + }; + + byte[] testOpenMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(openMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepOpenMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testOpenMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testOpenMsg = new byte[readLen]; + buf.readBytes(testOpenMsg, 0, readLen); + assertThat(testOpenMsg, is(openMsg)); + + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java new file mode 100644 index 00000000..f9921efd --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java @@ -0,0 +1,218 @@ +/* + * 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.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +public class PcepReportMsgExtTest { + + /** + * This test case checks forSRP Object,LSP Object(symbolic path tlv),ERO Object + * SRP Object,LSP Object(symbolic path tlv,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest39() throws PcepParseException { + + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x98, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object + * SRP Object,LSP Object(symbolic path tlv),ERO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest40() throws PcepParseException { + + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x64, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object + * SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object + * in PcRpt message. + */ + @Test + public void reportMessageTest41() throws PcepParseException { + + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x8c, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object, + * Metric-list SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object,BandWidth Object,Metric-list, + * RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest42() throws PcepParseException { + + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0xE8, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv + 0x07, 0x10, 0x00, 0x14, //ERO object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java new file mode 100644 index 00000000..c9e2bc8b --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgTest.java @@ -0,0 +1,1597 @@ +/* + * 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.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +public class PcepReportMsgTest { + + /** + * This test case checks for SRP object, LSP object(Symbolic path name tlv), ERO object + * in PcRpt message. + */ + @Test + public void reportMessageTest1() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, 0x24, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x04}; //ERO Object + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv + * StatefulLspErrorCodeTlv) ERO Object, LSPA Object, Metric-list, IRO object + * in PcRpt message. + */ + @Test + public void reportMessageTest2() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x7c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object // LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, // IPv4SubObjects + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + }; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv,StatefulLspErrorCodeTlv) + * ERO Object, LSPA Object, Metric-list, IRO object + * in PcRpt message. + */ + @Test + public void reportMessageTest3() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70, + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //Ipv4SubObjects + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric Objects + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + }; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv,StatefulLspErrorCodeTlv) + * ERO Object, LSPA Object, Metric-list + * in PcRpt message. + */ + @Test + public void reportMessageTest4() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x64, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv + * StatefulLspErrorCodeTlv) ERO Object, IRO object + * in PcRpt message. + */ + @Test + public void reportMessageTest5() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x50, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object, LSP Object(StatefulIPv4LspIdentidiersTlv,SymbolicPathNameTlv + * StatefulLspErrorCodeTlv) ERO Object, LSPA Object, Metric-list. + * in PcRpt message. + */ + @Test + public void reportMessageTest6() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x04, //ERO Object + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, //Metric object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + }; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for LSP Object, ERO Object, LSPA Object, Metric-list, IRO object + * in PcRpt message. + */ + @Test + public void reportMessageTest7() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x58, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, // Metric objects + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP object, LSP object( StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv) ERO object, LSPA object, Metric object + * in PcRpt message. + */ + @Test + public void reportMessageTest8() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv, + * StatefulLspErrorCodeTlv ),ERO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest9() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x44, + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(StatefulIPv4LspIdentidiersTlv)ERO Object,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest10() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(SymbolicPathNameTlv)ERO Object,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest11() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object, ERO Object,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest12() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x60, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(StatefulLspErrorCodeTlv)ERO Object,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest13() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(StatefulRsvpErrorSpecTlv),ERO Object,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest14() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x60, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(symbolic path tlv),LSPA Object,ERO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest15() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x7C, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(symbolic path tlv),BandWidth Object,ERO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest16() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x70, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object,ERO Object,LSPA Object,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest17() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object,ERO Object,BandWidth Object,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest18() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x68, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object,ERO Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest19() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6C, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object,ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest20() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x88, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv, + * StatefulLspErrorCodeTlv ) ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest21() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xac, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) + * ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest22() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xA0, + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) + * ERO Object,BandWidth Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest23() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8c, + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) + * ERO Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest24() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x84, + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) + * ERO Object,LSPA Object,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest25() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8c, + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) + * ERO Object,LSPA Object + * in PcRpt message. + */ + @Test + public void reportMessageTest26() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x58, + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv) + * ERO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest27() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x44, + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for LSP Object(Symbolic path tlv, StatefulIPv4LspIdentidiersTlv,StatefulLspErrorCodeTlv ) + * LSPA Object,BandWidth Object,Metric-list,ERO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest28() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x6c, + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest29() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x74, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object + * SRP Object,LSP Object(symbolic path tlv),ERO Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest30() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xE4, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object + * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv) + * ERO Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest31() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, 0x00, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object + * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv) + * ERO Object,LSPA Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest32() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, (byte) 0x14, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(symbolic path tlv),ERO Object,LSPA Object + * BandWidth Object,Metric-list,RRO Object,SRP Object,LSP Object(symbolic path tlv) + * ERO Object,LSPA Object,BandWidth Object,Metric-list,RRO Object + * in PcRpt message. + */ + @Test + public void reportMessageTest33() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x01, (byte) 0x1c, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, + 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00}; + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object(symbolic path Tlv),ERO Object,LSPA Object + * BandWidth Object,Metric-list,SRP Object,LSP Object(symbolic path tlv) + * ERO Object,LSPA Object,BandWidth Object,Metric-list + * in PcRpt message. + */ + @Test + public void reportMessageTest34() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0xB4, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric Object + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x04, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } + + /** + * This test case checks for SRP Object,LSP Object)Symbolic path tlv),ERO Object,SRP Object + * LSP Object(symbolic path tlv) ERO Object,LSPA Object, BandWidth Object,Metric-list + * in PcRpt message. + */ + @Test + public void reportMessageTest35() throws PcepParseException { + + byte[] reportMsg = new byte[]{0x20, 0x0a, 0x00, (byte) 0x8C, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP Object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP Object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, //ERO Object + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, //LSPA Object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth Object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric Object + + byte[] testReportMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(reportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(reportMsg)); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepTEReportMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepTEReportMsgTest.java new file mode 100644 index 00000000..e401c159 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepTEReportMsgTest.java @@ -0,0 +1,1596 @@ +/* + * 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.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +public class PcepTEReportMsgTest { + + /** + * This test case checks for + * TE Object (Routing Universe TLV, Local TE Node Descriptors TLV(AutonomousSystemTlv)). + * in PcTERpt message. + */ + @Test + public void teReportMessageTest1() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x28, // common header + 0x0E, 0x10, 0x00, 0x24, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x08, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystem Tlv + 0x00, 0x00, 0x00, 0x11}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * T E Object (Routing Universe TLV, Local TE Node Descriptors TLV(AutonomousSystemTlv)) with different TE-ID. + * in PcTERpt message. + */ + @Test + public void teReportMessageTest2() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x28, // common header + 0x0E, 0x10, 0x00, 0x24, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x08, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for TE Object (Routing Universe TLV) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest3() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x1c, // common header + 0x0E, 0x10, 0x00, 0x18, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv. + * OSPFareaIDsubTlv, RouterIDSubTlv)). + * in PcTERpt message. + */ + @Test + public void teReportMessageTest4() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x44, // common header + 0x0E, 0x10, 0x00, 0x40, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest5() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x3C, // common header + 0x0E, 0x10, 0x00, 0x38, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x1C, // Local TE Node Descriptors TLV + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(OSPFareaIDsubTlv, + * RouterIDSubTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest6() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x34, // common header + 0x0E, 0x10, 0x00, 0x30, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x14, // Local TE Node Descriptors TLV + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(RouterIDSubTlv)). + * in PcTERpt message. + */ + @Test + public void teReportMessageTest7() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x2C, // common header + 0x0E, 0x10, 0x00, 0x28, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x0C, // Local TE Node Descriptors TLV + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11}; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for TE Object (Routing Universe TLV,Local TE Node Descriptors TLV) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest8() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x20, // common header + 0x0E, 0x10, 0x00, 0x1C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x00 // Local TE Node Descriptors TLV + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv. + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv. + * OSPFareaIDsubTlv, RouterIDSubTlv)). + * in PcTERpt message. + */ + @Test + public void teReportMessageTest9() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x6C, // common header + 0x0E, 0x10, 0x00, 0x68, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest10() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x64, // common header + 0x0E, 0x10, 0x00, 0x60, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x1C, //RemoteTENodeDescriptorsTLV + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(OSPFareaIDsubTlv, RouterIDSubTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest11() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x5C, // common header + 0x0E, 0x10, 0x00, 0x58, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x14, //RemoteTENodeDescriptorsTLV + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(RouterIDSubTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest12() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x54, // common header + 0x0E, 0x10, 0x00, 0x50, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x0c, //RemoteTENodeDescriptorsTLV + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest13() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, 0x48, // common header + 0x0E, 0x10, 0x00, 0x44, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x00, //RemoteTENodeDescriptorsTLV + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv + * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest14() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x8C, // common header + 0x0E, 0x10, 0x00, (byte) 0x88, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV + 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv + 0x01, 0x11, 0x00, 0x09, + 0x01, 0x21, 0x00, 0x09, + 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv + 0x01, 0x011, 0x01, 0x10 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV( + * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest15() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x80, // common header + 0x0E, 0x10, 0x00, (byte) 0x7C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x10, //TELinkDescriptorsTLV + 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv + 0x01, 0x011, 0x01, 0x10 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(IPv4NeighborAddressTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest16() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x78, // common header + 0x0E, 0x10, 0x00, (byte) 0x74, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x08, //TELinkDescriptorsTLV + 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv + 0x01, 0x011, 0x01, 0x10 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest17() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0x70, // common header + 0x0E, 0x10, 0x00, (byte) 0x6C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x00, //TELinkDescriptorsTLV + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv + * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest18() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xC0, // common header + 0x0E, 0x10, 0x00, (byte) 0xbC, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV + 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv + 0x01, 0x11, 0x00, 0x09, + 0x01, 0x21, 0x00, 0x09, + 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv + 0x01, 0x011, 0x01, 0x10, + 0x04, (byte) 0xF3, 0x00, 0x30, //TENodeAttributesTlv + 0x00, 0x0E, 0x00, 0x01, //NodeFlagBitsTlv + (byte) 0x90, 0x00, 0x00, 0x00, + 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv + 0x01, 0x011, 0x01, 0x10, + 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv + 0x08, 0x00, 0x01, 0x09, + 0x08, 0x00, 0x01, 0x09, + 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv + 0x20, 0x01, 0x22, 0x01, + 0x20, 0x01, 0x22, 0x01, + 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv + 0x00, 0x01, 0x01, 0x02 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv + * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv + * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest19() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xC0, // common header + 0x0E, 0x10, 0x00, (byte) 0xBC, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV + 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv + 0x01, 0x11, 0x00, 0x09, + 0x01, 0x21, 0x00, 0x09, + 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv + 0x01, 0x011, 0x01, 0x10, + 0x04, (byte) 0xF3, 0x00, 0x30, //TENodeAttributesTlv + 0x00, 0x0E, 0x00, 0x01, //NodeFlagBitsTlv + (byte) 0x90, 0x00, 0x00, 0x00, + 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv + 0x01, 0x011, 0x01, 0x10, + 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv + 0x08, 0x00, 0x01, 0x09, + 0x08, 0x00, 0x01, 0x09, + 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv + 0x20, 0x01, 0x22, 0x01, + 0x20, 0x01, 0x22, 0x01, + 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv + 0x00, 0x01, 0x01, 0x02 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv + * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(OpaqueNodeAttributeTlv + * NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest20() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xB8, // common header + 0x0E, 0x10, 0x00, (byte) 0xB4, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV + 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv + 0x01, 0x11, 0x00, 0x09, + 0x01, 0x21, 0x00, 0x09, + 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv + 0x01, 0x011, 0x01, 0x10, + 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv + 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv + 0x01, 0x011, 0x01, 0x10, + 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv + 0x08, 0x00, 0x01, 0x09, + 0x08, 0x00, 0x01, 0x09, + 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv + 0x20, 0x01, 0x22, 0x01, + 0x20, 0x01, 0x22, 0x01, + 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv + 0x00, 0x01, 0x01, 0x02 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv. + * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(OpaqueNodeAttributeTlv + * ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest21() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x00, (byte) 0xAC, // common header + 0x0E, 0x10, 0x00, (byte) 0xA8, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV + 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv + 0x01, 0x11, 0x00, 0x09, + 0x01, 0x21, 0x00, 0x09, + 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv + 0x01, 0x011, 0x01, 0x10, + 0x04, (byte) 0xF3, 0x00, 0x1C, //TENodeAttributesTlv + 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv + 0x01, 0x011, 0x01, 0x10, + 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv + 0x20, 0x01, 0x22, 0x01, + 0x20, 0x01, 0x22, 0x01, + 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv + 0x00, 0x01, 0x01, 0x02 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv. + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv. + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv. + * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv. + * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv). + * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv. + * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv. + * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv:, SharedRiskLinkGroupTlv. + * OpaqueLinkAttributeTlv, LinkNameTlv)). + * in PcTERpt message. + */ + @Test + public void teReportMessageTest22() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x120, // common header + 0x0E, 0x10, 0x01, (byte) 0x1C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV + 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv + 0x01, 0x11, 0x00, 0x09, + 0x01, 0x21, 0x00, 0x09, + 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv + 0x01, 0x011, 0x01, 0x10, + 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv + 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv + 0x01, 0x011, 0x01, 0x10, + 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv + 0x08, 0x00, 0x01, 0x09, + 0x08, 0x00, 0x01, 0x09, + 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv + 0x20, 0x01, 0x22, 0x01, + 0x20, 0x01, 0x22, 0x01, + 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv + 0x00, 0x01, 0x01, 0x02, + 0x07, 0x69, 0x00, 0x64, //TELinkAttributesTlv + 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv + 0x00, 0x07, 0x08, 0x00, + 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv + 0x00, 0x09, 0x08, 0x00, + 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv + 0x00, 0x09, 0x00, 0x00, + 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv + 0x00, 0x10, 0x00, 0x00, + 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv + 0x00, 0x00, (byte) 0x90, 0x00, + 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv + 0x00, (byte) 0x99, 0x09, 0x00, + 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv + 0x09, 0x00, 0x00, 0x00, + 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv + (byte) 0x80, 0x00, 0x00, 0x00, + 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv + 0x09, (byte) 0x89, 0x07, 0x00, + 0x04, 0x48, 0x00, 0x08, //SharedRiskLinkGroupTlv + 0x04, 0x47, 0x00, 0x03, + 0x04, 0x47, 0x00, 0x03, //OpaqueLinkAttributeTlv + 0x04, 0x49, 0x00, 0x04, + 0x04, 0x47, 0x00, 0x03, + 0x04, 0x4A, 0x00, 0x04, //LinkNameTlv + 0x04, 0x47, 0x00, 0x03 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv + * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv + * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv) + * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv + * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv + * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv:, SharedRiskLinkGroupTlv + * OpaqueLinkAttributeTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest23() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x118, // common header + 0x0E, 0x10, 0x01, (byte) 0x14, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV + 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv + 0x01, 0x11, 0x00, 0x09, + 0x01, 0x21, 0x00, 0x09, + 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv + 0x01, 0x011, 0x01, 0x10, + 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv + 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv + 0x01, 0x011, 0x01, 0x10, + 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv + 0x08, 0x00, 0x01, 0x09, + 0x08, 0x00, 0x01, 0x09, + 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv + 0x20, 0x01, 0x22, 0x01, + 0x20, 0x01, 0x22, 0x01, + 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv + 0x00, 0x01, 0x01, 0x02, + 0x07, 0x69, 0x00, 0x5C, //TELinkAttributesTlv + 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv + 0x00, 0x07, 0x08, 0x00, + 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv + 0x00, 0x09, 0x08, 0x00, + 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv + 0x00, 0x09, 0x00, 0x00, + 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv + 0x00, 0x10, 0x00, 0x00, + 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv + 0x00, 0x00, (byte) 0x90, 0x00, + 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv + 0x00, (byte) 0x99, 0x09, 0x00, + 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv + 0x09, 0x00, 0x00, 0x00, + 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv + (byte) 0x80, 0x00, 0x00, 0x00, + 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv + 0x09, (byte) 0x89, 0x07, 0x00, + 0x04, 0x48, 0x00, 0x08, //SharedRiskLinkGroupTlv + 0x04, 0x47, 0x00, 0x03, + 0x04, 0x47, 0x00, 0x03, //OpaqueLinkAttributeTlv + 0x04, 0x49, 0x00, 0x04, + 0x04, 0x47, 0x00, 0x03 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv + * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv + * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv) + * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv + * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv + * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv:, SharedRiskLinkGroupTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest24() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x110, // common header + 0x0E, 0x10, 0x01, (byte) 0x0C, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV + 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv + 0x01, 0x11, 0x00, 0x09, + 0x01, 0x21, 0x00, 0x09, + 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv + 0x01, 0x011, 0x01, 0x10, + 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv + 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv + 0x01, 0x011, 0x01, 0x10, + 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv + 0x08, 0x00, 0x01, 0x09, + 0x08, 0x00, 0x01, 0x09, + 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv + 0x20, 0x01, 0x22, 0x01, + 0x20, 0x01, 0x22, 0x01, + 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv + 0x00, 0x01, 0x01, 0x02, + 0x07, 0x69, 0x00, 0x54, //TELinkAttributesTlv + 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv + 0x00, 0x07, 0x08, 0x00, + 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv + 0x00, 0x09, 0x08, 0x00, + 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv + 0x00, 0x09, 0x00, 0x00, + 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv + 0x00, 0x10, 0x00, 0x00, + 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv + 0x00, 0x00, (byte) 0x90, 0x00, + 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv + 0x00, (byte) 0x99, 0x09, 0x00, + 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv + 0x09, 0x00, 0x00, 0x00, + 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv + (byte) 0x80, 0x00, 0x00, 0x00, + 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv + 0x09, (byte) 0x89, 0x07, 0x00, + 0x04, 0x48, 0x00, 0x08, //SharedRiskLinkGroupTlv + 0x04, 0x47, 0x00, 0x03, + 0x04, 0x47, 0x00, 0x03 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } + + /** + * This test case checks for + * TE Object (Routing Universe TLV,Local TE Node Descriptors TLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), RemoteTENodeDescriptorsTLV(AutonomousSystemTlv, BGPLSidentifierTlv + * OSPFareaIDsubTlv, RouterIDSubTlv), TELinkDescriptorsTLV(LinkLocalRemoteIdentifiersTlv + * IPv4InterfaceAddressTlv, IPv4NeighborAddressTlv), TENodeAttributesTlv(NodeFlagBitsTlv + * OpaqueNodeAttributeTlv, NodeNameTlv, ISISAreaIdentifierTlv, IPv4TERouterIdOfLocalNodeTlv) + * TELinkAttributesTlv(IPv4TERouterIdOfRemoteNodeTlv, IPv6TERouterIdofRemoteNodeTlv, AdministrativeGroupTlv + * MaximumLinkBandwidthTlv, MaximumReservableLinkBandwidthTlv, UnreservedBandwidthTlv, TEDefaultMetricTlv + * LinkProtectionTypeTlv, MPLSProtocolMaskTlv, IGPMetricTlv)) + * in PcTERpt message. + */ + @Test + public void teReportMessageTest25() throws PcepParseException { + + byte[] teReportMsg = new byte[]{0x20, 0x0E, 0x01, (byte) 0x104, // common header + 0x0E, 0x10, 0x01, 0x00, // TE Object Header + 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, // TE-ID + 0x00, 0x0E, 0x00, 0x08, // Routing Universe TLV + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, + 0x06, 0x65, 0x00, 0x24, // Local TE Node Descriptors TLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xEB, 0x00, 0x24, //RemoteTENodeDescriptorsTLV + 0x00, 0x64, 0x00, 0x04, //AutonomousSystemTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x11, 0x00, 0x04, //BGPLSidentifierTlv + 0x00, 0x00, 0x00, 0x11, + 0x02, 0x58, 0x00, 0x04, //OSPFareaIDsubTlv + 0x00, 0x00, 0x00, 0x11, + 0x03, (byte) 0xE8, 0x00, 0x08, //RouterIDSubTlv + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x11, + 0x04, 0x2E, 0x00, 0x1C, //TELinkDescriptorsTLV + 0x00, 0x04, 0x00, 0x08, //LinkLocalRemoteIdentifiersTlv + 0x01, 0x11, 0x00, 0x09, + 0x01, 0x21, 0x00, 0x09, + 0x00, 0x06, 0x00, 0x04, //IPv4InterfaceAddressTlv + 0x01, 0x01, 0x01, 0x01, + 0x00, 0x08, 0x00, 0x04, //IPv4NeighborAddressTlv + 0x01, 0x011, 0x01, 0x10, + 0x04, (byte) 0xF3, 0x00, 0x28, //TENodeAttributesTlv + 0x03, (byte) 0xE9, 0x00, 0x04, //OpaqueNodeAttributeTlv + 0x01, 0x011, 0x01, 0x10, + 0x03, (byte) 0xEF, 0x00, 0x08, //NodeNameTlv + 0x08, 0x00, 0x01, 0x09, + 0x08, 0x00, 0x01, 0x09, + 0x00, 0x6B, 0x00, 0x08, //ISISAreaIdentifierTlv + 0x20, 0x01, 0x22, 0x01, + 0x20, 0x01, 0x22, 0x01, + 0x00, (byte) 0x86, 0x00, 0x04, //IPv4TERouterIdOfLocalNodeTlv + 0x00, 0x01, 0x01, 0x02, + 0x07, 0x69, 0x00, 0x48, //TELinkAttributesTlv + 0x05, 0x3C, 0x00, 0x04, //IPv4TERouterIdOfRemoteNodeTlv + 0x00, 0x07, 0x08, 0x00, + 0x00, 0x03, 0x00, 0x04, //AdministrativeGroupTlv + 0x00, 0x09, 0x08, 0x00, + 0x00, 0x09, 0x00, 0x04, //MaximumLinkBandwidthTlv + 0x00, 0x09, 0x00, 0x00, + 0x00, 0x0a, 0x00, 0x04, //MaximumReservableLinkBandwidthTlv + 0x00, 0x10, 0x00, 0x00, + 0x00, 0x0b, 0x00, 0x04, //UnreservedBandwidthTlv + 0x00, 0x00, (byte) 0x90, 0x00, + 0x34, 0x58, 0x00, 0x04, //TEDefaultMetricTlv + 0x00, (byte) 0x99, 0x09, 0x00, + 0x00, 0x14, 0x00, 0x02, //LinkProtectionTypeTlv + 0x09, 0x00, 0x00, 0x00, + 0x04, 0x46, 0x00, 0x01, //MPLSProtocolMaskTlv + (byte) 0x80, 0x00, 0x00, 0x00, + 0x04, 0x47, 0x00, 0x03, //IGPMetricTlv + 0x09, (byte) 0x89, 0x07, 0x00 + }; + + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(teReportMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + byte[] testReportMsg = {0}; + + assertThat(message, instanceOf(PcepTEReportMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + + int readLen = buf.writerIndex(); + testReportMsg = new byte[readLen]; + buf.readBytes(testReportMsg, 0, readLen); + + assertThat(testReportMsg, is(teReportMsg)); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java new file mode 100644 index 00000000..40234a69 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgExtTest.java @@ -0,0 +1,1269 @@ +/* + * 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.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +/** + * Test cases for PCEP update message. + */ +public class PcepUpdateMsgExtTest { + + /** + * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object, + * Metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest1() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x8c, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object, + * LSPA, Bandwidth object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest2() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSP object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object, ERO object, LSPA, bandwidth object + * Metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest3() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,bandwidth object + * Metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest4() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,bandwidth object + * Metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest5() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object, LSPA, bandwidth object + * Metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest6() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object, + * bandwidth object Metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest7() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA + * bandwidth object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest8() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA + * bandwidth object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest9() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x18, 0x00, 0x00, 0x10, 0x03, + 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv + 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulRsvpErrorSpecTlv), ERO object,LSPA + * bandwidth object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest10() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPa object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA + * bandwidth object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest11() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA + * bandwidth object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest12() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object,LSPA + * bandwidth object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest13() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object,LSPA + * metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest14() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object, ERO object,LSPA + * metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest15() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //lspa object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object,LSPA + * metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest16() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object,LSPA + * metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest17() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object,LSPA + * metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest18() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object, + * metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest19() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object, + * Bandwidth , metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest20() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object, ERO object, + * Bandwidth , metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest21() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object, + * Bandwidth , metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest22() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulLspDbVerTlv), ERO object, + * Bandwidth , metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest23() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(SymbolicPathNameTlv), ERO object, + * Bandwidth , metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest24() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(SymbolicPathNameTlv), ERO object, + * Bandwidth , metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest25() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulIPv4LspIdentidiersTlv), ERO object, + * LSPA object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest26() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 }; + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object, ERO object, + * bandwidth object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest27() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x34, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object, LSP object(StatefulLspErrorCodeTlv), ERO object, + * metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest28() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object, + * lspa object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest29() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 }; + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object, + * bandwidth object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest30() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object(SymbolicPathNameTlv), LSP object(StatefulLspErrorCodeTlv), ERO object, + * metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest31() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case is for SRP object(symbolic path tlv), LSP object(StatefulLspDbVerTlv), ERO object, + * Metric object in PcepUpdate message. + */ + @Test + public void pcepUpdateMsgTest32() throws PcepParseException { + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } +} + diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java new file mode 100644 index 00000000..1db30641 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepUpdateMsgTest.java @@ -0,0 +1,1423 @@ +/* + * 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.pcepio.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.junit.Test; +import org.onosproject.pcepio.exceptions.PcepParseException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.core.Is.is; + +public class PcepUpdateMsgTest { + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), ERO in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest1() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x30, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv + 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x04 }; //ERO object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP(SymbolicPathNameTlv), LSP (StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO, LSPA, Metric-list in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest2() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x94, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object // lsp object + 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv + 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x24, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), + * ERO objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest3() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x38, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x04 }; //ERO object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv), ERO objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest4() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x04 }; //ERO object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv), ERO objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest5() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x04 }; //ERO object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv), ERO objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest6() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x04 }; + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv), ERO objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest7() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x04}; //ERO object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv), ERO (IPv4SubObject) objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest8() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x0c, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00 }; + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject) objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest9() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00 }; + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject), LSPA objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest10() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x6c, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 }; + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest11() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest12() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest13() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), + * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric Object objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest14() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), + * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest15() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * ERO (IPv4SubObject, IPv4SubObject),LSPA, metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest16() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * ERO (IPv4SubObject, IPv4SubObject),LSPA objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest17() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x05, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 }; + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * ERO (IPv4SubObject, IPv4SubObject),Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest18() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * ERO (IPv4SubObject, IPv4SubObject),Metric-list objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest19() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv),ERO (IPv4SubObject, IPv4SubObject),LSPA, Bandwidth, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest20() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * ERO (IPv4SubObject, IPv4SubObject), Bandwidth objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest21() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest22() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5C, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest23() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv) + * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest24() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv) + * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest25() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, + * Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest26() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, + * StatefulLspErrorCodeTlv) ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, + * Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest27() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, + * SymbolicPathNameTlv, StatefulLspErrorCodeTlv), ERO (IPv4SubObject, IPv4SubObject), + * LSPA, Bandwidth, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest28() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulIPv4LspIdentidiersTlv), + * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest29() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20, + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP, + * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest30() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (StatefulLspErrorCodeTlv), + * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest31() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP, + * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest32() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x8, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv), + * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest33() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c, + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } + + /** + * This test case checks for SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), + * ERO (IPv4SubObject, IPv4SubObject), LSPA, Bandwidth, Metric objects in PcUpd message. + */ + @Test + public void pcepUpdateMsgTest34() throws PcepParseException { + + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64, + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, + 0x01, 0x01, 0x04, 0x00, + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object + + byte[] testupdateMsg = {0}; + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + buffer.writeBytes(updateMsg); + + PcepMessageReader reader = PcepFactories.getGenericReader(); + PcepMessage message = null; + + message = reader.readFrom(buffer); + + assertThat(message, instanceOf(PcepUpdateMsg.class)); + ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); + message.writeTo(buf); + testupdateMsg = buf.array(); + + int readLen = buf.writerIndex() - 0; + testupdateMsg = new byte[readLen]; + buf.readBytes(testupdateMsg, 0, readLen); + + assertThat(testupdateMsg, is(updateMsg)); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupTlvTest.java new file mode 100644 index 00000000..41e88445 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AdministrativeGroupTlvTest.java @@ -0,0 +1,36 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the AdministrativeGroupTlv. + */ +public class AdministrativeGroupTlvTest { + private final AdministrativeGroupTlv tlv1 = AdministrativeGroupTlv.of(1); + private final AdministrativeGroupTlv sameAsTlv1 = AdministrativeGroupTlv.of(1); + private final AdministrativeGroupTlv tlv2 = AdministrativeGroupTlv.of(2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemTlvTest.java new file mode 100644 index 00000000..904a71ef --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/AutonomousSystemTlvTest.java @@ -0,0 +1,36 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the AutonomousSystemTlv. + */ +public class AutonomousSystemTlvTest { + private final AutonomousSystemTlv tlv1 = AutonomousSystemTlv.of(1); + private final AutonomousSystemTlv sameAsTlv1 = AutonomousSystemTlv.of(1); + private final AutonomousSystemTlv tlv2 = AutonomousSystemTlv.of(2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BGPLSidentifierTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BGPLSidentifierTlvTest.java new file mode 100644 index 00000000..7ac6cea4 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/BGPLSidentifierTlvTest.java @@ -0,0 +1,36 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the BGPLSidentifierTlv. + */ +public class BGPLSidentifierTlvTest { + private final BGPLSidentifierTlv tlv1 = BGPLSidentifierTlv.of(1); + private final BGPLSidentifierTlv sameAsTlv1 = BGPLSidentifierTlv.of(1); + private final BGPLSidentifierTlv tlv2 = BGPLSidentifierTlv.of(2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.java new file mode 100644 index 00000000..7972712f --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/GmplsCapabilityTlvTest.java @@ -0,0 +1,36 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the GmplsCapabilityTlv. + */ +public class GmplsCapabilityTlvTest { + private final GmplsCapabilityTlv tlv1 = GmplsCapabilityTlv.of(1); + private final GmplsCapabilityTlv sameAsTlv1 = GmplsCapabilityTlv.of(1); + private final GmplsCapabilityTlv tlv2 = GmplsCapabilityTlv.of(2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IGPMetricTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IGPMetricTlvTest.java new file mode 100644 index 00000000..061a9cea --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IGPMetricTlvTest.java @@ -0,0 +1,38 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the IGPMetricTlv. + */ +public class IGPMetricTlvTest { + private final byte[] b1 = new byte[] {0x01, 0x02}; + private final byte[] b2 = new byte[] {0x01, 0x02}; + private final IGPMetricTlv tlv1 = IGPMetricTlv.of(b1, (short) 2); + private final IGPMetricTlv sameAsTlv1 = IGPMetricTlv.of(b1, (short) 2); + private final IGPMetricTlv tlv2 = IGPMetricTlv.of(b2, (short) 2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlvTest.java new file mode 100644 index 00000000..eb3a16a8 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlvTest.java @@ -0,0 +1,37 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the IPv4InterfaceAddressTlv. + */ +public class IPv4InterfaceAddressTlvTest { + + private final IPv4InterfaceAddressTlv tlv1 = IPv4InterfaceAddressTlv.of(2); + private final IPv4InterfaceAddressTlv sameAsTlv1 = IPv4InterfaceAddressTlv.of(2); + private final IPv4InterfaceAddressTlv tlv2 = IPv4InterfaceAddressTlv.of(3); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlvTest.java new file mode 100644 index 00000000..5f10b4c1 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlvTest.java @@ -0,0 +1,37 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the IPv4NeighborAddressTlv. + */ +public class IPv4NeighborAddressTlvTest { + + private final IPv4NeighborAddressTlv tlv1 = IPv4NeighborAddressTlv.of(2); + private final IPv4NeighborAddressTlv sameAsTlv1 = IPv4NeighborAddressTlv.of(2); + private final IPv4NeighborAddressTlv tlv2 = IPv4NeighborAddressTlv.of(3); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java new file mode 100644 index 00000000..10f54015 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4SubObjectTest.java @@ -0,0 +1,37 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the IPv4SubObject. + */ +public class IPv4SubObjectTest { + + private final IPv4SubObject subObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0); + private final IPv4SubObject sameAsSubObj1 = IPv4SubObject.of(2, (byte) 16, (byte) 0); + private final IPv4SubObject subObj2 = IPv4SubObject.of(3, (byte) 16, (byte) 0); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(subObj1, sameAsSubObj1) + .addEqualityGroup(subObj2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlvTest.java new file mode 100644 index 00000000..3880ca7f --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlvTest.java @@ -0,0 +1,37 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the IPv4TERouterIdOfLocalNodeTlv. + */ +public class IPv4TERouterIdOfLocalNodeTlvTest { + + private final IPv4TERouterIdOfLocalNodeTlv tlv1 = IPv4TERouterIdOfLocalNodeTlv.of(2); + private final IPv4TERouterIdOfLocalNodeTlv sameAsTlv1 = IPv4TERouterIdOfLocalNodeTlv.of(2); + private final IPv4TERouterIdOfLocalNodeTlv tlv2 = IPv4TERouterIdOfLocalNodeTlv.of(3); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlvTest.java new file mode 100644 index 00000000..f40ede04 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlvTest.java @@ -0,0 +1,37 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the IPv4TERouterIdOfRemoteNodeTlv. + */ +public class IPv4TERouterIdOfRemoteNodeTlvTest { + + private final IPv4TERouterIdOfRemoteNodeTlv tlv1 = IPv4TERouterIdOfRemoteNodeTlv.of(2); + private final IPv4TERouterIdOfRemoteNodeTlv sameAsTlv1 = IPv4TERouterIdOfRemoteNodeTlv.of(2); + private final IPv4TERouterIdOfRemoteNodeTlv tlv2 = IPv4TERouterIdOfRemoteNodeTlv.of(3); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlvTest.java new file mode 100644 index 00000000..aa2e5d9b --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the IPv6InterfaceAddressTlv. + */ +public class IPv6InterfaceAddressTlvTest { + + private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00}; + private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; + + private final IPv6InterfaceAddressTlv tlv1 = IPv6InterfaceAddressTlv.of(b1); + private final IPv6InterfaceAddressTlv sameAsTlv1 = IPv6InterfaceAddressTlv.of(b1); + private final IPv6InterfaceAddressTlv tlv2 = IPv6InterfaceAddressTlv.of(b2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlvTest.java new file mode 100644 index 00000000..65e257b0 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the IPv6NeighborAddressTlv. + */ +public class IPv6NeighborAddressTlvTest { + + private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00}; + private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; + + private final IPv6NeighborAddressTlv tlv1 = IPv6NeighborAddressTlv.of(b1); + private final IPv6NeighborAddressTlv sameAsTlv1 = IPv6NeighborAddressTlv.of(b1); + private final IPv6NeighborAddressTlv tlv2 = IPv6NeighborAddressTlv.of(b2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.java new file mode 100644 index 00000000..f23b11d8 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6SubObjectTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the IPv6SubObject. + */ +public class IPv6SubObjectTest { + + private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00}; + private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; + + private final IPv6SubObject subObj1 = IPv6SubObject.of(b1); + private final IPv6SubObject sameAsSubObj1 = IPv6SubObject.of(b1); + private final IPv6SubObject subObj2 = IPv6SubObject.of(b2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(subObj1, sameAsSubObj1).addEqualityGroup(subObj2).testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlvTest.java new file mode 100644 index 00000000..6516ed3d --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the IPv6TERouterIdofLocalNodeTlv. + */ +public class IPv6TERouterIdofLocalNodeTlvTest { + + private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00}; + private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; + + private final IPv6TERouterIdofLocalNodeTlv tlv1 = IPv6TERouterIdofLocalNodeTlv.of(b1); + private final IPv6TERouterIdofLocalNodeTlv sameAsTlv1 = IPv6TERouterIdofLocalNodeTlv.of(b1); + private final IPv6TERouterIdofLocalNodeTlv tlv2 = IPv6TERouterIdofLocalNodeTlv.of(b2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlvTest.java new file mode 100644 index 00000000..f3828609 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the IPv6TERouterIdofRemoteNodeTlv. + */ +public class IPv6TERouterIdofRemoteNodeTlvTest { + + private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00}; + private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; + + private final IPv6TERouterIdofRemoteNodeTlv tlv1 = IPv6TERouterIdofRemoteNodeTlv.of(b1); + private final IPv6TERouterIdofRemoteNodeTlv sameAsTlv1 = IPv6TERouterIdofRemoteNodeTlv.of(b1); + private final IPv6TERouterIdofRemoteNodeTlv tlv2 = IPv6TERouterIdofRemoteNodeTlv.of(b2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlvTest.java new file mode 100644 index 00000000..17584ac1 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the ISISAreaIdentifierTlv. + */ +public class ISISAreaIdentifierTlvTest { + + private final byte[] b1 = new byte[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; + private final byte[] b2 = new byte[] {2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }; + + private final ISISAreaIdentifierTlv tlv1 = ISISAreaIdentifierTlv.of(b1, (short) 20); + private final ISISAreaIdentifierTlv sameAsTlv1 = ISISAreaIdentifierTlv.of(b1, (short) 20); + private final ISISAreaIdentifierTlv tlv2 = ISISAreaIdentifierTlv.of(b2, (short) 20); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java new file mode 100644 index 00000000..511d0a20 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LabelSubObjectTest.java @@ -0,0 +1,37 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the LabelSubObject. + */ +public class LabelSubObjectTest { + + private final LabelSubObject subObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20); + private final LabelSubObject sameAsSubObj1 = LabelSubObject.of((byte) 0, (byte) 1, 20); + private final LabelSubObject subObj2 = LabelSubObject.of((byte) 0, (byte) 1, 30); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(subObj1, sameAsSubObj1) + .addEqualityGroup(subObj2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlvTest.java new file mode 100644 index 00000000..e25bda02 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlvTest.java @@ -0,0 +1,37 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the LinkLocalRemoteIdentifiersTlv. + */ +public class LinkLocalRemoteIdentifiersTlvTest { + + private final LinkLocalRemoteIdentifiersTlv tlv1 = LinkLocalRemoteIdentifiersTlv.of(10, 20); + private final LinkLocalRemoteIdentifiersTlv sameAsTlv1 = LinkLocalRemoteIdentifiersTlv.of(10, 20); + private final LinkLocalRemoteIdentifiersTlv tlv2 = LinkLocalRemoteIdentifiersTlv.of(20, 30); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameTlvTest.java new file mode 100644 index 00000000..7d9dcb26 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkNameTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Equality test for LinkNameTlv. + */ +public class LinkNameTlvTest { + private final byte[] rawValue1 = new byte[] {0x01, 0x00}; + private final byte[] rawValue2 = new byte[] {0x02, 0x00}; + + private final LinkNameTlv tlv1 = new LinkNameTlv(rawValue1, (short) rawValue1.length); + private final LinkNameTlv sameAsTlv1 = LinkNameTlv.of(tlv1.getValue(), tlv1.getLength()); + private final LinkNameTlv tlv2 = new LinkNameTlv(rawValue2, (short) 0); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeTlvTest.java new file mode 100644 index 00000000..61928f22 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LinkProtectionTypeTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the LinkProtectionTypeTlv. + */ +public class LinkProtectionTypeTlvTest { + private final byte rawValue1 = 0x0A; + private final byte rawValue2 = 0x0B; + + private final LinkProtectionTypeTlv tlv1 = new LinkProtectionTypeTlv(rawValue1); + private final LinkProtectionTypeTlv sameAsTlv1 = new LinkProtectionTypeTlv(rawValue1); + private final LinkProtectionTypeTlv tlv2 = new LinkProtectionTypeTlv(rawValue2, (byte) 0); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlvTest.java new file mode 100644 index 00000000..e8b6abcc --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +import java.util.LinkedList; + +/** + * Test of the LocalTENodeDescriptorsTlv. + */ +public class LocalTENodeDescriptorsTlvTest { + + private final AutonomousSystemTlv baAutoSysTlvRawValue1 = new AutonomousSystemTlv(1); + private final BGPLSidentifierTlv baBgplsIdRawValue1 = new BGPLSidentifierTlv(1); + + private final AutonomousSystemTlv baAutoSysTlvRawValue2 = new AutonomousSystemTlv(2); + private final BGPLSidentifierTlv baBgplsIdRawValue2 = new BGPLSidentifierTlv(2); + + private final LinkedList llNodeDescriptorSubTLVs1 = new LinkedList(); + private final boolean a = llNodeDescriptorSubTLVs1.add(baAutoSysTlvRawValue1); + private final boolean b = llNodeDescriptorSubTLVs1.add(baBgplsIdRawValue1); + + private final LinkedList llNodeDescriptorSubTLVs2 = new LinkedList(); + private final boolean c = llNodeDescriptorSubTLVs2.add(baAutoSysTlvRawValue2); + private final boolean d = llNodeDescriptorSubTLVs2.add(baBgplsIdRawValue2); + + private final LocalTENodeDescriptorsTlv tlv1 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1); + private final LocalTENodeDescriptorsTlv sameAstlv1 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs1); + private final LocalTENodeDescriptorsTlv tlv2 = LocalTENodeDescriptorsTlv.of(llNodeDescriptorSubTLVs2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlvTest.java new file mode 100644 index 00000000..5e79e284 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the MPLSProtocolMaskTlv. + */ +public class MPLSProtocolMaskTlvTest { + private final byte rawValue1 = 0x0A; + private final byte rawValue2 = 0x0B; + + private final MPLSProtocolMaskTlv tlv1 = new MPLSProtocolMaskTlv(rawValue1); + private final MPLSProtocolMaskTlv sameAsTlv1 = new MPLSProtocolMaskTlv(rawValue1); + private final MPLSProtocolMaskTlv tlv2 = MPLSProtocolMaskTlv.of(rawValue2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlvTest.java new file mode 100644 index 00000000..4e022b82 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the MaximumLinkBandwidthTlv. + */ +public class MaximumLinkBandwidthTlvTest { + private final int rawValue1 = 0x0A; + private final int rawValue2 = 0x0B; + + private final MaximumLinkBandwidthTlv tlv1 = new MaximumLinkBandwidthTlv(rawValue1); + private final MaximumLinkBandwidthTlv sameAsTlv1 = new MaximumLinkBandwidthTlv(rawValue1); + private final MaximumLinkBandwidthTlv tlv2 = MaximumLinkBandwidthTlv.of(rawValue2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlvTest.java new file mode 100644 index 00000000..7b370359 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the MaximumReservableLinkBandwidthTlv. + */ +public class MaximumReservableLinkBandwidthTlvTest { + private final int rawValue1 = 0x0A; + private final int rawValue2 = 0x0B; + + private final MaximumReservableLinkBandwidthTlv tlv1 = new MaximumReservableLinkBandwidthTlv(rawValue1); + private final MaximumReservableLinkBandwidthTlv sameAsTlv1 = new MaximumReservableLinkBandwidthTlv(rawValue1); + private final MaximumReservableLinkBandwidthTlv tlv2 = MaximumReservableLinkBandwidthTlv.of(rawValue2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java new file mode 100644 index 00000000..39c699bc --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv4addressTlvTest.java @@ -0,0 +1,37 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Equality test for NexthopIPv4addressTlv. + */ +public class NexthopIPv4addressTlvTest { + + private final NexthopIPv4addressTlv tlv1 = new NexthopIPv4addressTlv(0x0A); + private final NexthopIPv4addressTlv sameAsTlv1 = new NexthopIPv4addressTlv(0x0A); + private final NexthopIPv4addressTlv tlv2 = NexthopIPv4addressTlv.of(0x0B); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java new file mode 100644 index 00000000..4621336e --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopIPv6addressTlvTest.java @@ -0,0 +1,41 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Equality test for NexthopIPv6addressTlv. + */ +public class NexthopIPv6addressTlvTest { + + private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, 0x00, 0x00 }; + private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, 0x00, 0x00 }; + + private final NexthopIPv6addressTlv tlv1 = NexthopIPv6addressTlv.of(b1); + private final NexthopIPv6addressTlv sameAsTlv1 = NexthopIPv6addressTlv.of(b1); + private final NexthopIPv6addressTlv tlv2 = NexthopIPv6addressTlv.of(b2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java new file mode 100644 index 00000000..906c6526 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlvTest.java @@ -0,0 +1,37 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Equality test for NexthopUnnumberedIPv4IDTlv. + */ +public class NexthopUnnumberedIPv4IDTlvTest { + + private final NexthopUnnumberedIPv4IDTlv tlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A); + private final NexthopUnnumberedIPv4IDTlv sameAsTlv1 = new NexthopUnnumberedIPv4IDTlv(0x0A, 0x0A); + private final NexthopUnnumberedIPv4IDTlv tlv2 = NexthopUnnumberedIPv4IDTlv.of(0x0B, 0x0B); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsTlvTest.java new file mode 100644 index 00000000..fb90fedb --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeFlagBitsTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the NodeFlagBitsTlv. + */ +public class NodeFlagBitsTlvTest { + private final byte rawValue1 = 0x0A; + private final byte rawValue2 = 0x0B; + + private final NodeFlagBitsTlv tlv1 = new NodeFlagBitsTlv(rawValue1); + private final NodeFlagBitsTlv sameAsTlv1 = new NodeFlagBitsTlv(rawValue1); + private final NodeFlagBitsTlv tlv2 = NodeFlagBitsTlv.of(rawValue2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameTlvTest.java new file mode 100644 index 00000000..d6d53d6f --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/NodeNameTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the NodeNameTlv. + */ +public class NodeNameTlvTest { + private final byte[] rawValue1 = new byte[] {0x01, 0x02}; + private final byte[] rawValue2 = new byte[] {0x14, 0x15}; + + private final NodeNameTlv tlv1 = new NodeNameTlv(rawValue1, (short) rawValue1.length); + private final NodeNameTlv sameAsTlv1 = NodeNameTlv.of(tlv1.getValue(), tlv1.getLength()); + private final NodeNameTlv tlv2 = new NodeNameTlv(rawValue2, (short) 0); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OSPFareaIDsubTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OSPFareaIDsubTlvTest.java new file mode 100644 index 00000000..3f741ed6 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OSPFareaIDsubTlvTest.java @@ -0,0 +1,36 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the OSPFareaIDsubTlv. + */ +public class OSPFareaIDsubTlvTest { + private final int rawValue1 = 0x0A; + + private final OSPFareaIDsubTlv tlv1 = new OSPFareaIDsubTlv(rawValue1); + private final OSPFareaIDsubTlv tlv2 = OSPFareaIDsubTlv.of(tlv1.getInt()); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlvTest.java new file mode 100644 index 00000000..f437fb57 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the OpaqueLinkAttributeTlv. + */ +public class OpaqueLinkAttributeTlvTest { + private final byte[] rawValue1 = new byte[] {0x01, 0x02}; + private final byte[] rawValue2 = new byte[] {0x14, 0x15}; + + private final OpaqueLinkAttributeTlv tlv1 = new OpaqueLinkAttributeTlv(rawValue1, (short) rawValue1.length); + private final OpaqueLinkAttributeTlv sameAsTlv1 = OpaqueLinkAttributeTlv.of(tlv1.getValue(), tlv1.getLength()); + private final OpaqueLinkAttributeTlv tlv2 = new OpaqueLinkAttributeTlv(rawValue2, (short) 0); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java new file mode 100644 index 00000000..64cda54e --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathKeySubObjectTest.java @@ -0,0 +1,37 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the PathKeySubObject. + */ +public class PathKeySubObjectTest { + + private final PathKeySubObject tlv1 = new PathKeySubObject((short) 0x0A, 0x0A); + private final PathKeySubObject sameAsTlv1 = PathKeySubObject.of((short) 0x0A, 0x0A); + private final PathKeySubObject tlv2 = new PathKeySubObject((short) 0x0B, 0x0B); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java new file mode 100644 index 00000000..d82c943e --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PathSetupTypeTlvTest.java @@ -0,0 +1,34 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the PathSetupTypeTlv. + */ +public class PathSetupTypeTlvTest { + + private final PathSetupTypeTlv tlv1 = PathSetupTypeTlv.of(0x0A); + private final PathSetupTypeTlv sameAsTlv1 = PathSetupTypeTlv.of(0x0A); + private final PathSetupTypeTlv tlv2 = PathSetupTypeTlv.of(0x0B); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.java new file mode 100644 index 00000000..30892b18 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PceccCapabilityTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test of the PceccCapabilityTlv. + */ +public class PceccCapabilityTlvTest { + private final int rawValue1 = 0x0A; + private final int rawValue2 = 0x0B; + + private final PceccCapabilityTlv tlv1 = new PceccCapabilityTlv(rawValue1); + private final PceccCapabilityTlv sameAsTlv1 = new PceccCapabilityTlv(rawValue1); + private final PceccCapabilityTlv tlv2 = PceccCapabilityTlv.of(rawValue2); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, sameAsTlv1) + .addEqualityGroup(tlv2) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.java new file mode 100644 index 00000000..3ebc9a1e --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4AdjacencyTest.java @@ -0,0 +1,36 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Equality test for PcepNaiIpv4Adjacency. + */ +public class PcepNaiIpv4AdjacencyTest { + + private final PcepNaiIpv4Adjacency obj1 = PcepNaiIpv4Adjacency.of(2, 16); + private final PcepNaiIpv4Adjacency sameAsObj1 = PcepNaiIpv4Adjacency.of(2, 16); + private final PcepNaiIpv4Adjacency obj2 = PcepNaiIpv4Adjacency.of(3, 16); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(obj1, sameAsObj1).addEqualityGroup(obj2).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java new file mode 100644 index 00000000..5ea5edd6 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeIdTest.java @@ -0,0 +1,34 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +public class PcepNaiIpv4NodeIdTest { + + private final PcepNaiIpv4NodeId tlv1 = PcepNaiIpv4NodeId.of(1); + private final PcepNaiIpv4NodeId tlv2 = PcepNaiIpv4NodeId.of(1); + private final PcepNaiIpv4NodeId tlv3 = PcepNaiIpv4NodeId.of(3); + + @Test + public void basics() { + new EqualsTester() + .addEqualityGroup(tlv1, tlv2) + .addEqualityGroup(tlv3) + .testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java new file mode 100644 index 00000000..52c40f94 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6AdjacencyTest.java @@ -0,0 +1,37 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +public class PcepNaiIpv6AdjacencyTest { + private final byte[] localIpv6Addr1 = {(byte) 0x01010101 }; + private final byte[] remoteIpv6Addr1 = {(byte) 0x02020202 }; + private final byte[] localIpv6Addr2 = {(byte) 0x01010101 }; + private final byte[] remoteIpv6Addr2 = {(byte) 0x02020202 }; + private final byte[] localIpv6Addr3 = {(byte) 0x05050505 }; + private final byte[] remoteIpv6Addr3 = {(byte) 0x06060606 }; + + private final PcepNaiIpv6Adjacency tlv1 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1); + private final PcepNaiIpv6Adjacency tlv2 = PcepNaiIpv6Adjacency.of(localIpv6Addr1, remoteIpv6Addr1); + private final PcepNaiIpv6Adjacency tlv3 = PcepNaiIpv6Adjacency.of(localIpv6Addr3, remoteIpv6Addr3); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.java new file mode 100644 index 00000000..29771a0f --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeIdTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Equality test for PcepNaiIpv6NodeId. + */ +public class PcepNaiIpv6NodeIdTest { + + private final byte[] b1 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x29, 0x00, 0x02, + 0x00, 0x00 }; + private final byte[] b2 = new byte[] {(byte) 0xFE, (byte) 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, + (byte) 0xB3, (byte) 0xFF, (byte) 0xFE, 0x1E, (byte) 0x83, 0x30, 0x00, 0x02, + 0x00, 0x00 }; + + private final PcepNaiIpv6NodeId tlv1 = PcepNaiIpv6NodeId.of(b1); + private final PcepNaiIpv6NodeId sameAsTlv1 = PcepNaiIpv6NodeId.of(b1); + private final PcepNaiIpv6NodeId tlv2 = PcepNaiIpv6NodeId.of(b2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.java new file mode 100644 index 00000000..60ae22fd --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4Test.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +public class PcepNaiUnnumberedAdjacencyIpv4Test { + + private final int localNodeId1 = 1; + private final int localInterfaceId1 = 1; + private final int remoteNodeId1 = 1; + private final int remoteInterfaceId1 = 1; + private final PcepNaiUnnumberedAdjacencyIpv4 tlv1 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId1, + localInterfaceId1, remoteNodeId1, remoteInterfaceId1); + + private final int localNodeId2 = 1; + private final int localInterfaceId2 = 1; + private final int remoteNodeId2 = 1; + private final int remoteInterfaceId2 = 1; + private final PcepNaiUnnumberedAdjacencyIpv4 tlv2 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId2, + localInterfaceId2, remoteNodeId2, remoteInterfaceId2); + + private final int localNodeId3 = 2; + private final int localInterfaceId3 = 2; + private final int remoteNodeId3 = 2; + private final int remoteInterfaceId3 = 2; + + private final PcepNaiUnnumberedAdjacencyIpv4 tlv3 = PcepNaiUnnumberedAdjacencyIpv4.of(localNodeId3, + localInterfaceId3, remoteNodeId3, remoteInterfaceId3); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlvTest.java new file mode 100644 index 00000000..112e4a4e --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlvTest.java @@ -0,0 +1,52 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +import java.util.LinkedList; + +/** + * Test case for Remote TE Node Descriptors tlv. + */ +public class RemoteTENodeDescriptorsTlvTest { + + private final AutonomousSystemTlv autonomousSystemTlv1 = new AutonomousSystemTlv(10); + private final BGPLSidentifierTlv bGPLSidentifierTlv1 = new BGPLSidentifierTlv(20); + + private final AutonomousSystemTlv autonomousSystemTlv2 = new AutonomousSystemTlv(20); + private final BGPLSidentifierTlv bGPLSidentifierTlv2 = new BGPLSidentifierTlv(30); + + private final LinkedList llRemoteTENodeDescriptorSubTLV1 = new LinkedList<>(); + private final boolean a = llRemoteTENodeDescriptorSubTLV1.add(autonomousSystemTlv1); + private final boolean b = llRemoteTENodeDescriptorSubTLV1.add(bGPLSidentifierTlv1); + + private final LinkedList llRemoteTENodeDescriptorSubTLV2 = new LinkedList<>(); + private final boolean c = llRemoteTENodeDescriptorSubTLV2.add(autonomousSystemTlv2); + private final boolean d = llRemoteTENodeDescriptorSubTLV2.add(bGPLSidentifierTlv2); + + private final RemoteTENodeDescriptorsTlv tlv1 = RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1); + private final RemoteTENodeDescriptorsTlv sameAsTlv1 = + RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV1); + private final RemoteTENodeDescriptorsTlv tlv2 = RemoteTENodeDescriptorsTlv.of(llRemoteTENodeDescriptorSubTLV2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RouterIDSubTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RouterIDSubTlvTest.java new file mode 100644 index 00000000..2f9e18a9 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RouterIDSubTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test case for Router ID Sub tlv. + */ +public class RouterIDSubTlvTest { + + private final byte[] value1 = {1, 2 }; + private final Short length1 = 2; + private final RouterIDSubTlv tlv1 = RouterIDSubTlv.of(value1, length1); + + private final Short length2 = 2; + private final RouterIDSubTlv tlv2 = RouterIDSubTlv.of(value1, length2); + + private final byte[] value3 = {1, 2, 3 }; + private final Short length3 = 3; + private final RouterIDSubTlv tlv3 = RouterIDSubTlv.of(value3, length3); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.java new file mode 100644 index 00000000..18aa2851 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/RoutingUniverseTlvTest.java @@ -0,0 +1,35 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Equality test for RoutingUniverseTlv. + */ +public class RoutingUniverseTlvTest { + + private final RoutingUniverseTlv tlv1 = RoutingUniverseTlv.of(2); + private final RoutingUniverseTlv tlv2 = RoutingUniverseTlv.of(2); + private final RoutingUniverseTlv tlv3 = RoutingUniverseTlv.of(3); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlvTest.java new file mode 100644 index 00000000..7c8ec570 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlvTest.java @@ -0,0 +1,41 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test case for Shared Risk Link Group tlv. + */ +public class SharedRiskLinkGroupTlvTest { + + private final int[] raw = {1 }; + private final Short hLength = 2; + private final SharedRiskLinkGroupTlv tlv1 = SharedRiskLinkGroupTlv.of(raw, hLength); + + private final SharedRiskLinkGroupTlv sameAsTlv1 = SharedRiskLinkGroupTlv.of(raw, hLength); + + private final int[] raw2 = {2 }; + private final Short hLength2 = 3; + private final SharedRiskLinkGroupTlv tlv2 = SharedRiskLinkGroupTlv.of(raw2, hLength2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java new file mode 100644 index 00000000..d91569b9 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SrEroSubObjectTest.java @@ -0,0 +1,59 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; +import org.onosproject.pcepio.protocol.PcepNai; + +public class SrEroSubObjectTest { + + private final boolean bFFlag = false; + private final boolean bSFlag = false; + private final boolean bCFlag = false; + private final boolean bMFlag = false; + private final byte st = 1; + private final int sID = 1; + private final PcepNai nai = null; + + private final SrEroSubObject tlv1 = SrEroSubObject.of(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai); + + private final boolean bFFlag1 = false; + private final boolean bSFlag1 = false; + private final boolean bCFlag1 = false; + private final boolean bMFlag1 = false; + private final byte st1 = 1; + private final int sID1 = 1; + private final PcepNai nai1 = null; + + private final SrEroSubObject tlv2 = SrEroSubObject.of(st1, bFFlag1, bSFlag1, bCFlag1, bMFlag1, sID1, nai1); + + private final boolean bFFlag2 = true; + private final boolean bSFlag2 = true; + private final boolean bCFlag2 = true; + private final boolean bMFlag2 = true; + private final byte st2 = 2; + private final int sID2 = 2; + private final PcepNai nai2 = null; + + private final SrEroSubObject tlv3 = SrEroSubObject.of(st2, bFFlag2, bSFlag2, bCFlag2, bMFlag2, sID2, nai2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.java new file mode 100644 index 00000000..d1798fa3 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +public class StatefulIPv4LspIdentidiersTlvTest { + + private final int ipv4IngressAddress = 1; + private final short lspId = 1; + private final short tunnelId = 1; + private final int extendedTunnelId = 1; + private final int ipv4EgressAddress = 1; + + private final StatefulIPv4LspIdentidiersTlv tlv1 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress, lspId, + tunnelId, extendedTunnelId, ipv4EgressAddress); + + private final int ipv4IngressAddress1 = 1; + private final short lspId1 = 1; + private final short tunnelId1 = 1; + private final int extendedTunnelId1 = 1; + private final int ipv4EgressAddress1 = 1; + + private final StatefulIPv4LspIdentidiersTlv tlv2 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress1, lspId1, + tunnelId1, extendedTunnelId1, ipv4EgressAddress1); + + private final int ipv4IngressAddress2 = 2; + private final short lspId2 = 2; + private final short tunnelId2 = 2; + private final int extendedTunnelId2 = 2; + private final int ipv4EgressAddress2 = 2; + + private final StatefulIPv4LspIdentidiersTlv tlv3 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress2, lspId2, + tunnelId2, extendedTunnelId2, ipv4EgressAddress2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.java new file mode 100644 index 00000000..7076bc9e --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspDbVerTlvTest.java @@ -0,0 +1,35 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test case for Stateful Lsp Db Ver tlv. + */ +public class StatefulLspDbVerTlvTest { + + private final StatefulLspDbVerTlv tlv1 = StatefulLspDbVerTlv.of(1); + private final StatefulLspDbVerTlv tlv2 = StatefulLspDbVerTlv.of(1); + private final StatefulLspDbVerTlv tlv3 = StatefulLspDbVerTlv.of(2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.java new file mode 100644 index 00000000..039108ae --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlvTest.java @@ -0,0 +1,31 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +public class StatefulLspErrorCodeTlvTest { + + private final StatefulLspErrorCodeTlv tlv1 = StatefulLspErrorCodeTlv.of(1); + private final StatefulLspErrorCodeTlv tlv2 = StatefulLspErrorCodeTlv.of(1); + private final StatefulLspErrorCodeTlv tlv3 = StatefulLspErrorCodeTlv.of(2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java new file mode 100644 index 00000000..8637024c --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlvTest.java @@ -0,0 +1,34 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test case for Stateful Pce Capability tlv. + */ +public class StatefulPceCapabilityTlvTest { + + private final StatefulPceCapabilityTlv tlv1 = StatefulPceCapabilityTlv.of(1); + private final StatefulPceCapabilityTlv tlv2 = StatefulPceCapabilityTlv.of(1); + private final StatefulPceCapabilityTlv tlv3 = StatefulPceCapabilityTlv.of(2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.java new file mode 100644 index 00000000..8d458f4e --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/SymbolicPathNameTlvTest.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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test case for Symbolic path tlv. + */ +public class SymbolicPathNameTlvTest { + + private final byte[] value1 = {0x41 }; + private final Short length1 = 2; + private final SymbolicPathNameTlv tlv1 = SymbolicPathNameTlv.of(value1, length1); + + private final byte[] value2 = {0x41 }; + private final Short length2 = 2; + private final SymbolicPathNameTlv tlv2 = SymbolicPathNameTlv.of(value1, length2); + + private final byte[] value3 = {0x41, 0x43 }; + private final Short length3 = 3; + private final SymbolicPathNameTlv tlv3 = SymbolicPathNameTlv.of(value3, length3); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricTlvTest.java new file mode 100644 index 00000000..c46b0af1 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TEDefaultMetricTlvTest.java @@ -0,0 +1,34 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test case for TE Default Metric tlv. + */ +public class TEDefaultMetricTlvTest { + + private final TEDefaultMetricTlv tlv1 = TEDefaultMetricTlv.of(1); + private final TEDefaultMetricTlv tlv2 = TEDefaultMetricTlv.of(1); + private final TEDefaultMetricTlv tlv3 = TEDefaultMetricTlv.of(2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkAttributesTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkAttributesTlvTest.java new file mode 100644 index 00000000..8504a87c --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkAttributesTlvTest.java @@ -0,0 +1,54 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +import java.util.LinkedList; + +/** + * Test case for TE Link Attribute Tlv. + */ +public class TELinkAttributesTlvTest { + + private final AdministrativeGroupTlv administrativeGroupTlv1 = new AdministrativeGroupTlv(10); + private final MaximumReservableLinkBandwidthTlv maximumReservableLinkBandwidthTlv1 = + new MaximumReservableLinkBandwidthTlv(20); + + private final AdministrativeGroupTlv administrativeGroupTlv2 = new AdministrativeGroupTlv(20); + private final MaximumReservableLinkBandwidthTlv maximumReservableLinkBandwidthTlv2 = + new MaximumReservableLinkBandwidthTlv(30); + + private final LinkedList llLinkAttributesSubTLV1 = new LinkedList<>(); + private final boolean a = llLinkAttributesSubTLV1.add(administrativeGroupTlv1); + private final boolean b = llLinkAttributesSubTLV1.add(maximumReservableLinkBandwidthTlv1); + + private final LinkedList llLinkAttributesSubTLV2 = new LinkedList<>(); + + private final boolean c = llLinkAttributesSubTLV2.add(administrativeGroupTlv2); + private final boolean d = llLinkAttributesSubTLV2.add(maximumReservableLinkBandwidthTlv2); + + private final TELinkAttributesTlv tlv1 = TELinkAttributesTlv.of(llLinkAttributesSubTLV1); + private final TELinkAttributesTlv sameAsTlv1 = TELinkAttributesTlv.of(llLinkAttributesSubTLV1); + private final TELinkAttributesTlv tlv2 = TELinkAttributesTlv.of(llLinkAttributesSubTLV2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkDescriptorsTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkDescriptorsTlvTest.java new file mode 100644 index 00000000..4e942097 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TELinkDescriptorsTlvTest.java @@ -0,0 +1,52 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +import java.util.LinkedList; + +/** + * Test case for TE link descriptors Tlv. + */ +public class TELinkDescriptorsTlvTest { + private final LinkLocalRemoteIdentifiersTlv linkLocalRemoteIdentifiersTlv1 = new + LinkLocalRemoteIdentifiersTlv(10, 10); + private final IPv4InterfaceAddressTlv iPv4InterfaceAddressTlv1 = new IPv4InterfaceAddressTlv(0x01010101); + + private final LinkLocalRemoteIdentifiersTlv linkLocalRemoteIdentifiersTlv2 = new + LinkLocalRemoteIdentifiersTlv(20, 20); + private final IPv4InterfaceAddressTlv iPv4InterfaceAddressTlv2 = new IPv4InterfaceAddressTlv(0x02020202); + + private final LinkedList llLinkDescriptorsSubTLVs1 = new LinkedList<>(); + private final boolean a = llLinkDescriptorsSubTLVs1.add(linkLocalRemoteIdentifiersTlv1); + private final boolean b = llLinkDescriptorsSubTLVs1.add(iPv4InterfaceAddressTlv1); + + private final LinkedList llLinkDescriptorsSubTLVs2 = new LinkedList<>(); + private final boolean c = llLinkDescriptorsSubTLVs2.add(linkLocalRemoteIdentifiersTlv2); + private final boolean d = llLinkDescriptorsSubTLVs2.add(iPv4InterfaceAddressTlv2); + + private final TELinkDescriptorsTlv tlv1 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1); + private final TELinkDescriptorsTlv sameAstlv1 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs1); + private final TELinkDescriptorsTlv tlv2 = TELinkDescriptorsTlv.of(llLinkDescriptorsSubTLVs2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, sameAstlv1).addEqualityGroup(tlv2).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TENodeAttributesTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TENodeAttributesTlvTest.java new file mode 100644 index 00000000..28cf27d4 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TENodeAttributesTlvTest.java @@ -0,0 +1,54 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +import java.util.LinkedList; + +/** + * Test case for TE Node Attribute tlv. + */ +public class TENodeAttributesTlvTest { + + private final NodeFlagBitsTlv nodeFlagBitsTlv1 = new NodeFlagBitsTlv((byte) 10); + private final IPv4TERouterIdOfLocalNodeTlv iPv4TERouterIdOfLocalNodeTlv1 = new + IPv4TERouterIdOfLocalNodeTlv(0x01010101); + + private final NodeFlagBitsTlv nodeFlagBitsTlv2 = new NodeFlagBitsTlv((byte) 20); + private final IPv4TERouterIdOfLocalNodeTlv iPv4TERouterIdOfLocalNodeTlv2 = new + IPv4TERouterIdOfLocalNodeTlv(0x02020202); + + private final LinkedList llNodeAttributesSubTLV1 = new LinkedList<>(); + private final boolean a = llNodeAttributesSubTLV1.add(nodeFlagBitsTlv1); + private final boolean b = llNodeAttributesSubTLV1.add(iPv4TERouterIdOfLocalNodeTlv1); + + private final LinkedList llNodeAttributesSubTLV2 = new LinkedList<>(); + + private final boolean c = llNodeAttributesSubTLV2.add(nodeFlagBitsTlv2); + private final boolean d = llNodeAttributesSubTLV2.add(iPv4TERouterIdOfLocalNodeTlv2); + + private final TENodeAttributesTlv tlv1 = TENodeAttributesTlv.of(llNodeAttributesSubTLV1); + private final TENodeAttributesTlv sameAsTlv1 = TENodeAttributesTlv.of(llNodeAttributesSubTLV1); + private final TENodeAttributesTlv tlv2 = TENodeAttributesTlv.of(llNodeAttributesSubTLV2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, sameAsTlv1).addEqualityGroup(tlv2).testEquals(); + } + +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TedCapabilityTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TedCapabilityTlvTest.java new file mode 100644 index 00000000..18677ca3 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/TedCapabilityTlvTest.java @@ -0,0 +1,34 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Test case for TED Capability tlv. + */ +public class TedCapabilityTlvTest { + + private final TedCapabilityTlv tlv1 = TedCapabilityTlv.of(1); + private final TedCapabilityTlv tlv2 = TedCapabilityTlv.of(1); + private final TedCapabilityTlv tlv3 = TedCapabilityTlv.of(2); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } +} diff --git a/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthTlvTest.java b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthTlvTest.java new file mode 100644 index 00000000..a50fd9f4 --- /dev/null +++ b/framework/src/onos/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/UnreservedBandwidthTlvTest.java @@ -0,0 +1,36 @@ +/* + * 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.pcepio.types; + +import com.google.common.testing.EqualsTester; +import org.junit.Test; + +/** + * Unit Test case for Unreserved Bandwidth Tlv. + */ +public class UnreservedBandwidthTlvTest { + + // Objects of unreserved bandwidth tlv + private final UnreservedBandwidthTlv tlv1 = UnreservedBandwidthTlv.of(100); + private final UnreservedBandwidthTlv tlv2 = UnreservedBandwidthTlv.of(100); + private final UnreservedBandwidthTlv tlv3 = UnreservedBandwidthTlv.of(200); + + @Test + public void basics() { + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); + } + +} diff --git a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java index 4d5b6b28..c591f47d 100644 --- a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java +++ b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java @@ -50,6 +50,7 @@ import org.projectfloodlight.openflow.protocol.OFFlowRemoved; import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; import org.projectfloodlight.openflow.protocol.action.OFAction; import org.projectfloodlight.openflow.protocol.action.OFActionCircuit; +import org.projectfloodlight.openflow.protocol.action.OFActionEnqueue; import org.projectfloodlight.openflow.protocol.action.OFActionExperimenter; import org.projectfloodlight.openflow.protocol.action.OFActionGroup; import org.projectfloodlight.openflow.protocol.action.OFActionOutput; @@ -346,6 +347,10 @@ public class FlowEntryBuilder { OFActionSetQueue setQueue = (OFActionSetQueue) act; builder.setQueue(setQueue.getQueueId()); break; + case ENQUEUE: + OFActionEnqueue enqueue = (OFActionEnqueue) act; + builder.setQueue(enqueue.getQueueId(), PortNumber.portNumber(enqueue.getPort().getPortNumber())); + break; case STRIP_VLAN: case POP_VLAN: builder.popVlan(); @@ -364,7 +369,6 @@ public class FlowEntryBuilder { case SET_NW_TOS: case SET_NW_TTL: - case ENQUEUE: default: log.warn("Action type {} not yet implemented.", act.getType()); } diff --git a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer10.java b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer10.java index c7898414..6c4ee4dc 100644 --- a/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer10.java +++ b/framework/src/onos/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowModBuilderVer10.java @@ -22,6 +22,7 @@ import org.onosproject.net.flow.FlowRule; import org.onosproject.net.flow.TrafficTreatment; import org.onosproject.net.flow.instructions.Instruction; import org.onosproject.net.flow.instructions.Instructions.OutputInstruction; +import org.onosproject.net.flow.instructions.Instructions.SetQueueInstruction; import org.onosproject.net.flow.instructions.L2ModificationInstruction; import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; import org.onosproject.net.flow.instructions.L2ModificationInstruction.ModVlanIdInstruction; @@ -35,6 +36,7 @@ import org.projectfloodlight.openflow.protocol.OFFlowMod; import org.projectfloodlight.openflow.protocol.OFFlowModFlags; import org.projectfloodlight.openflow.protocol.action.OFAction; import org.projectfloodlight.openflow.protocol.action.OFActionOutput; +import org.projectfloodlight.openflow.protocol.action.OFActionEnqueue; import org.projectfloodlight.openflow.protocol.match.Match; import org.projectfloodlight.openflow.types.IPv4Address; import org.projectfloodlight.openflow.types.MacAddress; @@ -167,6 +169,16 @@ public class FlowModBuilderVer10 extends FlowModBuilder { } acts.add(action.build()); break; + case QUEUE: + SetQueueInstruction queue = (SetQueueInstruction) i; + if (queue.port() == null) { + log.warn("Required argument 'port' undefined for OFActionEnqueue"); + } + OFActionEnqueue.Builder queueBuilder = factory().actions().buildEnqueue() + .setQueueId(queue.queueId()) + .setPort(OFPort.ofInt((int) queue.port().toLong())); + acts.add(queueBuilder.build()); + break; case L0MODIFICATION: case GROUP: case TABLE: diff --git a/framework/src/onos/tools/test/scenarios/fast.xml b/framework/src/onos/tools/test/scenarios/fast.xml index 3cfe2c60..0d38c456 100644 --- a/framework/src/onos/tools/test/scenarios/fast.xml +++ b/framework/src/onos/tools/test/scenarios/fast.xml @@ -26,5 +26,5 @@ - + diff --git a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyCycle.java b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyCycle.java index 444995bf..0fc761d4 100644 --- a/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyCycle.java +++ b/framework/src/onos/utils/jdvue/src/main/java/org/onlab/jdvue/DependencyCycle.java @@ -110,7 +110,7 @@ public class DependencyCycle { @Override public int hashCode() { - return Objects.hash(cycle); + return cycle.hashCode(); } @Override diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/DisjointPathPair.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/DisjointPathPair.java index 206a34c8..dfa150e3 100644 --- a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/DisjointPathPair.java +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/DisjointPathPair.java @@ -30,8 +30,8 @@ import static com.google.common.base.MoreObjects.toStringHelper; */ public class DisjointPathPair> implements Path { - private Path primary, secondary; - boolean primaryActive = true; + private final Path primary, secondary; + private boolean primaryActive = true; /** * Creates a disjoint path pair from two paths. @@ -88,7 +88,7 @@ public class DisjointPathPair> implements Pa * @return boolean representing whether it has backup */ public boolean hasBackup() { - return secondary != null && secondary.edges() != null; + return secondary != null; } @Override @@ -103,7 +103,9 @@ public class DisjointPathPair> implements Pa @Override public int hashCode() { - return hasBackup() ? Objects.hash(primary) + Objects.hash(secondary) : + // Note: DisjointPathPair with primary and secondary swapped + // must result in same hashCode + return hasBackup() ? primary.hashCode() + secondary.hashCode() : Objects.hash(primary); } diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/DisjointPathPair.java.orig b/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/DisjointPathPair.java.orig deleted file mode 100644 index 1cf22b6a..00000000 --- a/framework/src/onos/utils/misc/src/main/java/org/onlab/graph/DisjointPathPair.java.orig +++ /dev/null @@ -1,169 +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.onlab.graph; - -import java.util.List; -import java.util.Objects; -import java.util.Set; - -import static com.google.common.collect.ImmutableSet.of; -import static com.google.common.base.MoreObjects.toStringHelper; - - -public class DisjointPathPair> implements Path { - public Path path1, path2; - boolean usingPath1 = true; - -<<<<<<< HEAD - /** - * Creates a Disjoint Path Pair from two paths. - * - * @param p1 first path - * @param p2 second path - */ -======= ->>>>>>> Disjoint Path Pairs (Suurballe) utils - public DisjointPathPair(Path p1, Path p2) { - path1 = p1; - path2 = p2; - } -<<<<<<< HEAD - - @Override -======= ->>>>>>> Disjoint Path Pairs (Suurballe) utils - public V src() { - return path1.src(); - } - -<<<<<<< HEAD - @Override - public V dst() { - return path1.dst(); - } - - @Override -======= - public V dst() { - return path1.dst(); - } ->>>>>>> Disjoint Path Pairs (Suurballe) utils - public double cost() { - if (!hasBackup()) { - return path1.cost(); - } - return path1.cost() + path2.cost(); - } -<<<<<<< HEAD - - @Override -======= ->>>>>>> Disjoint Path Pairs (Suurballe) utils - public List edges() { - if (usingPath1 || !hasBackup()) { - return path1.edges(); - } else { - return path2.edges(); - } - } -<<<<<<< HEAD - - /** - * Checks if this path pair contains a backup/secondary path. - * - * @return boolean representing whether it has backup - */ - public boolean hasBackup() { - return path2 != null && path2.edges() != null; - } - - /** - * Switches this disjoint path pair to using its backup path, instead of - * using its primary. - */ - public void useBackup() { - usingPath1 = !usingPath1; - } - - @Override -======= - public boolean hasBackup() { - return path2 != null && path2.edges() != null; - } - public void useBackup() { - usingPath1 = !usingPath1; - } ->>>>>>> Disjoint Path Pairs (Suurballe) utils - public String toString() { - return toStringHelper(this) - .add("src", src()) - .add("dst", dst()) - .add("cost", cost()) - .add("edges", edges()) - .toString(); - } -<<<<<<< HEAD - - @Override -======= ->>>>>>> Disjoint Path Pairs (Suurballe) utils - public int hashCode() { - Set> paths; - if (!hasBackup()) { - paths = of(path1); - } else { - paths = of(path1, path2); - } - return Objects.hash(paths); - } -<<<<<<< HEAD - - @Override -======= ->>>>>>> Disjoint Path Pairs (Suurballe) utils - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof DisjointPathPair) { - final DisjointPathPair other = (DisjointPathPair) obj; - return Objects.equals(this.src(), other.src()) && - Objects.equals(this.dst(), other.dst()) && - (Objects.equals(this.path1, other.path1) && - Objects.equals(this.path2, other.path2)) || - (Objects.equals(this.path1, other.path2) && - Objects.equals(this.path2, other.path1)); - } - return false; - } -<<<<<<< HEAD - - /** - * Returns number of paths inside this path pair object. - * - * @return number of paths - */ -======= ->>>>>>> Disjoint Path Pairs (Suurballe) utils - public int size() { - if (hasBackup()) { - return 2; - } - return 1; - } -} diff --git a/framework/src/onos/utils/misc/src/main/java/org/onlab/util/Frequency.java b/framework/src/onos/utils/misc/src/main/java/org/onlab/util/Frequency.java index 5669abdc..1ef71130 100644 --- a/framework/src/onos/utils/misc/src/main/java/org/onlab/util/Frequency.java +++ b/framework/src/onos/utils/misc/src/main/java/org/onlab/util/Frequency.java @@ -18,8 +18,6 @@ package org.onlab.util; import com.google.common.base.MoreObjects; import com.google.common.collect.ComparisonChain; -import java.util.Objects; - /** * Class representing frequency. This class is intended to be used for a value whose unit is Hz * and its family (KHz, MHz, etc.). @@ -157,7 +155,7 @@ public final class Frequency implements RichComparable { @Override public int hashCode() { - return Objects.hash(frequency); + return Long.hashCode(frequency); } @Override diff --git a/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/DisjointPathPairTest.java b/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/DisjointPathPairTest.java new file mode 100644 index 00000000..ca6c56c4 --- /dev/null +++ b/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/DisjointPathPairTest.java @@ -0,0 +1,43 @@ +package org.onlab.graph; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import com.google.common.collect.ImmutableList; +import com.google.common.testing.EqualsTester; + +/** + * Test of DisjointPathPair. + */ +public class DisjointPathPairTest { + + private static final TestVertex A = new TestVertex("A"); + private static final TestVertex B = new TestVertex("B"); + private static final TestVertex C = new TestVertex("C"); + private static final TestVertex D = new TestVertex("D"); + + private static final TestEdge AB = new TestEdge(A, B, 1.0); + private static final TestEdge BC = new TestEdge(B, C, 1.0); + private static final TestEdge AD = new TestEdge(A, D, 1.0); + private static final TestEdge DC = new TestEdge(D, C, 1.0); + + private static final Path ABC + = new DefaultPath<>(ImmutableList.of(AB, BC), 1.0); + private static final Path ADC + = new DefaultPath<>(ImmutableList.of(AD, DC), 1.0); + + @Test + public void testSwappingPrimarySecondaryDoesntImpactHashCode() { + assertEquals(new DisjointPathPair<>(ABC, ADC).hashCode(), + new DisjointPathPair<>(ADC, ABC).hashCode()); + } + + @Test + public void testSwappingPrimarySecondaryDoesntImpactEquality() { + new EqualsTester() + .addEqualityGroup(new DisjointPathPair<>(ABC, ADC), + new DisjointPathPair<>(ADC, ABC)); + } + +} diff --git a/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/TestVertex.java b/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/TestVertex.java index be92bd27..b0b92a4a 100644 --- a/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/TestVertex.java +++ b/framework/src/onos/utils/misc/src/test/java/org/onlab/graph/TestVertex.java @@ -30,7 +30,7 @@ public class TestVertex implements Vertex { @Override public int hashCode() { - return Objects.hash(name); + return name.hashCode(); } @Override diff --git a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Coordinator.java b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Coordinator.java index ef1c31f3..228e7834 100644 --- a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Coordinator.java +++ b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Coordinator.java @@ -25,6 +25,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -41,7 +42,7 @@ import static org.onlab.stc.Coordinator.Status.*; */ public class Coordinator { - private static final int MAX_THREADS = 16; + private static final int MAX_THREADS = 64; private final ExecutorService executor = newFixedThreadPool(MAX_THREADS); @@ -143,13 +144,15 @@ public class Coordinator { } /** - * Wants for completion of the entire process flow. + * Waits for completion of the entire process flow. * * @return exit code to use * @throws InterruptedException if interrupted while waiting for completion */ public int waitFor() throws InterruptedException { - latch.await(); + while (!store.isComplete()) { + latch.await(1, TimeUnit.SECONDS); + } return store.hasFailures() ? 1 : 0; } @@ -234,14 +237,25 @@ public class Coordinator { substitute(step.command()))); } } else if (directive == SKIP) { - if (step instanceof Group) { - Group group = (Group) step; - group.children().forEach(child -> delegate.onCompletion(child, SKIPPED)); - } - delegate.onCompletion(step, SKIPPED); + skipStep(step); } } + /** + * Recursively skips the specified step or group and any steps/groups within. + * + * @param step step or group + */ + private void skipStep(Step step) { + if (step instanceof Group) { + Group group = (Group) step; + store.markComplete(step, SKIPPED); + group.children().forEach(this::skipStep); + } + delegate.onCompletion(step, SKIPPED); + + } + /** * Determines the state of the specified step. * @@ -258,8 +272,8 @@ public class Coordinator { Status depStatus = store.getStatus(dependency.dst()); if (depStatus == WAITING || depStatus == IN_PROGRESS) { return NOOP; - } else if ((depStatus == FAILED || depStatus == SKIPPED) && - !dependency.isSoft()) { + } else if (((depStatus == FAILED || depStatus == SKIPPED) && !dependency.isSoft()) || + (step.group() != null && store.getStatus(step.group()) == SKIPPED)) { return SKIP; } } diff --git a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Step.java b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Step.java index 3d8ea983..e14addb5 100644 --- a/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Step.java +++ b/framework/src/onos/utils/stc/src/main/java/org/onlab/stc/Step.java @@ -101,7 +101,7 @@ public class Step implements Vertex { @Override public int hashCode() { - return Objects.hash(name); + return name.hashCode(); } @Override -- cgit 1.2.3-korg