Removed Floodlight storage framework
diff --git a/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java b/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java
index 21788af..a3f3859 100644
--- a/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java
+++ b/src/test/java/net/floodlightcontroller/core/internal/ControllerTest.java
@@ -33,9 +33,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -44,7 +42,6 @@
import net.floodlightcontroller.core.FloodlightProvider;
import net.floodlightcontroller.core.IFloodlightProviderService;
import net.floodlightcontroller.core.IFloodlightProviderService.Role;
-import net.floodlightcontroller.core.IHAListener;
import net.floodlightcontroller.core.IListener.Command;
import net.floodlightcontroller.core.IOFMessageListener;
import net.floodlightcontroller.core.IOFSwitch;
@@ -65,8 +62,6 @@
import net.floodlightcontroller.perfmon.PktInProcessingTime;
import net.floodlightcontroller.restserver.IRestApiService;
import net.floodlightcontroller.restserver.RestApiServer;
-import net.floodlightcontroller.storage.IStorageSourceService;
-import net.floodlightcontroller.storage.memory.MemoryStorageSource;
import net.floodlightcontroller.test.FloodlightTestCase;
import net.floodlightcontroller.threadpool.IThreadPoolService;
import net.onrc.onos.ofcontroller.core.IOFSwitchPortListener;
@@ -121,8 +116,8 @@
controller = (Controller)cm.getServiceImpls().get(IFloodlightProviderService.class);
fmc.addService(IFloodlightProviderService.class, controller);
- MemoryStorageSource memstorage = new MemoryStorageSource();
- fmc.addService(IStorageSourceService.class, memstorage);
+ //MemoryStorageSource memstorage = new MemoryStorageSource();
+ //fmc.addService(IStorageSourceService.class, memstorage);
RestApiServer restApi = new RestApiServer();
fmc.addService(IRestApiService.class, restApi);
@@ -146,13 +141,13 @@
ppt.init(fmc);
restApi.init(fmc);
- memstorage.init(fmc);
+ //memstorage.init(fmc);
cm.init(fmc);
tp.init(fmc);
sr.init(fmc);
ppt.startUp(fmc);
restApi.startUp(fmc);
- memstorage.startUp(fmc);
+ //memstorage.startUp(fmc);
cm.startUp(fmc);
tp.startUp(fmc);
sr.startUp(fmc);
@@ -183,10 +178,12 @@
expect(sw.getId()).andReturn(dpid).anyTimes();
expect(sw.getStringId()).andReturn(dpidString).anyTimes();
- expect(sw.getConnectedSince()).andReturn(new Date());
- Channel channel = createMock(Channel.class);
- expect(sw.getChannel()).andReturn(channel);
- expect(channel.getRemoteAddress()).andReturn(null);
+
+ //Now we don't write to storage these methods aren't called
+ //expect(sw.getConnectedSince()).andReturn(new Date());
+ //Channel channel = createMock(Channel.class);
+ //expect(sw.getChannel()).andReturn(channel);
+ //expect(channel.getRemoteAddress()).andReturn(null);
expect(sw.getCapabilities()).andReturn(0).anyTimes();
expect(sw.getBuffers()).andReturn(0).anyTimes();
@@ -403,21 +400,22 @@
IOFSwitch newsw = createMock(IOFSwitch.class);
expect(newsw.getId()).andReturn(0L).anyTimes();
expect(newsw.getStringId()).andReturn("00:00:00:00:00:00:00").anyTimes();
- expect(newsw.getConnectedSince()).andReturn(new Date());
- Channel channel2 = createMock(Channel.class);
- expect(newsw.getChannel()).andReturn(channel2);
- expect(channel2.getRemoteAddress()).andReturn(null);
- expect(newsw.getPorts()).andReturn(new ArrayList<OFPhysicalPort>());
+ //Now we don't write to storage, these methods aren't called
+ //expect(newsw.getConnectedSince()).andReturn(new Date());
+ //Channel channel2 = createMock(Channel.class);
+ //expect(newsw.getChannel()).andReturn(channel2);
+ //expect(channel2.getRemoteAddress()).andReturn(null);
+ //expect(newsw.getPorts()).andReturn(new ArrayList<OFPhysicalPort>());
expect(newsw.getCapabilities()).andReturn(0).anyTimes();
expect(newsw.getBuffers()).andReturn(0).anyTimes();
expect(newsw.getTables()).andReturn((byte)0).anyTimes();
expect(newsw.getActions()).andReturn(0).anyTimes();
controller.activeSwitches.put(0L, oldsw);
- replay(newsw, channel, channel2);
+ replay(newsw, channel);//, channel2);
controller.addSwitch(newsw);
- verify(newsw, channel, channel2);
+ verify(newsw, channel);//, channel2);
}
@Test
@@ -483,7 +481,7 @@
}
}
-
+ /*
private Map<String,Object> getFakeControllerIPRow(String id, String controllerId,
String type, int number, String discoveredIP ) {
HashMap<String, Object> row = new HashMap<String,Object>();
@@ -494,6 +492,7 @@
row.put(Controller.CONTROLLER_INTERFACE_DISCOVERED_IP, discoveredIP);
return row;
}
+ */
/**
* Test notifications for controller node IP changes. This requires
@@ -507,6 +506,7 @@
*
* @throws Exception
*/
+ /*
@Test
public void testControllerNodeIPChanges() throws Exception {
class DummyHAListener implements IHAListener {
@@ -617,7 +617,9 @@
listener.do_assert(4, expectedCurMap, expectedAddedMap, expectedRemovedMap);
}
}
+ */
+ /*
@Test
public void testGetControllerNodeIPs() {
HashMap<String,String> expectedCurMap = new HashMap<String, String>();
@@ -633,6 +635,7 @@
assertEquals("expectedControllerNodeIPs is not as expected",
expectedCurMap, controller.getControllerNodeIPs());
}
+ */
@Test
public void testSetRoleNull() {
diff --git a/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java b/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java
index be43a8b..6bef8c1 100644
--- a/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java
+++ b/src/test/java/net/floodlightcontroller/core/module/FloodlightTestModuleLoader.java
@@ -4,26 +4,23 @@
import java.util.Collection;
import java.util.Iterator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import net.floodlightcontroller.core.module.FloodlightModuleLoader;
-import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.test.MockFloodlightProvider;
import net.floodlightcontroller.core.test.MockThreadPoolService;
import net.floodlightcontroller.counter.NullCounterStore;
import net.floodlightcontroller.devicemanager.internal.DefaultEntityClassifier;
import net.floodlightcontroller.devicemanager.test.MockDeviceManager;
import net.floodlightcontroller.perfmon.NullPktInProcessingTime;
-import net.floodlightcontroller.storage.memory.MemoryStorageSource;
import net.floodlightcontroller.topology.TopologyManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class FloodlightTestModuleLoader extends FloodlightModuleLoader {
protected final static Logger log = LoggerFactory.getLogger(FloodlightTestModuleLoader.class);
// List of default modules to use unless specified otherwise
- public static final Class<? extends IFloodlightModule> DEFAULT_STORAGE_SOURCE =
- MemoryStorageSource.class;
+ //public static final Class<? extends IFloodlightModule> DEFAULT_STORAGE_SOURCE =
+ //MemoryStorageSource.class;
public static final Class<? extends IFloodlightModule> DEFAULT_FLOODLIGHT_PRPOVIDER =
MockFloodlightProvider.class;
public static final Class<? extends IFloodlightModule> DEFAULT_TOPOLOGY_PROVIDER =
@@ -45,7 +42,7 @@
DEFAULT_MODULE_LIST = new ArrayList<Class<? extends IFloodlightModule>>();
DEFAULT_MODULE_LIST.add(DEFAULT_DEVICE_SERVICE);
DEFAULT_MODULE_LIST.add(DEFAULT_FLOODLIGHT_PRPOVIDER);
- DEFAULT_MODULE_LIST.add(DEFAULT_STORAGE_SOURCE);
+ //DEFAULT_MODULE_LIST.add(DEFAULT_STORAGE_SOURCE);
DEFAULT_MODULE_LIST.add(DEFAULT_TOPOLOGY_PROVIDER);
DEFAULT_MODULE_LIST.add(DEFAULT_COUNTER_STORE);
DEFAULT_MODULE_LIST.add(DEFAULT_THREADPOOL);
diff --git a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java
index 7afb78a..3fccd0f 100644
--- a/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java
+++ b/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceManagerImplTest.java
@@ -18,7 +18,17 @@
package net.floodlightcontroller.devicemanager.internal;
-import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.anyLong;
+import static org.easymock.EasyMock.anyShort;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertArrayEquals;
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,18 +41,17 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import static org.easymock.EasyMock.expectLastCall;
import net.floodlightcontroller.core.IFloodlightProviderService;
import net.floodlightcontroller.core.IOFSwitch;
import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.test.MockFloodlightProvider;
import net.floodlightcontroller.core.test.MockThreadPoolService;
-import net.floodlightcontroller.devicemanager.IDeviceListener;
import net.floodlightcontroller.devicemanager.IDevice;
+import net.floodlightcontroller.devicemanager.IDeviceListener;
+import net.floodlightcontroller.devicemanager.IDeviceService;
import net.floodlightcontroller.devicemanager.IEntityClass;
import net.floodlightcontroller.devicemanager.IEntityClassifierService;
import net.floodlightcontroller.devicemanager.SwitchPort;
-import net.floodlightcontroller.devicemanager.IDeviceService;
import net.floodlightcontroller.devicemanager.SwitchPort.ErrorStatus;
import net.floodlightcontroller.devicemanager.internal.DeviceManagerImpl.ClassState;
import net.floodlightcontroller.devicemanager.test.MockEntityClassifier;
@@ -56,21 +65,18 @@
import net.floodlightcontroller.packet.IPv4;
import net.floodlightcontroller.restserver.IRestApiService;
import net.floodlightcontroller.restserver.RestApiServer;
-import net.floodlightcontroller.storage.IStorageSourceService;
-import net.floodlightcontroller.storage.memory.MemoryStorageSource;
import net.floodlightcontroller.test.FloodlightTestCase;
import net.floodlightcontroller.threadpool.IThreadPoolService;
import net.floodlightcontroller.topology.ITopologyService;
-import static org.junit.Assert.*;
import org.easymock.EasyMock;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openflow.protocol.OFPacketIn;
+import org.openflow.protocol.OFPacketIn.OFPacketInReason;
import org.openflow.protocol.OFPhysicalPort;
import org.openflow.protocol.OFType;
-import org.openflow.protocol.OFPacketIn.OFPacketInReason;
import org.openflow.util.HexString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -89,7 +95,7 @@
private byte[] testARPReplyPacket_3_Serialized;
MockFloodlightProvider mockFloodlightProvider;
DeviceManagerImpl deviceManager;
- MemoryStorageSource storageSource;
+ //MemoryStorageSource storageSource;
FlowReconcileManager flowReconcileMgr;
private IOFSwitch makeSwitchMock(long id) {
@@ -118,8 +124,8 @@
flowReconcileMgr = new FlowReconcileManager();
DefaultEntityClassifier entityClassifier = new DefaultEntityClassifier();
fmc.addService(IDeviceService.class, deviceManager);
- storageSource = new MemoryStorageSource();
- fmc.addService(IStorageSourceService.class, storageSource);
+ //storageSource = new MemoryStorageSource();
+ //fmc.addService(IStorageSourceService.class, storageSource);
fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
fmc.addService(IRestApiService.class, restApi);
fmc.addService(IFlowReconcileService.class, flowReconcileMgr);
@@ -127,11 +133,11 @@
fmc.addService(ITopologyService.class, topology);
tp.init(fmc);
restApi.init(fmc);
- storageSource.init(fmc);
+ //storageSource.init(fmc);
deviceManager.init(fmc);
flowReconcileMgr.init(fmc);
entityClassifier.init(fmc);
- storageSource.startUp(fmc);
+ //storageSource.startUp(fmc);
deviceManager.startUp(fmc);
flowReconcileMgr.startUp(fmc);
tp.startUp(fmc);
diff --git a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java
index 186fd69..4f53342 100644
--- a/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java
+++ b/src/test/java/net/floodlightcontroller/staticflowentry/StaticFlowTests.java
@@ -1,49 +1,16 @@
package net.floodlightcontroller.staticflowentry;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.easymock.Capture;
-import org.easymock.CaptureType;
-import org.junit.Test;
-import org.openflow.protocol.OFFlowMod;
-import org.openflow.protocol.OFMatch;
-import org.openflow.protocol.OFMessage;
-import org.openflow.protocol.OFPort;
-import org.openflow.protocol.action.OFAction;
-import org.openflow.protocol.action.OFActionOutput;
-import org.openflow.util.HexString;
-
-
-import net.floodlightcontroller.core.FloodlightContext;
-import net.floodlightcontroller.core.IFloodlightProviderService.Role;
-import net.floodlightcontroller.core.IOFSwitch;
-import net.floodlightcontroller.core.module.FloodlightModuleContext;
-import net.floodlightcontroller.core.module.FloodlightModuleException;
-import net.floodlightcontroller.core.test.MockFloodlightProvider;
-import net.floodlightcontroller.test.FloodlightTestCase;
-import net.floodlightcontroller.restserver.RestApiServer;
-import net.floodlightcontroller.staticflowentry.StaticFlowEntryPusher;
-import net.floodlightcontroller.storage.IStorageSourceService;
-import net.floodlightcontroller.storage.memory.MemoryStorageSource;
-import static net.floodlightcontroller.staticflowentry.StaticFlowEntryPusher.*;
-import static org.easymock.EasyMock.*;
-
+/*
public class StaticFlowTests extends FloodlightTestCase {
static String TestSwitch1DPID = "00:00:00:00:00:00:00:01";
static int TotalTestRules = 3;
- /***
- * Create TestRuleXXX and the corresponding FlowModXXX
- * for X = 1..3
- */
+ //
+ // Create TestRuleXXX and the corresponding FlowModXXX
+ // for X = 1..3
+ //
static Map<String,Object> TestRule1;
static OFFlowMod FlowMod1;
static {
@@ -332,3 +299,4 @@
assert(staticFlowEntryPusher.entriesFromStorage.containsValue(FlowMod3));
}
}
+*/
diff --git a/src/test/java/net/floodlightcontroller/storage/memory/tests/MemoryStorageTest.java b/src/test/java/net/floodlightcontroller/storage/memory/tests/MemoryStorageTest.java
deleted file mode 100644
index c250066..0000000
--- a/src/test/java/net/floodlightcontroller/storage/memory/tests/MemoryStorageTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford 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 net.floodlightcontroller.storage.memory.tests;
-
-import net.floodlightcontroller.core.module.FloodlightModuleContext;
-import net.floodlightcontroller.restserver.IRestApiService;
-import net.floodlightcontroller.restserver.RestApiServer;
-import net.floodlightcontroller.storage.memory.MemoryStorageSource;
-import net.floodlightcontroller.storage.tests.StorageTest;
-import org.junit.Before;
-
-public class MemoryStorageTest extends StorageTest {
-
- @Before
- public void setUp() throws Exception {
- storageSource = new MemoryStorageSource();
- restApi = new RestApiServer();
- FloodlightModuleContext fmc = new FloodlightModuleContext();
- fmc.addService(IRestApiService.class, restApi);
- restApi.init(fmc);
- storageSource.init(fmc);
- restApi.startUp(fmc);
- storageSource.startUp(fmc);
- super.setUp();
- }
-}
diff --git a/src/test/java/net/floodlightcontroller/storage/tests/StorageTest.java b/src/test/java/net/floodlightcontroller/storage/tests/StorageTest.java
deleted file mode 100644
index 29cc15b..0000000
--- a/src/test/java/net/floodlightcontroller/storage/tests/StorageTest.java
+++ /dev/null
@@ -1,743 +0,0 @@
-/**
-* Copyright 2011, Big Switch Networks, Inc.
-* Originally created by David Erickson, Stanford 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 net.floodlightcontroller.storage.tests;
-
-import static org.easymock.EasyMock.*;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.TimeUnit;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import net.floodlightcontroller.restserver.RestApiServer;
-import net.floodlightcontroller.storage.CompoundPredicate;
-import net.floodlightcontroller.storage.IStorageExceptionHandler;
-import net.floodlightcontroller.storage.IPredicate;
-import net.floodlightcontroller.storage.IQuery;
-import net.floodlightcontroller.storage.IResultSet;
-import net.floodlightcontroller.storage.IRowMapper;
-import net.floodlightcontroller.storage.IStorageSourceListener;
-import net.floodlightcontroller.storage.NullValueStorageException;
-import net.floodlightcontroller.storage.OperatorPredicate;
-import net.floodlightcontroller.storage.RowOrdering;
-import net.floodlightcontroller.storage.nosql.NoSqlStorageSource;
-import net.floodlightcontroller.test.FloodlightTestCase;
-
-import org.junit.Test;
-
-public abstract class StorageTest extends FloodlightTestCase {
-
- protected NoSqlStorageSource storageSource;
- protected RestApiServer restApi;
-
- protected String PERSON_TABLE_NAME = "Person";
-
- protected String PERSON_SSN = "SSN";
- protected String PERSON_FIRST_NAME = "FirstName";
- protected String PERSON_LAST_NAME = "LastName";
- protected String PERSON_AGE = "Age";
- protected String PERSON_REGISTERED = "Registered";
-
- protected String[] PERSON_COLUMN_LIST = {PERSON_SSN, PERSON_FIRST_NAME, PERSON_LAST_NAME, PERSON_AGE, PERSON_REGISTERED};
-
- class Person {
- private String ssn;
- private String firstName;
- private String lastName;
- int age;
- boolean registered;
-
- public Person(String ssn, String firstName, String lastName, int age, boolean registered) {
- this.ssn = ssn;
- this.firstName = firstName;
- this.lastName = lastName;
- this.age = age;
- this.registered = registered;
- }
-
- public String getSSN() {
- return ssn;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public String getLastName() {
- return lastName;
-
- }
-
- public int getAge() {
- return age;
- }
-
- public boolean isRegistered() {
- return registered;
- }
- }
-
- class PersonRowMapper implements IRowMapper {
- public Object mapRow(IResultSet resultSet) {
- String ssn = resultSet.getString(PERSON_SSN);
- String firstName = resultSet.getString(PERSON_FIRST_NAME);
- String lastName = resultSet.getString(PERSON_LAST_NAME);
- int age = resultSet.getInt(PERSON_AGE);
- boolean registered = resultSet.getBoolean(PERSON_REGISTERED);
- return new Person(ssn, firstName, lastName, age, registered);
- }
- }
-
- Object[][] PERSON_INIT_DATA = {
- {"111-11-1111", "John", "Smith", 40, true},
- {"222-22-2222", "Jim", "White", 24, false},
- {"333-33-3333", "Lisa", "Jones", 27, true},
- {"444-44-4444", "Susan", "Jones", 14, false},
- {"555-55-5555", "Jose", "Garcia", 31, true},
- {"666-66-6666", "Abigail", "Johnson", 35, false},
- {"777-77-7777", "Bjorn", "Borg", 55, true},
- {"888-88-8888", "John", "McEnroe", 53, false}
- };
-
- Map<String,Object> createPersonRowValues(Object[] personData) {
- Map<String,Object> rowValues = new HashMap<String,Object>();
- for (int i = 0; i < PERSON_COLUMN_LIST.length; i++) {
- rowValues.put(PERSON_COLUMN_LIST[i], personData[i]);
- }
- return rowValues;
- }
-
- public void insertPerson(Object[] personData) {
- Map<String,Object> rowValues = createPersonRowValues(personData);
- storageSource.insertRow(PERSON_TABLE_NAME, rowValues);
- }
-
- public void initPersons() {
- for (Object[] row: PERSON_INIT_DATA) {
- insertPerson(row);
- }
- }
-
- public void setUp() throws Exception {
- super.setUp();
- Set<String> indexedColumnNames = new HashSet<String>();
- indexedColumnNames.add(PERSON_LAST_NAME);
- storageSource.setExceptionHandler(null);
- storageSource.createTable(PERSON_TABLE_NAME, indexedColumnNames);
- storageSource.setTablePrimaryKeyName(PERSON_TABLE_NAME, PERSON_SSN);
- initPersons();
- }
-
- public void checkExpectedResults(IResultSet resultSet, String[] columnNameList, Object[][] expectedRowList) {
- boolean nextResult;
- for (Object[] expectedRow: expectedRowList) {
- nextResult = resultSet.next();
- assertEquals(nextResult,true);
- assertEquals(expectedRow.length, columnNameList.length);
- for (int i = 0; i < expectedRow.length; i++) {
- Object expectedObject = expectedRow[i];
- String columnName = columnNameList[i];
- if (expectedObject instanceof Boolean)
- assertEquals(((Boolean)expectedObject).booleanValue(), resultSet.getBoolean(columnName));
- else if (expectedObject instanceof Byte)
- assertEquals(((Byte)expectedObject).byteValue(), resultSet.getByte(columnName));
- else if (expectedObject instanceof Short)
- assertEquals(((Short)expectedObject).shortValue(), resultSet.getShort(columnName));
- else if (expectedObject instanceof Integer)
- assertEquals(((Integer)expectedObject).intValue(), resultSet.getInt(columnName));
- else if (expectedObject instanceof Long)
- assertEquals(((Long)expectedObject).longValue(), resultSet.getLong(columnName));
- else if (expectedObject instanceof Float)
- assertEquals(((Float)expectedObject).floatValue(), resultSet.getFloat(columnName), 0.00001);
- else if (expectedObject instanceof Double)
- assertEquals(((Double)expectedObject).doubleValue(), resultSet.getDouble(columnName), 0.00001);
- else if (expectedObject instanceof byte[])
- assertEquals((byte[])expectedObject, resultSet.getByteArray(columnName));
- else if (expectedObject instanceof String)
- assertEquals((String)expectedObject, resultSet.getString(columnName));
- else
- assertTrue("Unexpected column value type", false);
- }
- }
- nextResult = resultSet.next();
- assertEquals(nextResult,false);
- resultSet.close();
- }
-
- @Test
- public void testInsertRows() {
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, null, new RowOrdering(PERSON_SSN));
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, PERSON_INIT_DATA);
- }
-
- @Test
- public void testOperatorQuery() {
- Object[][] expectedResults = {
- {"John", "Smith", 40},
- {"Jim", "White", 24},
- };
- String[] columnList = {PERSON_FIRST_NAME,PERSON_LAST_NAME,PERSON_AGE};
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, columnList,
- new OperatorPredicate(PERSON_LAST_NAME, OperatorPredicate.Operator.GTE, "Sm"),
- new RowOrdering(PERSON_SSN));
- checkExpectedResults(resultSet, columnList, expectedResults);
- }
-
- @Test
- public void testAndQuery() {
- String[] columnList = {PERSON_FIRST_NAME,PERSON_LAST_NAME};
- Object[][] expectedResults = {
- {"Lisa", "Jones"},
- {"Susan", "Jones"},
- {"Jose", "Garcia"},
- {"Abigail", "Johnson"},
- {"John", "McEnroe"}
- };
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, columnList,
- new CompoundPredicate(CompoundPredicate.Operator.AND, false,
- new OperatorPredicate(PERSON_LAST_NAME, OperatorPredicate.Operator.GTE, "G"),
- new OperatorPredicate(PERSON_LAST_NAME, OperatorPredicate.Operator.LT, "N")
- ),
- new RowOrdering(PERSON_SSN));
- checkExpectedResults(resultSet, columnList, expectedResults);
- }
-
- @Test
- public void testOrQuery() {
- String[] columnList = {PERSON_FIRST_NAME,PERSON_LAST_NAME, PERSON_AGE};
- Object[][] expectedResults = {
- {"John", "Smith", 40},
- {"Lisa", "Jones", 27},
- {"Abigail", "Johnson", 35},
- {"Bjorn", "Borg", 55},
- {"John", "McEnroe", 53}
- };
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, columnList,
- new CompoundPredicate(CompoundPredicate.Operator.OR, false,
- new OperatorPredicate(PERSON_AGE, OperatorPredicate.Operator.GTE, 35),
- new OperatorPredicate(PERSON_FIRST_NAME, OperatorPredicate.Operator.EQ, "Lisa")
- ),
- new RowOrdering(PERSON_SSN));
- checkExpectedResults(resultSet, columnList, expectedResults);
-}
-
- @Test
- public void testCreateQuery() {
- String[] columnList = {PERSON_FIRST_NAME,PERSON_LAST_NAME};
- Object[][] expectedResults = {
- {"Lisa", "Jones"},
- {"Susan", "Jones"}
- };
- IPredicate predicate = new OperatorPredicate(PERSON_LAST_NAME, OperatorPredicate.Operator.EQ, "Jones");
- IQuery query = storageSource.createQuery(PERSON_TABLE_NAME, columnList, predicate, new RowOrdering(PERSON_SSN));
- IResultSet resultSet = storageSource.executeQuery(query);
- checkExpectedResults(resultSet, columnList, expectedResults);
- }
-
- @Test
- public void testQueryParameters() {
- String[] columnList = {PERSON_FIRST_NAME,PERSON_LAST_NAME, PERSON_AGE};
- Object[][] expectedResults = {
- {"John", "Smith", 40},
- {"Bjorn", "Borg", 55},
- {"John", "McEnroe", 53}
- };
- IPredicate predicate = new OperatorPredicate(PERSON_AGE, OperatorPredicate.Operator.GTE, "?MinimumAge?");
- IQuery query = storageSource.createQuery(PERSON_TABLE_NAME, columnList, predicate, new RowOrdering(PERSON_SSN));
- query.setParameter("MinimumAge", 40);
- IResultSet resultSet = storageSource.executeQuery(query);
- checkExpectedResults(resultSet, columnList, expectedResults);
- }
-
- private void checkPerson(Person person, Object[] expectedValues) {
- assertEquals(person.getSSN(), expectedValues[0]);
- assertEquals(person.getFirstName(), expectedValues[1]);
- assertEquals(person.getLastName(), expectedValues[2]);
- assertEquals(person.getAge(), expectedValues[3]);
- assertEquals(person.isRegistered(), expectedValues[4]);
- }
-
- @Test
- public void testRowMapper() {
- Object[][] expectedResults = {
- PERSON_INIT_DATA[2],
- PERSON_INIT_DATA[3]
- };
- IPredicate predicate = new OperatorPredicate(PERSON_LAST_NAME, OperatorPredicate.Operator.EQ, "Jones");
- IRowMapper rowMapper = new PersonRowMapper();
- Object[] personList = storageSource.executeQuery(PERSON_TABLE_NAME, null, predicate, new RowOrdering(PERSON_SSN), rowMapper);
- assertEquals(personList.length, 2);
- for (int i = 0; i < personList.length; i++)
- checkPerson((Person)personList[i], expectedResults[i]);
- }
-
- @Test
- public void testDeleteRowsDirect() {
-
- storageSource.deleteRow(PERSON_TABLE_NAME, "111-11-1111");
- storageSource.deleteRow(PERSON_TABLE_NAME, "222-22-2222");
- storageSource.deleteRow(PERSON_TABLE_NAME, "333-33-3333");
- storageSource.deleteRow(PERSON_TABLE_NAME, "444-44-4444");
-
- Object[][] expectedResults = {
- {"555-55-5555", "Jose", "Garcia", 31, true},
- {"666-66-6666", "Abigail", "Johnson", 35, false},
- {"777-77-7777", "Bjorn", "Borg", 55, true},
- {"888-88-8888", "John", "McEnroe", 53, false}
- };
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, PERSON_COLUMN_LIST, null, new RowOrdering(PERSON_SSN));
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedResults);
- }
-
- @Test
- public void testDeleteRowsFromResultSet() {
- Object[][] expectedResults = {
- {"555-55-5555", "Jose", "Garcia", 31, true},
- {"666-66-6666", "Abigail", "Johnson", 35, false},
- {"777-77-7777", "Bjorn", "Borg", 55, true},
- {"888-88-8888", "John", "McEnroe", 53, false}
- };
-
- // Query once to delete the rows
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, PERSON_COLUMN_LIST, null, new RowOrdering(PERSON_SSN));
- for (int i = 0; i < 4; i++) {
- resultSet.next();
- resultSet.deleteRow();
- }
- resultSet.save();
- resultSet.close();
-
- // Now query again to verify that the rows were deleted
- resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, PERSON_COLUMN_LIST, null, new RowOrdering(PERSON_SSN));
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedResults);
- }
-
- @Test
- public void testDeleteMatchingRows() {
- Object[][] expectedResults = {
- {"111-11-1111", "John", "Smith", 40, true},
- {"777-77-7777", "Bjorn", "Borg", 55, true},
- {"888-88-8888", "John", "McEnroe", 53, false}
- };
- storageSource.deleteMatchingRows(PERSON_TABLE_NAME, new OperatorPredicate(PERSON_AGE, OperatorPredicate.Operator.LT, 40));
-
- // Now query again to verify that the rows were deleted
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, PERSON_COLUMN_LIST, null, new RowOrdering(PERSON_SSN));
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedResults);
-
- storageSource.deleteMatchingRows(PERSON_TABLE_NAME, null);
-
- // Now query again to verify that all rows were deleted
- resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, PERSON_COLUMN_LIST, null, new RowOrdering(PERSON_SSN));
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, new Object[0][]);
- }
-
- @Test
- public void testUpdateRowsDirect() {
-
- Object[][] expectedResults = {
- {"777-77-7777", "Tennis", "Borg", 60, true},
- {"888-88-8888", "Tennis", "McEnroe", 60, false}
- };
- Map<String,Object> updateValues = new HashMap<String,Object>();
- updateValues.put(PERSON_FIRST_NAME, "Tennis");
- updateValues.put(PERSON_AGE, 60);
-
- IPredicate predicate = new OperatorPredicate(PERSON_AGE, OperatorPredicate.Operator.GT, 50);
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, predicate, new RowOrdering(PERSON_SSN));
- while (resultSet.next()) {
- String key = resultSet.getString(PERSON_SSN);
- storageSource.updateRow(PERSON_TABLE_NAME, key, updateValues);
- }
- resultSet.close();
-
- resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, PERSON_COLUMN_LIST, predicate, new RowOrdering(PERSON_SSN));
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedResults);
- }
-
- @Test
- public void testUpdateRowsFromResultSet() {
-
- Object[][] expectedResults = {
- {"777-77-7777", "Tennis", "Borg", 60, true},
- {"888-88-8888", "Tennis", "McEnroe", 60, false}
- };
-
- IPredicate predicate = new OperatorPredicate(PERSON_AGE, OperatorPredicate.Operator.GT, 50);
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, predicate, null);
- while (resultSet.next()) {
- resultSet.setString(PERSON_FIRST_NAME, "Tennis");
- resultSet.setInt(PERSON_AGE, 60);
- }
- resultSet.save();
- resultSet.close();
-
- resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, PERSON_COLUMN_LIST, predicate, new RowOrdering(PERSON_SSN));
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedResults);
- }
-
- @Test
- public void testNullValues() {
-
- IPredicate predicate = new OperatorPredicate(PERSON_LAST_NAME, OperatorPredicate.Operator.EQ, "Jones");
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, predicate, new RowOrdering(PERSON_SSN));
- while (resultSet.next()) {
- resultSet.setNull(PERSON_FIRST_NAME);
- resultSet.setIntegerObject(PERSON_AGE, null);
- }
- resultSet.save();
- resultSet.close();
-
- resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, predicate, new RowOrdering(PERSON_SSN));
- int count = 0;
- while (resultSet.next()) {
- boolean checkNull = resultSet.isNull(PERSON_FIRST_NAME);
- assertTrue(checkNull);
- String s = resultSet.getString(PERSON_FIRST_NAME);
- assertEquals(s, null);
- checkNull = resultSet.isNull(PERSON_AGE);
- assertTrue(checkNull);
- Integer intObj = resultSet.getIntegerObject(PERSON_AGE);
- assertEquals(intObj, null);
- Short shortObj = resultSet.getShortObject(PERSON_AGE);
- assertEquals(shortObj, null);
- boolean excThrown = false;
- try {
- resultSet.getInt(PERSON_AGE);
- }
- catch (NullValueStorageException exc) {
- excThrown = true;
- }
- assertTrue(excThrown);
- count++;
- }
- resultSet.close();
- assertEquals(count, 2);
-
- predicate = new OperatorPredicate(PERSON_FIRST_NAME, OperatorPredicate.Operator.EQ, null);
- resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, predicate, new RowOrdering(PERSON_SSN));
- count = 0;
- while (resultSet.next()) {
- boolean checkNull = resultSet.isNull(PERSON_FIRST_NAME);
- assertTrue(checkNull);
- count++;
- checkNull = resultSet.isNull(PERSON_AGE);
- assertTrue(checkNull);
- }
- resultSet.close();
- assertEquals(count, 2);
- }
-
- @Test
- public void testInsertNotification() {
- // Set up the listener and record the expected notification
- IStorageSourceListener mockListener = createNiceMock(IStorageSourceListener.class);
- Set<Object> expectedKeys = new HashSet<Object>();
- expectedKeys.add("999-99-9999");
- mockListener.rowsModified(PERSON_TABLE_NAME, expectedKeys);
-
- replay(mockListener);
-
- // Now try it for real
- storageSource.addListener(PERSON_TABLE_NAME, mockListener);
-
- // Create a new person, which should trigger the listener
- Object[] newPerson = {"999-99-9999", "Serena", "Williams", 22, true};
- insertPerson(newPerson);
-
- verify(mockListener);
- }
-
- @Test
- public void testUpdateNotification() {
- // Set up the listener and record the expected notification
- IStorageSourceListener mockListener = createNiceMock(IStorageSourceListener.class);
- Set<Object> expectedKeys = new HashSet<Object>();
- expectedKeys.add("111-11-1111");
- mockListener.rowsModified(PERSON_TABLE_NAME, expectedKeys);
-
- replay(mockListener);
-
- // Now try it for real
- storageSource.addListener(PERSON_TABLE_NAME, mockListener);
-
- // Create a new person, which should trigger the listener
- Map<String,Object> updateValues = new HashMap<String,Object>();
- updateValues.put(PERSON_FIRST_NAME, "Tennis");
- storageSource.updateRow(PERSON_TABLE_NAME, "111-11-1111", updateValues);
-
- verify(mockListener);
- }
-
- @Test
- public void testDeleteNotification() {
- IStorageSourceListener mockListener = createNiceMock(IStorageSourceListener.class);
- Set<Object> expectedKeys = new HashSet<Object>();
- expectedKeys.add("111-11-1111");
- mockListener.rowsDeleted(PERSON_TABLE_NAME, expectedKeys);
-
- replay(mockListener);
-
- // Now try it for real
- storageSource.addListener(PERSON_TABLE_NAME, mockListener);
-
- // Create a new person, which should trigger the listener
- storageSource.deleteRow(PERSON_TABLE_NAME, "111-11-1111");
-
- verify(mockListener);
- }
-
- public void waitForFuture(Future<?> future) {
- try
- {
- future.get(10, TimeUnit.SECONDS);
- }
- catch (InterruptedException exc)
- {
- fail("Async storage operation interrupted");
- }
- catch (ExecutionException exc) {
- fail("Async storage operation failed");
- }
- catch (TimeoutException exc) {
- fail("Async storage operation timed out");
- }
- }
-
- @Test
- public void testAsyncQuery1() {
- Object[][] expectedResults = {
- {"John", "Smith", 40},
- {"Jim", "White", 24},
- };
- String[] columnList = {PERSON_FIRST_NAME,PERSON_LAST_NAME,PERSON_AGE};
- IPredicate predicate = new OperatorPredicate(PERSON_LAST_NAME, OperatorPredicate.Operator.GTE, "Sm");
- IQuery query = storageSource.createQuery(PERSON_TABLE_NAME, columnList, predicate, new RowOrdering(PERSON_SSN));
- Future<IResultSet> future = storageSource.executeQueryAsync(query);
- waitForFuture(future);
- try {
- IResultSet resultSet = future.get();
- checkExpectedResults(resultSet, columnList, expectedResults);
- }
- catch (Exception e) {
- fail("Exception thrown in async storage operation: " + e.toString());
- }
- }
-
- @Test
- public void testAsyncQuery2() {
- Object[][] expectedResults = {
- {"John", "Smith", 40},
- {"Jim", "White", 24},
- };
- String[] columnList = {PERSON_FIRST_NAME,PERSON_LAST_NAME,PERSON_AGE};
- IPredicate predicate = new OperatorPredicate(PERSON_LAST_NAME, OperatorPredicate.Operator.GTE, "Sm");
- Future<IResultSet> future = storageSource.executeQueryAsync(PERSON_TABLE_NAME,
- columnList, predicate, new RowOrdering(PERSON_SSN));
- waitForFuture(future);
- try {
- IResultSet resultSet = future.get();
- checkExpectedResults(resultSet, columnList, expectedResults);
- }
- catch (Exception e) {
- fail("Exception thrown in async storage operation: " + e.toString());
- }
- }
-
- @Test
- public void testAsyncQuery3() {
- Object[][] expectedResults = {
- PERSON_INIT_DATA[2],
- PERSON_INIT_DATA[3]
- };
- IPredicate predicate = new OperatorPredicate(PERSON_LAST_NAME, OperatorPredicate.Operator.EQ, "Jones");
- IRowMapper rowMapper = new PersonRowMapper();
- Future<Object[]> future = storageSource.executeQueryAsync(PERSON_TABLE_NAME,
- null, predicate, new RowOrdering(PERSON_SSN), rowMapper);
- waitForFuture(future);
- try {
- Object[] personList = future.get();
- assertEquals(personList.length, 2);
- for (int i = 0; i < personList.length; i++)
- checkPerson((Person)personList[i], expectedResults[i]);
- }
- catch (Exception e) {
- fail("Exception thrown in async storage operation: " + e.toString());
- }
- }
-
- @Test
- public void testAsyncException() {
- class TestExceptionHandler implements IStorageExceptionHandler {
- public int exceptionCount = 0;
- @Override
- public void handleException(Exception exception) {
- exceptionCount++;
- }
- }
- TestExceptionHandler exceptionHandler = new TestExceptionHandler();
- storageSource.setExceptionHandler(exceptionHandler);
-
- // Use an invalid table name, which should cause the storage API call to throw
- // an exception, which should then be converted to an ExecutionException.
- Future<IResultSet> future = storageSource.executeQueryAsync("InvalidTableName",
- null, null, null);
- try {
- future.get(10, TimeUnit.SECONDS);
- fail("Expected ExecutionException was not thrown");
- }
- catch (ExecutionException e) {
- assertTrue(true);
- }
- catch (Exception e) {
- fail("Exception thrown in async storage operation: " + e.toString());
- }
- assertEquals(exceptionHandler.exceptionCount, 1);
- }
-
- @Test
- public void testAsyncInsertRow() {
- Object[][] newPersonInfo = {{"999-99-9999", "Ellen", "Wilson", 40, true}};
- Map<String,Object> rowValues = createPersonRowValues(newPersonInfo[0]);
- Future<?> future = storageSource.insertRowAsync(PERSON_TABLE_NAME, rowValues);
- waitForFuture(future);
- try {
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, null, new RowOrdering(PERSON_SSN));
- Object[][] expectedPersons = Arrays.copyOf(PERSON_INIT_DATA, PERSON_INIT_DATA.length + newPersonInfo.length);
- System.arraycopy(newPersonInfo, 0, expectedPersons, PERSON_INIT_DATA.length, newPersonInfo.length);
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedPersons);
- }
- catch (Exception e) {
- fail("Exception thrown in async storage operation: " + e.toString());
- }
- }
-
- @Test
- public void testAsyncUpdateRow() {
- Map<String,Object> updateValues = new HashMap<String,Object>();
- updateValues.put(PERSON_SSN, "777-77-7777");
- updateValues.put(PERSON_FIRST_NAME, "Tennis");
- updateValues.put(PERSON_AGE, 60);
-
- Future<?> future = storageSource.updateRowAsync(PERSON_TABLE_NAME, updateValues);
- waitForFuture(future);
-
- try {
- IResultSet resultSet = storageSource.getRow(PERSON_TABLE_NAME, "777-77-7777");
- Object[][] expectedPersons = {{"777-77-7777", "Tennis", "Borg", 60, true}};
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedPersons);
- }
- catch (Exception e) {
- fail("Exception thrown in async storage operation: " + e.toString());
- }
- }
-
- @Test
- public void testAsyncUpdateRow2() {
- Map<String,Object> updateValues = new HashMap<String,Object>();
- updateValues.put(PERSON_FIRST_NAME, "Tennis");
- updateValues.put(PERSON_AGE, 60);
-
- Future<?> future = storageSource.updateRowAsync(PERSON_TABLE_NAME, "777-77-7777", updateValues);
- waitForFuture(future);
-
- try {
- IResultSet resultSet = storageSource.getRow(PERSON_TABLE_NAME, "777-77-7777");
- Object[][] expectedPersons = {{"777-77-7777", "Tennis", "Borg", 60, true}};
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedPersons);
- }
- catch (Exception e) {
- fail("Exception thrown in async storage operation: " + e.toString());
- }
- }
-
- @Test
- public void testAsyncUpdateMatchingRows() {
- Map<String,Object> updateValues = new HashMap<String,Object>();
- updateValues.put(PERSON_FIRST_NAME, "Tennis");
- updateValues.put(PERSON_AGE, 60);
-
- IPredicate predicate = new OperatorPredicate(PERSON_SSN, OperatorPredicate.Operator.EQ, "777-77-7777");
- Future<?> future = storageSource.updateMatchingRowsAsync(PERSON_TABLE_NAME, predicate, updateValues);
- waitForFuture(future);
- try {
- IResultSet resultSet = storageSource.getRow(PERSON_TABLE_NAME, "777-77-7777");
- Object[][] expectedPersons = {{"777-77-7777", "Tennis", "Borg", 60, true}};
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedPersons);
- }
- catch (Exception e) {
- fail("Exception thrown in async storage operation: " + e.toString());
- }
- }
-
- @Test
- public void testAsyncDeleteRow() {
- Future<?> future = storageSource.deleteRowAsync(PERSON_TABLE_NAME, "111-11-1111");
- waitForFuture(future);
- try {
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, null, new RowOrdering(PERSON_SSN));
- Object[][] expectedPersons = Arrays.copyOfRange(PERSON_INIT_DATA, 1, PERSON_INIT_DATA.length);
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedPersons);
- }
- catch (Exception e) {
- fail("Exception thrown in async storage operation: " + e.toString());
- }
- }
-
- @Test
- public void testAsyncDeleteMatchingRows() {
- Future<?> future = storageSource.deleteMatchingRowsAsync(PERSON_TABLE_NAME, null);
- waitForFuture(future);
- try {
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, null, new RowOrdering(PERSON_SSN));
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, new Object[0][]);
- }
- catch (Exception e) {
- fail("Exception thrown in async storage operation: " + e.toString());
- }
- }
-
- @Test
- public void testAsyncSave() {
- // Get a result set and make some changes to it
- IResultSet resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, null, new RowOrdering(PERSON_SSN));
- resultSet.next();
- resultSet.deleteRow();
- resultSet.next();
- resultSet.setString(PERSON_FIRST_NAME, "John");
-
- Future<?> future = storageSource.saveAsync(resultSet);
- waitForFuture(future);
- try {
- resultSet = storageSource.executeQuery(PERSON_TABLE_NAME, null, null, new RowOrdering(PERSON_SSN));
- Object[][] expectedPersons = Arrays.copyOfRange(PERSON_INIT_DATA, 1, PERSON_INIT_DATA.length);
- expectedPersons[0][1] = "John";
- checkExpectedResults(resultSet, PERSON_COLUMN_LIST, expectedPersons);
- }
- catch (Exception e) {
- fail("Exception thrown in async storage operation: " + e.toString());
- }
-
- }
-}
diff --git a/src/test/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java b/src/test/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
index c3647f2..b2689a4 100644
--- a/src/test/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
+++ b/src/test/java/net/onrc/onos/ofcontroller/linkdiscovery/internal/LinkDiscoveryManagerTest.java
@@ -17,19 +17,16 @@
package net.onrc.onos.ofcontroller.linkdiscovery.internal;
-import static org.easymock.EasyMock.*;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
-import java.util.Collections;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import net.floodlightcontroller.core.IFloodlightProviderService;
import net.floodlightcontroller.core.IFloodlightProviderService.Role;
import net.floodlightcontroller.core.IOFSwitch;
@@ -39,8 +36,6 @@
import net.floodlightcontroller.restserver.RestApiServer;
import net.floodlightcontroller.routing.IRoutingService;
import net.floodlightcontroller.routing.Link;
-import net.floodlightcontroller.storage.IStorageSourceService;
-import net.floodlightcontroller.storage.memory.MemoryStorageSource;
import net.floodlightcontroller.test.FloodlightTestCase;
import net.floodlightcontroller.threadpool.IThreadPoolService;
import net.floodlightcontroller.topology.ITopologyService;
@@ -49,7 +44,11 @@
import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryListener;
import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryService;
import net.onrc.onos.ofcontroller.linkdiscovery.LinkInfo;
-import net.onrc.onos.ofcontroller.linkdiscovery.internal.LinkDiscoveryManager;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
*
@@ -75,11 +74,12 @@
isClearLinksCalled = false;
}
+ /*
@Override
protected void clearAllLinks() {
isClearLinksCalled = true;
super.clearAllLinks();
- }
+ }*/
}
public LinkDiscoveryManager getTopology() {
@@ -106,7 +106,7 @@
cntx.addService(IRoutingService.class, routingEngine);
cntx.addService(ILinkDiscoveryService.class, ldm);
cntx.addService(ITopologyService.class, ldm);
- cntx.addService(IStorageSourceService.class, new MemoryStorageSource());
+ //cntx.addService(IStorageSourceService.class, new MemoryStorageSource());
cntx.addService(IFloodlightProviderService.class, getMockFloodlightProvider());
restApi.init(cntx);
tp.init(cntx);
@@ -426,7 +426,7 @@
getMockFloodlightProvider().dispatchRoleChanged(Role.SLAVE, Role.MASTER);
// check that lldps were sent
assertTrue(ldm.isSendLLDPsCalled);
- assertTrue(ldm.isClearLinksCalled);
+ //assertTrue(ldm.isClearLinksCalled);
ldm.reset();
}
}