From 76dc892491948adae5e5e62cf94448967e8d865b Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Sun, 6 Dec 2015 07:15:03 -0800 Subject: Fixes bad POM file with ONOS commit 8c68536972f63069c263635c9d9f4f31d7f3e9a2 Change-Id: I7adb5a2d3738d53dbc41db7577768b0e7ced5450 Signed-off-by: Ashlee Young --- .../onosproject/bgp/BgpPeerChannelHandlerTest.java | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100755 framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerChannelHandlerTest.java (limited to 'framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerChannelHandlerTest.java') diff --git a/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerChannelHandlerTest.java b/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerChannelHandlerTest.java new file mode 100755 index 00000000..26ed36d8 --- /dev/null +++ b/framework/src/onos/protocols/bgp/ctl/src/test/java/org/onosproject/bgp/BgpPeerChannelHandlerTest.java @@ -0,0 +1,107 @@ +/* + * 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 java.util.LinkedList; +import java.util.concurrent.TimeUnit; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; +import org.jboss.netty.channel.ChannelHandlerContext; +import org.jboss.netty.channel.ChannelStateEvent; +import org.jboss.netty.channel.SimpleChannelHandler; +import org.onosproject.bgpio.protocol.ver4.BgpKeepaliveMsgVer4; +import org.onosproject.bgpio.protocol.ver4.BgpOpenMsgVer4; +import org.onosproject.bgpio.types.BgpHeader; +import org.onosproject.bgpio.types.BgpValueType; + +public class BgpPeerChannelHandlerTest extends SimpleChannelHandler { + public static final int OPEN_MSG_MINIMUM_LENGTH = 29; + public static final byte[] MARKER = 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}; + public static final BgpHeader DEFAULT_OPEN_HEADER = new BgpHeader(MARKER, + (short) OPEN_MSG_MINIMUM_LENGTH, (byte) 0X01); + LinkedList capabilityTlv = new LinkedList<>(); + public byte version; + public short asNumber; + public short holdTime; + public int bgpId; + public boolean isLargeAsCapabilitySet; + + final BgpOpenMsgVer4 openMessage = new BgpOpenMsgVer4(); + ChannelHandlerContext savedCtx; + + /** + * Constructor to initialize all variables of BGP Open message. + * + * @param version BGP version in open message + * @param asNumber AS number in open message + * @param holdTime hold time in open message + * @param bgpId BGP identifier in open message + * @param capabilityTlv capabilities in open message + */ + public BgpPeerChannelHandlerTest(byte version, + short asNumber, + short holdTime, + int bgpId, + boolean isLargeAsCapabilitySet, + LinkedList capabilityTlv) { + this.version = version; + this.asNumber = asNumber; + this.holdTime = holdTime; + this.bgpId = bgpId; + this.isLargeAsCapabilitySet = isLargeAsCapabilitySet; + this.capabilityTlv = capabilityTlv; + } + + /** + * closes the channel. + */ + void closeChannel() { + savedCtx.getChannel().close(); + } + + @Override + public void channelConnected(ChannelHandlerContext ctx, + ChannelStateEvent channelEvent) throws InterruptedException { + this.savedCtx = ctx; + + BgpOpenMsgVer4 openMsg = new BgpOpenMsgVer4(DEFAULT_OPEN_HEADER, + this.version, + this.asNumber, + this.holdTime, + this.bgpId, + this.capabilityTlv); + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); + openMsg.writeTo(buffer); + ctx.getChannel().write(buffer); + + TimeUnit.MILLISECONDS.sleep(100); + + BgpKeepaliveMsgVer4 keepaliveMsg = new BgpKeepaliveMsgVer4(); + ChannelBuffer buffer1 = ChannelBuffers.dynamicBuffer(); + keepaliveMsg.writeTo(buffer1); + ctx.getChannel().write(buffer1); + } + + @Override + public void channelDisconnected(ChannelHandlerContext ctx, + ChannelStateEvent channelEvent) { + //Do Nothing + } +} -- cgit 1.2.3-korg