Renamed datagrid and datastore packages
net.onrc.onos.datagrid.* => net.onrc.onos.core.datagrid.*
net.onrc.onos.datastore.* => net.onrc.onos.core.datastore.*
Change-Id: Ibe1894a6fabae08ea7cfcbf6595f0c91b05ef497
diff --git a/src/test/java/net/onrc/onos/core/datastore/topology/KVSwitchNoDataStoreTest.java b/src/test/java/net/onrc/onos/core/datastore/topology/KVSwitchNoDataStoreTest.java
new file mode 100644
index 0000000..eec4a47
--- /dev/null
+++ b/src/test/java/net/onrc/onos/core/datastore/topology/KVSwitchNoDataStoreTest.java
@@ -0,0 +1,84 @@
+package net.onrc.onos.core.datastore.topology;
+
+import static org.junit.Assert.*;
+
+import java.nio.ByteBuffer;
+
+import net.onrc.onos.core.datastore.topology.KVSwitch;
+import net.onrc.onos.core.datastore.topology.KVSwitch.STATUS;
+
+import org.junit.Test;
+
+public class KVSwitchNoDataStoreTest {
+
+ @Test
+ public void testGetDpidFromKeyByteArray() {
+ // reference bytes
+ final byte[] key = KVSwitch.getSwitchID(0x1L);
+
+ assertEquals(0x1L, KVSwitch.getDpidFromKey(key));
+ }
+
+ @Test
+ public void testGetDpidFromKeyByteBuffer() {
+ // reference bytes
+ final ByteBuffer key = ByteBuffer.wrap(KVSwitch.getSwitchID(0x1L));
+
+ assertEquals(0x1L, KVSwitch.getDpidFromKey(key));
+ }
+
+ @Test
+ public void testCreateFromKeyByteArray() {
+ // reference bytes
+ Long dpid = Long.valueOf(0x1L);
+ final byte[] key = KVSwitch.getSwitchID(dpid);
+
+ KVSwitch sw = KVSwitch.createFromKey(key);
+ assertNotNull(sw);
+ assertEquals(dpid, sw.getDpid());
+ }
+
+ @Test
+ public void testGetStatus() {
+ KVSwitch sw = new KVSwitch(0x1L);
+
+ assertEquals(STATUS.INACTIVE, sw.getStatus());
+ }
+
+ @Test
+ public void testSetStatus() {
+ KVSwitch sw = new KVSwitch(0x1L);
+ assertEquals(STATUS.INACTIVE, sw.getStatus());
+
+ sw.setStatus(STATUS.ACTIVE);
+ assertEquals(STATUS.ACTIVE, sw.getStatus());
+ }
+
+ @Test
+ public void testGetDpid() {
+ Long dpid = 0x1L;
+ KVSwitch sw = new KVSwitch(dpid);
+ assertEquals(dpid, sw.getDpid());
+ }
+
+ @Test
+ public void testGetId() {
+ // reference bytes
+ Long dpid = Long.valueOf(0x1L);
+ final byte[] key = KVSwitch.getSwitchID(dpid);
+
+ KVSwitch sw = KVSwitch.createFromKey(key);
+ assertArrayEquals(key, sw.getId());
+ }
+
+ @Test
+ public void testToString() {
+ final String expected = "[" + "KVSwitch"
+ + " 0x" + 1 + " STATUS:" + STATUS.INACTIVE + "]";
+
+ Long dpid = 0x1L;
+ KVSwitch sw = new KVSwitch(dpid);
+
+ assertEquals(expected, sw.toString());
+ }
+}