1 package org.openflow.protocol;
3 import java.nio.ByteBuffer;
6 import org.openflow.protocol.factory.BasicFactory;
7 import org.openflow.util.U16;
9 import junit.framework.TestCase;
13 public class BasicFactoryTest extends TestCase {
14 public void testCreateAndParse() {
15 BasicFactory factory = new BasicFactory();
16 OFMessage m = factory.getMessage(OFType.HELLO);
17 m.setVersion((byte) 1);
18 m.setType(OFType.ECHO_REQUEST);
19 m.setLength(U16.t(8));
21 ByteBuffer bb = ByteBuffer.allocate(1024);
24 bb.limit(bb.limit()-1);
25 TestCase.assertEquals(0, factory.parseMessages(bb).size());
26 bb.limit(bb.limit()+1);
27 List<OFMessage> messages = factory.parseMessages(bb);
28 TestCase.assertEquals(1, messages.size());
29 TestCase.assertTrue(messages.get(0).getType() == OFType.ECHO_REQUEST);