Removed the old openflowj protocol library
Change-Id: I4fcd0399c6eb0d9089116e365b55505042ded1fc
diff --git a/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java b/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java
index 88a1177..79cc0e8 100644
--- a/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java
+++ b/src/test/java/net/onrc/onos/core/registry/StandaloneRegistryTest.java
@@ -24,7 +24,7 @@
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-import org.openflow.util.HexString;
+import org.projectfloodlight.openflow.util.HexString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java b/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java
index 5490162..3ac2c96 100644
--- a/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java
+++ b/src/test/java/net/onrc/onos/core/registry/ZookeeperRegistryTest.java
@@ -35,10 +35,10 @@
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.openflow.util.HexString;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
+import org.projectfloodlight.openflow.util.HexString;
/**
* Unit test for {@link ZookeeperRegistry}.
diff --git a/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java b/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java
index 7048697..fbba92c 100644
--- a/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java
+++ b/src/test/java/net/onrc/onos/core/util/FlowEntryActionTest.java
@@ -13,7 +13,7 @@
import net.onrc.onos.core.util.FlowEntryAction.ActionStripVlan;
import org.junit.Test;
-import org.openflow.protocol.OFPort;
+import org.projectfloodlight.openflow.types.OFPort;
public class FlowEntryActionTest {
@@ -56,7 +56,7 @@
act.setActionOutputToController((short) 0);
FlowEntryAction actCopy = new FlowEntryAction();
- actCopy.setActionOutput(new PortNumber(OFPort.OFPP_CONTROLLER.getValue()));
+ actCopy.setActionOutput(new PortNumber(OFPort.CONTROLLER.getShortPortNumber()));
FlowEntryAction actCopy2 = new FlowEntryAction(act.toString());
diff --git a/src/test/java/org/openflow/protocol/BasicFactoryTest.java b/src/test/java/org/openflow/protocol/BasicFactoryTest.java
deleted file mode 100644
index 49b2df9..0000000
--- a/src/test/java/org/openflow/protocol/BasicFactoryTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.factory.MessageParseException;
-import org.openflow.util.U16;
-
-public class BasicFactoryTest extends TestCase {
-
- 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);
- }
-
- public void testInvalidMsgParse() 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(16));
- m.setXid(0xdeadbeef);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- m.writeTo(bb);
- List<OFMessage> message = factory.parseMessage(bb);
- TestCase.assertNull(message);
- }
-
- 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());
- }
- }
-
-}
diff --git a/src/test/java/org/openflow/protocol/OFActionTypeTest.java b/src/test/java/org/openflow/protocol/OFActionTypeTest.java
deleted file mode 100644
index 2c9827e..0000000
--- a/src/test/java/org/openflow/protocol/OFActionTypeTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-import org.openflow.protocol.action.OFActionType;
-
-
-public class OFActionTypeTest extends TestCase {
- @Test
- public void testMapping() throws Exception {
- TestCase.assertEquals(OFActionType.OUTPUT,
- OFActionType.valueOf((short) 0));
- TestCase.assertEquals(OFActionType.OPAQUE_ENQUEUE,
- OFActionType.valueOf((short) 11));
- TestCase.assertEquals(OFActionType.VENDOR,
- OFActionType.valueOf((short) 0xffff));
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFBarrierReplyTest.java b/src/test/java/org/openflow/protocol/OFBarrierReplyTest.java
deleted file mode 100644
index 7e447bb..0000000
--- a/src/test/java/org/openflow/protocol/OFBarrierReplyTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFBarrierReplyTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFBarrierReply msg = (OFBarrierReply) messageFactory
- .getMessage(OFType.BARRIER_REPLY);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.BARRIER_REPLY, msg.getType());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFBarrierRequestTest.java b/src/test/java/org/openflow/protocol/OFBarrierRequestTest.java
deleted file mode 100644
index 3aa9cb4..0000000
--- a/src/test/java/org/openflow/protocol/OFBarrierRequestTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFBarrierRequestTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFBarrierRequest msg = (OFBarrierRequest) messageFactory
- .getMessage(OFType.BARRIER_REQUEST);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.BARRIER_REQUEST, msg.getType());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFErrorTest.java b/src/test/java/org/openflow/protocol/OFErrorTest.java
deleted file mode 100644
index 7acd727..0000000
--- a/src/test/java/org/openflow/protocol/OFErrorTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.OFError.OFErrorType;
-import org.openflow.protocol.OFError.OFHelloFailedCode;
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.factory.MessageParseException;
-import org.openflow.protocol.factory.OFMessageFactory;
-import org.openflow.util.OFTestCase;
-
-public class OFErrorTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFError msg = (OFError) messageFactory.getMessage(OFType.ERROR);
- msg.setMessageFactory(messageFactory);
- msg.setErrorType(OFErrorType.OFPET_HELLO_FAILED.getValue());
- msg.setErrorCode((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
- .ordinal());
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFErrorType.OFPET_HELLO_FAILED.getValue(),
- msg.getErrorType());
- TestCase.assertEquals((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
- .ordinal(), msg.getErrorType());
- TestCase.assertNull(msg.getOffendingMsg());
-
- msg.setOffendingMsg(new OFHello());
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFErrorType.OFPET_HELLO_FAILED.getValue(),
- msg.getErrorType());
- TestCase.assertEquals((short) OFHelloFailedCode.OFPHFC_INCOMPATIBLE
- .ordinal(), msg.getErrorType());
- TestCase.assertNotNull(msg.getOffendingMsg());
- TestCase.assertEquals(OFHello.MINIMUM_LENGTH,
- msg.getOffendingMsg().length);
- }
-
- 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());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFFeaturesReplyTest.java b/src/test/java/org/openflow/protocol/OFFeaturesReplyTest.java
deleted file mode 100644
index 62e491a..0000000
--- a/src/test/java/org/openflow/protocol/OFFeaturesReplyTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-
-public class OFFeaturesReplyTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFFeaturesReply ofr = (OFFeaturesReply) messageFactory
- .getMessage(OFType.FEATURES_REPLY);
- List<OFPhysicalPort> ports = new ArrayList<OFPhysicalPort>();
- OFPhysicalPort port = new OFPhysicalPort();
- port.setHardwareAddress(new byte[6]);
- port.setName("eth0");
- ports.add(port);
- ofr.setPorts(ports);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- ofr.writeTo(bb);
- ofr.readFrom(bb);
- TestCase.assertEquals(1, ofr.getPorts().size());
- TestCase.assertEquals("eth0", ofr.getPorts().get(0).getName());
-
- // test a 15 character name
- ofr.getPorts().get(0).setName("012345678901234");
- bb.clear();
- ofr.writeTo(bb);
- ofr.readFrom(bb);
- TestCase.assertEquals("012345678901234", ofr.getPorts().get(0).getName());
-
- // test a 16 character name getting truncated
- ofr.getPorts().get(0).setName("0123456789012345");
- bb.clear();
- ofr.writeTo(bb);
- ofr.readFrom(bb);
- TestCase.assertEquals("012345678901234", ofr.getPorts().get(0).getName());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFFlowRemovedTest.java b/src/test/java/org/openflow/protocol/OFFlowRemovedTest.java
deleted file mode 100644
index 11746e7..0000000
--- a/src/test/java/org/openflow/protocol/OFFlowRemovedTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.OFFlowRemoved.OFFlowRemovedReason;
-import org.openflow.util.OFTestCase;
-
-public class OFFlowRemovedTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFFlowRemoved msg = (OFFlowRemoved) messageFactory
- .getMessage(OFType.FLOW_REMOVED);
- msg.setMatch(new OFMatch());
- byte[] hwAddr = new byte[6];
- msg.getMatch().setDataLayerDestination(hwAddr);
- msg.getMatch().setDataLayerSource(hwAddr);
- msg.setReason(OFFlowRemovedReason.OFPRR_DELETE);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.FLOW_REMOVED, msg.getType());
- TestCase.assertEquals(OFFlowRemovedReason.OFPRR_DELETE, msg.getReason());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFGetConfigReplyTest.java b/src/test/java/org/openflow/protocol/OFGetConfigReplyTest.java
deleted file mode 100644
index c1f1f67..0000000
--- a/src/test/java/org/openflow/protocol/OFGetConfigReplyTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFGetConfigReplyTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFSetConfig msg = (OFSetConfig) messageFactory
- .getMessage(OFType.SET_CONFIG);
- msg.setFlags((short) 1);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.SET_CONFIG, msg.getType());
- TestCase.assertEquals((short)1, msg.getFlags());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFGetConfigRequestTest.java b/src/test/java/org/openflow/protocol/OFGetConfigRequestTest.java
deleted file mode 100644
index 94d9036..0000000
--- a/src/test/java/org/openflow/protocol/OFGetConfigRequestTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFGetConfigRequestTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFGetConfigRequest msg = (OFGetConfigRequest) messageFactory
- .getMessage(OFType.GET_CONFIG_REQUEST);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.GET_CONFIG_REQUEST, msg.getType());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFMatchTest.java b/src/test/java/org/openflow/protocol/OFMatchTest.java
deleted file mode 100644
index fd7863a..0000000
--- a/src/test/java/org/openflow/protocol/OFMatchTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import junit.framework.TestCase;
-
-public class OFMatchTest extends TestCase {
- public void testFromString() {
- OFMatch correct = new OFMatch();
- OFMatch tester = new OFMatch();
-
- // Various combinations of "all"/"any"
- tester.fromString("OFMatch[]");
- // correct is already wildcarded
- TestCase.assertEquals(correct, tester);
- tester.fromString("all");
- TestCase.assertEquals(correct, tester);
- tester.fromString("ANY");
- TestCase.assertEquals(correct, tester);
- tester.fromString("");
- TestCase.assertEquals(correct, tester);
- tester.fromString("[]");
- TestCase.assertEquals(correct, tester);
-
- // ip_src
- correct.setWildcards(~OFMatch.OFPFW_NW_SRC_MASK);
- correct.setNetworkSource(0x01010203);
- tester.fromString("nw_src=1.1.2.3");
- TestCase.assertEquals(correct.getNetworkSourceMaskLen(), tester
- .getNetworkSourceMaskLen());
- TestCase.assertEquals(correct, tester);
- tester.fromString("IP_sRc=1.1.2.3");
- TestCase.assertEquals(correct.getNetworkSourceMaskLen(), tester
- .getNetworkSourceMaskLen());
- TestCase.assertEquals(correct, tester);
-
- // 0xVlan
- correct = new OFMatch();
- correct.setDataLayerVirtualLan((short)65535);
- correct.setWildcards(~OFMatch.OFPFW_DL_VLAN);
- tester = new OFMatch();
- tester.fromString("dl_vlan=0xffff");
- TestCase.assertEquals(correct, tester);
- }
-
- public void testToString() {
- OFMatch match = new OFMatch();
- match.fromString("nw_dst=3.4.5.6/8");
- TestCase.assertEquals(8, match.getNetworkDestinationMaskLen());
- String correct = "OFMatch[nw_dst=3.0.0.0/8]";
- String tester = match.toString();
-
- TestCase.assertEquals(correct, tester);
- tester = "OFMatch[dl_type=35020]";
- correct = "OFMatch[dl_type=0x88cc]";
- match = new OFMatch();
- match.fromString(tester);
- TestCase.assertEquals(correct, match.toString());
- OFMatch match2 = new OFMatch();
- match2.fromString(correct);
- TestCase.assertEquals(match, match2);
- }
-
- public void testClone() {
- OFMatch match1 = new OFMatch();
- OFMatch match2 = match1.clone();
- TestCase.assertEquals(match1, match2);
- match2.setNetworkProtocol((byte) 4);
- match2.setWildcards(match2.getWildcards() & ~OFMatch.OFPFW_NW_PROTO);
- TestCase.assertNotSame(match1, match2);
- }
-
- public void testIpToString() {
- String test = OFMatch.ipToString(-1);
- TestCase.assertEquals("255.255.255.255", test);
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFMessageContextStoreTest.java b/src/test/java/org/openflow/protocol/OFMessageContextStoreTest.java
deleted file mode 100644
index 60a9e73..0000000
--- a/src/test/java/org/openflow/protocol/OFMessageContextStoreTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import junit.framework.TestCase;
-
-public class OFMessageContextStoreTest extends TestCase {
- public void testStoreAndGet() {
- OFMessage msg = new OFMessage();
- OFMessageContextStore<String> store = new OFMessageContextStore<String>(msg, this.getName());
- String key = "mykey";
- String value = "myvalue";
- store.put(key, value);
- TestCase.assertEquals(value, store.get(key));
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFPortConfigTest.java b/src/test/java/org/openflow/protocol/OFPortConfigTest.java
deleted file mode 100644
index 9b115eb..0000000
--- a/src/test/java/org/openflow/protocol/OFPortConfigTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFPortConfigTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFPortMod msg = (OFPortMod) messageFactory
- .getMessage(OFType.PORT_MOD);
- msg.setHardwareAddress(new byte[6]);
- msg.portNumber = 1;
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.PORT_MOD, msg.getType());
- TestCase.assertEquals(1, msg.getPortNumber());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFPortStatusTest.java b/src/test/java/org/openflow/protocol/OFPortStatusTest.java
deleted file mode 100644
index 4fab64e..0000000
--- a/src/test/java/org/openflow/protocol/OFPortStatusTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.OFPortStatus.OFPortReason;
-import org.openflow.util.OFTestCase;
-
-public class OFPortStatusTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFPortStatus msg = (OFPortStatus) messageFactory
- .getMessage(OFType.PORT_STATUS);
- msg.setDesc(new OFPhysicalPort());
- msg.getDesc().setHardwareAddress(new byte[6]);
- msg.getDesc().setName("eth0");
- msg.setReason((byte) OFPortReason.OFPPR_ADD.ordinal());
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.PORT_STATUS, msg.getType());
- TestCase.assertEquals((byte) OFPortReason.OFPPR_ADD.ordinal(), msg
- .getReason());
- TestCase.assertNotNull(msg.getDesc());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFSetConfigTest.java b/src/test/java/org/openflow/protocol/OFSetConfigTest.java
deleted file mode 100644
index 2a9e86f..0000000
--- a/src/test/java/org/openflow/protocol/OFSetConfigTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.util.OFTestCase;
-
-public class OFSetConfigTest extends OFTestCase {
- public void testWriteRead() throws Exception {
- OFGetConfigReply msg = (OFGetConfigReply) messageFactory
- .getMessage(OFType.GET_CONFIG_REPLY);
- msg.setFlags((short) 1);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(OFType.GET_CONFIG_REPLY, msg.getType());
- TestCase.assertEquals((short)1, msg.getFlags());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFStatisticsReplyTest.java b/src/test/java/org/openflow/protocol/OFStatisticsReplyTest.java
deleted file mode 100644
index 50bac8f..0000000
--- a/src/test/java/org/openflow/protocol/OFStatisticsReplyTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.factory.OFMessageFactory;
-import org.openflow.protocol.statistics.OFStatisticsType;
-import org.openflow.util.OFTestCase;
-
-public class OFStatisticsReplyTest extends OFTestCase {
- public void testOFFlowStatisticsReply() throws Exception {
- byte[] packet = new byte[] { 0x01, 0x11, 0x01, 0x2c, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, (byte) 0xff,
- (byte) 0xff, 0x00, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x0a, 0x00, 0x00, 0x03, 0x0a, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, (byte) 0xa6,
- (byte) 0xa6, 0x00, (byte) 0xff, (byte) 0xff, 0x00, 0x05, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- (byte) 0xc4, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x02, (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x08, 0x06,
- 0x00, 0x02, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x03, 0x0a, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x3b, 0x2f, (byte) 0xfa, 0x40, (byte) 0xff, (byte) 0xff, 0x00,
- 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00,
- 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x03, (byte) 0xff, (byte) 0xff, 0x00, 0x62, 0x08,
- 0x00, 0x00, 0x01, 0x62, 0x37, 0x0a, 0x00, 0x00, 0x02, 0x0a,
- 0x00, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x3a, (byte) 0xc5, 0x2a, (byte) 0x80, (byte) 0xff,
- (byte) 0xff, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0xc4, 0x00, 0x00, 0x00,
- 0x08, 0x00, 0x02, 0x00, 0x00 };
-
- OFMessageFactory factory = new BasicFactory();
- ChannelBuffer packetBuf = ChannelBuffers.wrappedBuffer(packet);
- List<OFMessage> msg = factory.parseMessage(packetBuf);
- TestCase.assertNotNull(msg);
- TestCase.assertEquals(msg.size(), 1);
- TestCase.assertTrue(msg.get(0) instanceof OFStatisticsReply);
- OFStatisticsReply sr = (OFStatisticsReply) msg.get(0);
- TestCase.assertEquals(OFStatisticsType.FLOW, sr.getStatisticType());
- TestCase.assertEquals(3, sr.getStatistics().size());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFStatisticsRequestTest.java b/src/test/java/org/openflow/protocol/OFStatisticsRequestTest.java
deleted file mode 100644
index 74af6f4..0000000
--- a/src/test/java/org/openflow/protocol/OFStatisticsRequestTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.factory.OFMessageFactory;
-import org.openflow.protocol.statistics.OFFlowStatisticsRequest;
-import org.openflow.protocol.statistics.OFStatisticsType;
-import org.openflow.protocol.statistics.OFVendorStatistics;
-import org.openflow.util.OFTestCase;
-
-public class OFStatisticsRequestTest extends OFTestCase {
- public void testOFFlowStatisticsRequest() throws Exception {
- byte[] packet = new byte[] { 0x01, 0x10, 0x00, 0x38, 0x00, 0x00, 0x00,
- 0x16, 0x00, 0x01, 0x00, 0x00, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, 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,
- (byte) 0xff, 0x00, (byte) 0xff, (byte) 0xff };
-
- OFMessageFactory factory = new BasicFactory();
- ChannelBuffer packetBuf = ChannelBuffers.wrappedBuffer(packet);
- List<OFMessage> msg = factory.parseMessage(packetBuf);
- TestCase.assertNotNull(msg);
- TestCase.assertEquals(msg.size(), 1);
- TestCase.assertTrue(msg.get(0) instanceof OFStatisticsRequest);
- OFStatisticsRequest sr = (OFStatisticsRequest) msg.get(0);
- TestCase.assertEquals(OFStatisticsType.FLOW, sr.getStatisticType());
- TestCase.assertEquals(1, sr.getStatistics().size());
- TestCase.assertTrue(sr.getStatistics().get(0) instanceof OFFlowStatisticsRequest);
- }
-
- public void testOFStatisticsRequestVendor() throws Exception {
- byte[] packet = new byte[] { 0x01, 0x10, 0x00, 0x50, 0x00, 0x00, 0x00,
- 0x63, (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x4c, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x20,
- (byte) 0xe0, 0x00, 0x11, 0x00, 0x0c, 0x29, (byte) 0xc5,
- (byte) 0x95, 0x57, 0x02, 0x25, 0x5c, (byte) 0xca, 0x00, 0x02,
- (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x50, 0x04,
- 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x00, 0x00, 0x00,
- (byte) 0xff, (byte) 0xff, 0x4e, 0x20 };
-
- OFMessageFactory factory = new BasicFactory();
- ChannelBuffer packetBuf = ChannelBuffers.wrappedBuffer(packet);
- List<OFMessage> msg = factory.parseMessage(packetBuf);
- TestCase.assertNotNull(msg);
- TestCase.assertEquals(msg.size(), 1);
- TestCase.assertTrue(msg.get(0) instanceof OFStatisticsRequest);
- OFStatisticsRequest sr = (OFStatisticsRequest) msg.get(0);
- TestCase.assertEquals(OFStatisticsType.VENDOR, sr.getStatisticType());
- TestCase.assertEquals(1, sr.getStatistics().size());
- TestCase.assertTrue(sr.getStatistics().get(0) instanceof OFVendorStatistics);
- TestCase.assertEquals(68, ((OFVendorStatistics)sr.getStatistics().get(0)).getLength());
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFStatisticsTypeTest.java b/src/test/java/org/openflow/protocol/OFStatisticsTypeTest.java
deleted file mode 100644
index d44ef7f..0000000
--- a/src/test/java/org/openflow/protocol/OFStatisticsTypeTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-import org.openflow.protocol.statistics.OFStatisticsType;
-
-
-public class OFStatisticsTypeTest extends TestCase {
- @Test
- public void testMapping() throws Exception {
- TestCase.assertEquals(OFStatisticsType.DESC,
- OFStatisticsType.valueOf((short) 0, OFType.STATS_REQUEST));
- TestCase.assertEquals(OFStatisticsType.QUEUE,
- OFStatisticsType.valueOf((short) 5, OFType.STATS_REQUEST));
- TestCase.assertEquals(OFStatisticsType.VENDOR,
- OFStatisticsType.valueOf((short) 0xffff, OFType.STATS_REQUEST));
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFTypeTest.java b/src/test/java/org/openflow/protocol/OFTypeTest.java
deleted file mode 100644
index c6bf0a3..0000000
--- a/src/test/java/org/openflow/protocol/OFTypeTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-
-public class OFTypeTest extends TestCase {
-
- public void testOFTypeCreate() throws Exception {
- OFType foo = OFType.HELLO;
- Class<? extends OFMessage> c = foo.toClass();
- TestCase.assertEquals(c, OFHello.class);
- }
-
- @Test
- public void testMapping() throws Exception {
- TestCase.assertEquals(OFType.HELLO, OFType.valueOf((byte) 0));
- TestCase.assertEquals(OFType.BARRIER_REPLY, OFType.valueOf((byte) 19));
- }
-}
diff --git a/src/test/java/org/openflow/protocol/OFVendorTest.java b/src/test/java/org/openflow/protocol/OFVendorTest.java
deleted file mode 100644
index 1516a02..0000000
--- a/src/test/java/org/openflow/protocol/OFVendorTest.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.protocol;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.vendor.OFBasicVendorDataType;
-import org.openflow.protocol.vendor.OFBasicVendorId;
-import org.openflow.protocol.vendor.OFByteArrayVendorData;
-import org.openflow.protocol.vendor.OFVendorData;
-import org.openflow.protocol.vendor.OFVendorId;
-import org.openflow.util.OFTestCase;
-
-public class OFVendorTest extends OFTestCase {
-
- public static int ACME_VENDOR_ID = 0x00112233;
-
- static class AcmeVendorData implements OFVendorData {
- protected int dataType;
-
- public int getLength() {
- return 4;
- }
-
- public void readFrom(ChannelBuffer data, int length) {
- dataType = data.readInt();
- }
-
- public void writeTo(ChannelBuffer data) {
- data.writeInt(dataType);
- }
- }
-
- static class AcmeVendorData1 extends AcmeVendorData {
- public short flags;
- public short value;
-
- public static int DATA_TYPE = 1;
-
- public AcmeVendorData1() {
- }
-
- public AcmeVendorData1(short flags, short value) {
- this.dataType = DATA_TYPE;
- this.flags = flags;
- this.value = value;
- }
-
- public short getFlags() {
- return flags;
- }
-
- public short getValue() {
- return value;
- }
-
- public int getLength() {
- return 8;
- }
-
- public void readFrom(ChannelBuffer data, int length) {
- super.readFrom(data, length);
- flags = data.readShort();
- value = data.readShort();
-
- }
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(flags);
- data.writeShort(value);
- }
-
- public static Instantiable<OFVendorData> getInstantiable() {
- return new Instantiable<OFVendorData>() {
- public OFVendorData instantiate() {
- return new AcmeVendorData1();
- }
- };
- }
- }
-
- static class AcmeVendorData2 extends AcmeVendorData {
- public int type;
- public int subtype;
-
- public static int DATA_TYPE = 2;
-
- public AcmeVendorData2() {
- }
-
- public AcmeVendorData2(int type, int subtype) {
- this.dataType = DATA_TYPE;
- this.type = type;
- this.subtype = subtype;
- }
-
- public int getType() {
- return type;
- }
-
- public int getSubtype() {
- return subtype;
- }
-
- public int getLength() {
- return 12;
- }
-
- public void readFrom(ChannelBuffer data, int length) {
- super.readFrom(data, length);
- type = data.readShort();
- subtype = data.readShort();
-
- }
- public void writeTo(ChannelBuffer data) {
- super.writeTo(data);
- data.writeShort(type);
- data.writeShort(subtype);
- }
-
- public static Instantiable<OFVendorData> getInstantiable() {
- return new Instantiable<OFVendorData>() {
- public OFVendorData instantiate() {
- return new AcmeVendorData2();
- }
- };
- }
- }
-
- {
- OFBasicVendorId acmeVendorId = new OFBasicVendorId(ACME_VENDOR_ID, 4);
- OFVendorId.registerVendorId(acmeVendorId);
- OFBasicVendorDataType acmeVendorData1 = new OFBasicVendorDataType(
- AcmeVendorData1.DATA_TYPE, AcmeVendorData1.getInstantiable());
- acmeVendorId.registerVendorDataType(acmeVendorData1);
- OFBasicVendorDataType acmeVendorData2 = new OFBasicVendorDataType(
- AcmeVendorData2.DATA_TYPE, AcmeVendorData2.getInstantiable());
- acmeVendorId.registerVendorDataType(acmeVendorData2);
- }
-
- private OFVendor makeVendorMessage(int vendor) {
- OFVendor msg = (OFVendor) messageFactory.getMessage(OFType.VENDOR);
- msg.setVendorDataFactory(new BasicFactory());
- msg.setVendor(vendor);
- return msg;
- }
-
- public void testWriteRead() throws Exception {
- OFVendor msg = makeVendorMessage(1);
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- TestCase.assertEquals(1, msg.getVendor());
- }
-
- public void testVendorData() throws Exception {
- OFVendor msg = makeVendorMessage(ACME_VENDOR_ID);
- OFVendorData vendorData = new AcmeVendorData1((short)11, (short)22);
- msg.setVendorData(vendorData);
- msg.setLengthU(OFVendor.MINIMUM_LENGTH + vendorData.getLength());
- ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- assertEquals(ACME_VENDOR_ID, msg.getVendor());
- AcmeVendorData1 vendorData1 = (AcmeVendorData1) msg.getVendorData();
- assertEquals(11, vendorData1.getFlags());
- assertEquals(22, vendorData1.getValue());
-
- vendorData = new AcmeVendorData2(33, 44);
- msg.setVendorData(vendorData);
- msg.setLengthU(OFVendor.MINIMUM_LENGTH + vendorData.getLength());
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- assertEquals(ACME_VENDOR_ID, msg.getVendor());
- AcmeVendorData2 vendorData2 = (AcmeVendorData2) msg.getVendorData();
- assertEquals(33, vendorData2.getType());
- assertEquals(44, vendorData2.getSubtype());
-
- final int DUMMY_VENDOR_ID = 55;
- msg.setVendor(DUMMY_VENDOR_ID);
- byte[] genericVendorDataBytes = new byte[] {0x55, 0x66};
- vendorData = new OFByteArrayVendorData(genericVendorDataBytes);
- msg.setVendorData(vendorData);
- msg.setLengthU(OFVendor.MINIMUM_LENGTH + vendorData.getLength());
- bb.clear();
- msg.writeTo(bb);
- msg.readFrom(bb);
- assertEquals(DUMMY_VENDOR_ID, msg.getVendor());
- OFByteArrayVendorData genericVendorData = (OFByteArrayVendorData) msg.getVendorData();
- assertTrue(Arrays.equals(genericVendorDataBytes, genericVendorData.getBytes()));
- }
-}
diff --git a/src/test/java/org/openflow/util/HexStringTest.java b/src/test/java/org/openflow/util/HexStringTest.java
deleted file mode 100644
index 9e1fabb..0000000
--- a/src/test/java/org/openflow/util/HexStringTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.util;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-
-/**
- * Does hexstring conversion work?
- *
- * @author Rob Sherwood (rob.sherwood@stanford.edu)
- *
- */
-
-public class HexStringTest extends TestCase {
-
- @Test
- public void testMarshalling() throws Exception {
- String dpidStr = "00:00:00:23:20:2d:16:71";
- long dpid = HexString.toLong(dpidStr);
- String testStr = HexString.toHexString(dpid);
- TestCase.assertEquals(dpidStr, testStr);
- }
-
- @Test
- public void testToLong() {
- String dpidStr = "3e:1f:01:fc:72:8c:63:31";
- long valid = 0x3e1f01fc728c6331L;
- long testLong = HexString.toLong(dpidStr);
- TestCase.assertEquals(valid, testLong);
- }
-
- @Test
- public void testToLongMSB() {
- String dpidStr = "ca:7c:5e:d1:64:7a:95:9b";
- long valid = -3856102927509056101L;
- long testLong = HexString.toLong(dpidStr);
- TestCase.assertEquals(valid, testLong);
- }
-
- @Test
- public void testToLongError() {
- String dpidStr = "09:08:07:06:05:04:03:02:01";
- try {
- HexString.toLong(dpidStr);
- fail("HexString.toLong() should have thrown a NumberFormatException");
- }
- catch (NumberFormatException expected) {
- // do nothing
- }
- }
-
- @Test
- public void testToStringBytes() {
- byte[] dpid = { 0, 0, 0, 0, 0, 0, 0, -1 };
- String valid = "00:00:00:00:00:00:00:ff";
- String testString = HexString.toHexString(dpid);
- TestCase.assertEquals(valid, testString);
- }
-
- @Test
- public void testFromHexStringError() {
- String invalidStr = "00:00:00:00:00:00:ffff";
- try {
- HexString.fromHexString(invalidStr);
- fail("HexString.fromHexString() should have thrown a NumberFormatException");
- }
- catch (NumberFormatException expected) {
- // do nothing
- }
- }
-}
diff --git a/src/test/java/org/openflow/util/OFTestCase.java b/src/test/java/org/openflow/util/OFTestCase.java
deleted file mode 100644
index bf2f2ab..0000000
--- a/src/test/java/org/openflow/util/OFTestCase.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.util;
-
-import junit.framework.TestCase;
-
-import org.openflow.protocol.factory.BasicFactory;
-import org.openflow.protocol.factory.OFMessageFactory;
-
-public class OFTestCase extends TestCase {
- public OFMessageFactory messageFactory;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- messageFactory = new BasicFactory();
- }
-
- public void test() throws Exception {
- }
-}
diff --git a/src/test/java/org/openflow/util/U16Test.java b/src/test/java/org/openflow/util/U16Test.java
deleted file mode 100644
index ba87e7b..0000000
--- a/src/test/java/org/openflow/util/U16Test.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.util;
-
-import junit.framework.TestCase;
-
-public class U16Test extends TestCase {
- /**
- * Tests that we correctly translate unsigned values in and out of a short
- * @throws Exception
- */
- public void test() throws Exception {
- int val = 0xffff;
- TestCase.assertEquals((short)-1, U16.t(val));
- TestCase.assertEquals((short)32767, U16.t(0x7fff));
- TestCase.assertEquals(val, U16.f((short)-1));
- }
-}
diff --git a/src/test/java/org/openflow/util/U32Test.java b/src/test/java/org/openflow/util/U32Test.java
deleted file mode 100644
index 223c103..0000000
--- a/src/test/java/org/openflow/util/U32Test.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.util;
-
-import junit.framework.TestCase;
-
-public class U32Test extends TestCase {
- /**
- * Tests that we correctly translate unsigned values in and out of an int
- * @throws Exception
- */
- public void test() throws Exception {
- long val = 0xffffffffL;
- TestCase.assertEquals(-1, U32.t(val));
- TestCase.assertEquals(val, U32.f(-1));
- }
-}
diff --git a/src/test/java/org/openflow/util/U64Test.java b/src/test/java/org/openflow/util/U64Test.java
deleted file mode 100644
index 0a97e30..0000000
--- a/src/test/java/org/openflow/util/U64Test.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.util;
-
-import java.math.BigInteger;
-
-import junit.framework.TestCase;
-
-public class U64Test extends TestCase {
- /**
- * Tests that we correctly translate unsigned values in and out of a long
- * @throws Exception
- */
- public void test() throws Exception {
- BigInteger val = new BigInteger("ffffffffffffffff", 16);
- TestCase.assertEquals(-1, U64.t(val));
- TestCase.assertEquals(val, U64.f(-1));
- }
-}
diff --git a/src/test/java/org/openflow/util/U8Test.java b/src/test/java/org/openflow/util/U8Test.java
deleted file mode 100644
index 2c06c4d..0000000
--- a/src/test/java/org/openflow/util/U8Test.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.util;
-
-import junit.framework.TestCase;
-
-public class U8Test extends TestCase {
- /**
- * Tests that we correctly translate unsigned values in and out of a byte
- * @throws Exception
- */
- public void test() throws Exception {
- short val = 0xff;
- TestCase.assertEquals(-1, U8.t(val));
- TestCase.assertEquals(val, U8.f((byte)-1));
- }
-}
diff --git a/src/test/java/org/openflow/util/UnsignedTest.java b/src/test/java/org/openflow/util/UnsignedTest.java
deleted file mode 100644
index 7cdf739..0000000
--- a/src/test/java/org/openflow/util/UnsignedTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
-* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
-* University
-*
-* 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.openflow.util;
-
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-
-import junit.framework.TestCase;
-
-public class UnsignedTest extends TestCase {
- public static String ULONG_MAX = "18446744073709551615";
-
- /**
- * Tests that we correctly extract an unsigned long into a BigInteger
- * @throws Exception
- */
- public void testGetUnsignedLong() throws Exception {
- ByteBuffer bb = ByteBuffer.allocate(8);
- bb.put((byte)0xff).put((byte)0xff).put((byte)0xff).put((byte)0xff);
- bb.put((byte)0xff).put((byte)0xff).put((byte)0xff).put((byte)0xff);
- bb.position(0);
- bb.limit(8);
- BigInteger bi = Unsigned.getUnsignedLong(bb);
- BigInteger uLongMax = new BigInteger(ULONG_MAX);
- for (int i = 0; i < uLongMax.bitCount(); ++i) {
- TestCase.assertTrue("Bit: " + i + " should be: " + uLongMax.testBit(i),
- uLongMax.testBit(i) == bi.testBit(i));
- }
- TestCase.assertEquals(ULONG_MAX, bi.toString());
-
- bb = ByteBuffer.allocate(10);
- bb.put((byte)0x00);
- bb.put((byte)0xff).put((byte)0xff).put((byte)0xff).put((byte)0xff);
- bb.put((byte)0xff).put((byte)0xff).put((byte)0xff).put((byte)0xff);
- bb.put((byte)0x00);
- bb.position(0);
- bb.limit(10);
- bi = Unsigned.getUnsignedLong(bb, 1);
- uLongMax = new BigInteger(ULONG_MAX);
- for (int i = 0; i < uLongMax.bitCount(); ++i) {
- TestCase.assertTrue("Bit: " + i + " should be: " + uLongMax.testBit(i),
- uLongMax.testBit(i) == bi.testBit(i));
- }
- TestCase.assertEquals(ULONG_MAX, bi.toString());
- }
-
- /**
- * Tests that we correctly put an unsigned long into a ByteBuffer
- * @throws Exception
- */
- public void testPutUnsignedLong() throws Exception {
- ByteBuffer bb = ByteBuffer.allocate(8);
- BigInteger uLongMax = new BigInteger(ULONG_MAX);
- Unsigned.putUnsignedLong(bb, uLongMax);
- for (int i = 0; i < 8; ++i) {
- TestCase.assertTrue("Byte: " + i + " should be 0xff, was: " + bb.get(i),
- (bb.get(i) & (short)0xff) == 0xff);
- }
-
- bb = ByteBuffer.allocate(10);
- Unsigned.putUnsignedLong(bb, uLongMax, 1);
- int offset = 1;
- for (int i = 0; i < 8; ++i) {
- TestCase.assertTrue("Byte: " + i + " should be 0xff, was: " +
- bb.get(offset+i), (bb.get(offset+i) & (short)0xff) == 0xff);
- }
- }
-}