本文整理汇总了Java中org.openflow.protocol.factory.MessageParseException类的典型用法代码示例。如果您正苦于以下问题:Java MessageParseException类的具体用法?Java MessageParseException怎么用?Java MessageParseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MessageParseException类属于org.openflow.protocol.factory包,在下文中一共展示了MessageParseException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGarbageAtEnd
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
public void testGarbageAtEnd() throws MessageParseException {
// This is a OFError msg (12 bytes), that encaps a OFVendor msg (24
// bytes)
// AND some zeros at the end (40 bytes) for a total of 76 bytes
// THIS is what an NEC sends in reply to Nox's VENDOR request
byte[] oferrorRaw = { 0x01, 0x01, 0x00, 0x4c, 0x00, 0x00, 0x10,
(byte) 0xcc, 0x00, 0x01, 0x00, 0x01, 0x01, 0x04, 0x00, 0x18,
0x00, 0x00, 0x10, (byte) 0xcc, 0x00, 0x00, 0x23, 0x20, 0x00,
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00 };
OFMessageFactory factory = BasicFactory.getInstance();
ChannelBuffer oferrorBuf =
ChannelBuffers.wrappedBuffer(oferrorRaw);
List<OFMessage> msg = factory.parseMessage(oferrorBuf);
TestCase.assertNotNull(msg);
TestCase.assertEquals(msg.size(), 1);
TestCase.assertEquals(76, msg.get(0).getLengthU());
ChannelBuffer out = ChannelBuffers.dynamicBuffer();
msg.get(0).writeTo(out);
TestCase.assertEquals(76, out.readableBytes());
}
示例2: testCreateAndParse
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
public void testCreateAndParse() throws MessageParseException {
BasicFactory factory = BasicFactory.getInstance();
OFMessage m = factory.getMessage(OFType.HELLO);
m.setVersion((byte) 1);
m.setType(OFType.ECHO_REQUEST);
m.setLength(U16.t(8));
m.setXid(0xdeadbeef);
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
ChannelBuffer bb2 = ChannelBuffers.dynamicBuffer();
m.writeTo(bb);
bb2.writeBytes(bb, bb.readableBytes()-1);
TestCase.assertNull(factory.parseMessage(bb2));
bb2.writeByte(bb.readByte());
List<OFMessage> message = factory.parseMessage(bb2);
TestCase.assertNotNull(message);
TestCase.assertEquals(message.size(), 1);
TestCase.assertTrue(message.get(0).getType() == OFType.ECHO_REQUEST);
}
示例3: testCurrouptedMsgParse
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
public void testCurrouptedMsgParse() throws MessageParseException {
BasicFactory factory = BasicFactory.getInstance();
OFMessage m = factory.getMessage(OFType.HELLO);
m.setVersion((byte) 1);
m.setType(OFType.ERROR);
m.setLength(U16.t(8));
m.setXid(0xdeadbeef);
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
m.writeTo(bb);
try {
factory.parseMessage(bb);
}
catch(Exception e) {
TestCase.assertEquals(MessageParseException.class, e.getClass());
}
}
示例4: testCustomVendorAction
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
public void testCustomVendorAction() throws MessageParseException {
BasicFactory factory = BasicFactory.getInstance();
OFVendorActionRegistry.getInstance().register(
MockVendorAction.VENDOR_ID, new MockVendorActionFactory());
byte[] deadBeefMessage = {
(byte) 0xff, (byte) 0xff, // action vendor
0x00, 0x10, // length
(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte)0xef, // deadbeaf
0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08 // pad
};
ChannelBuffer buf = ChannelBuffers.copiedBuffer(deadBeefMessage);
List<OFAction> actions = factory.parseActions(buf,deadBeefMessage.length);
assertEquals(1, actions.size());
OFAction ofAction = actions.get(0);
assertTrue("Action should be MockVendorAction, but is "+ofAction.getClass(), ofAction instanceof MockVendorAction);
assertArrayEquals( new byte[] { 1,2,3,4,5,6,7,8}, ((MockVendorAction)ofAction).getMockData());
}
示例5: testGenericVendorAction
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
public void testGenericVendorAction() throws MessageParseException {
byte[] nonDeadBeefMessage = {
(byte) 0xff, (byte) 0xff, // action vendor
0x00, 0x10, // length
(byte) 0x7e, (byte) 0xe7, (byte) 0xbe, (byte)0xef, // deadbeaf
0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08 // pad
};
BasicFactory factory = BasicFactory.getInstance();
OFVendorActionRegistry.getInstance().register(
MockVendorAction.VENDOR_ID, new MockVendorActionFactory());
ChannelBuffer buf = ChannelBuffers.copiedBuffer(nonDeadBeefMessage);
List<OFAction> actions = factory.parseActions(buf,nonDeadBeefMessage.length);
assertEquals(1, actions.size());
OFAction ofAction = actions.get(0);
assertTrue("Action should be OFActionVendorGeneric, but is "+ofAction.getClass(), ofAction instanceof OFActionVendorGeneric);
}
示例6: testGarbageAtEnd
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
public void testGarbageAtEnd() throws MessageParseException {
// This is a OFError msg (12 bytes), that encaps a OFVendor msg (24
// bytes)
// AND some zeros at the end (40 bytes) for a total of 76 bytes
// THIS is what an NEC sends in reply to Nox's VENDOR request
byte[] oferrorRaw = { 0x01, 0x01, 0x00, 0x4c, 0x00, 0x00, 0x10,
(byte) 0xcc, 0x00, 0x01, 0x00, 0x01, 0x01, 0x04, 0x00, 0x18,
0x00, 0x00, 0x10, (byte) 0xcc, 0x00, 0x00, 0x23, 0x20, 0x00,
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00 };
OFMessageFactory factory = new BasicFactory();
ChannelBuffer oferrorBuf =
ChannelBuffers.wrappedBuffer(oferrorRaw);
List<OFMessage> msg = factory.parseMessage(oferrorBuf);
TestCase.assertNotNull(msg);
TestCase.assertEquals(msg.size(), 1);
TestCase.assertEquals(76, msg.get(0).getLengthU());
ChannelBuffer out = ChannelBuffers.dynamicBuffer();
msg.get(0).writeTo(out);
TestCase.assertEquals(76, out.readableBytes());
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:26,代码来源:OFErrorTest.java
示例7: testCreateAndParse
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
public void testCreateAndParse() throws MessageParseException {
BasicFactory factory = new BasicFactory();
OFMessage m = factory.getMessage(OFType.HELLO);
m.setVersion((byte) 1);
m.setType(OFType.ECHO_REQUEST);
m.setLength(U16.t(8));
m.setXid(0xdeadbeef);
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
ChannelBuffer bb2 = ChannelBuffers.dynamicBuffer();
m.writeTo(bb);
bb2.writeBytes(bb, bb.readableBytes()-1);
TestCase.assertNull(factory.parseMessage(bb2));
bb2.writeByte(bb.readByte());
List<OFMessage> message = factory.parseMessage(bb2);
TestCase.assertNotNull(message);
TestCase.assertEquals(message.size(), 1);
TestCase.assertTrue(message.get(0).getType() == OFType.ECHO_REQUEST);
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:19,代码来源:BasicFactoryTest.java
示例8: testCurrouptedMsgParse
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
public void testCurrouptedMsgParse() throws MessageParseException {
BasicFactory factory = new BasicFactory();
OFMessage m = factory.getMessage(OFType.HELLO);
m.setVersion((byte) 1);
m.setType(OFType.ERROR);
m.setLength(U16.t(8));
m.setXid(0xdeadbeef);
ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
m.writeTo(bb);
try {
factory.parseMessage(bb);
}
catch(Exception e) {
TestCase.assertEquals(MessageParseException.class, e.getClass());
}
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:17,代码来源:BasicFactoryTest.java
示例9: getOffendingMsg
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
public OFMessage getOffendingMsg() throws MessageParseException {
// should only have one message embedded; if more than one, just
// grab first
if (this.error == null) {
return null;
}
final ChannelBuffer errorMsg = ChannelBuffers.wrappedBuffer(this.error);
if (this.factory == null) {
throw new RuntimeException("MessageFactory not set");
}
final List<OFMessage> msglist = this.factory.parseMessage(errorMsg);
if (msglist == null) {
return null;
}
return msglist.get(0);
}
示例10: processOFError
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
@Override
void processOFError(final SwitchChannelHandler h, final OFError m) {
try {
if (m.getOffendingMsg().getType() != OFType.BARRIER_REQUEST) {
h.log.error(
"Error waiting for features (type:{}, code:{})",
m.getErrorType(), m.getErrorCode());
if (h.channel.isOpen()) {
h.channel.close();
}
} else {
h.log.warn(
"Barrier Request message not understood by switch {}; "
+ "if it's an HP switch you are probably ok.",
HexString.toHexString(h.featuresReply
.getDatapathId()));
}
} catch (MessageParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例11: testCustomVendorAction
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
public void testCustomVendorAction() throws MessageParseException {
BasicFactory factory = new BasicFactory();
OFVendorActionRegistry.getInstance().register(
MockVendorAction.VENDOR_ID, new MockVendorActionFactory());
byte[] deadBeefMessage = {
(byte) 0xff, (byte) 0xff, // action vendor
0x00, 0x10, // length
(byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte)0xef, // deadbeaf
0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08 // pad
};
ChannelBuffer buf = ChannelBuffers.copiedBuffer(deadBeefMessage);
List<OFAction> actions = factory.parseActions(buf,deadBeefMessage.length);
assertEquals(1, actions.size());
OFAction ofAction = actions.get(0);
assertTrue("Action should be MockVendorAction, but is "+ofAction.getClass(), ofAction instanceof MockVendorAction);
assertArrayEquals( new byte[] { 1,2,3,4,5,6,7,8}, ((MockVendorAction)ofAction).getMockData());
}
示例12: testGenericVendorAction
import org.openflow.protocol.factory.MessageParseException; //导入依赖的package包/类
public void testGenericVendorAction() throws MessageParseException {
byte[] nonDeadBeefMessage = {
(byte) 0xff, (byte) 0xff, // action vendor
0x00, 0x10, // length
(byte) 0x7e, (byte) 0xe7, (byte) 0xbe, (byte)0xef, // deadbeaf
0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08 // pad
};
BasicFactory factory = new BasicFactory();
OFVendorActionRegistry.getInstance().register(
MockVendorAction.VENDOR_ID, new MockVendorActionFactory());
ChannelBuffer buf = ChannelBuffers.copiedBuffer(nonDeadBeefMessage);
List<OFAction> actions = factory.parseActions(buf,nonDeadBeefMessage.length);
assertEquals(1, actions.size());
OFAction ofAction = actions.get(0);
assertTrue("Action should be OFActionVendorGeneric, but is "+ofAction.getClass(), ofAction instanceof OFActionVendorGeneric);
}