?? deviceregistrytests.java
字號:
/**
* Copyright (c) 2003-2006 Craig Setera
* All Rights Reserved.
* Licensed under the Eclipse Public License - v 1.0
* For more information see http://www.eclipse.org/legal/epl-v10.html
*/
package eclipseme.core.model;
import java.util.List;
import eclipseme.core.model.device.DeviceRegistry;
import eclipseme.core.model.device.IDevice;
import eclipseme.core.model.device.IDeviceRegistryListener;
/**
* Type description
* <p />
* Copyright (c) 2003-2006 Craig Setera<br>
* All Rights Reserved.<br>
* Licensed under the Eclipse Public License - v 1.0<p/>
* <br>
* $Revision: 1.1 $
* <br>
* $Date: 2006/02/11 21:26:56 $
* <br>
* @author Craig Setera
*/
public class DeviceRegistryTests extends AbstractCoreTestCase {
private class DeviceRegistryListener implements IDeviceRegistryListener
{
public IDevice lastAdded;
public IDevice lastRemoved;
public void deviceAdded(IDevice device) {
lastAdded = device;
}
public void deviceRemoved(IDevice device) {
lastRemoved = device;
}
}
public void testDeviceRegistryBasics()
throws Exception
{
DeviceRegistry registry = DeviceRegistry.singleton;
DeviceRegistryListener listener = new DeviceRegistryListener();
registry.addRegistryListener(listener);
IDevice[] testDevices = getTestDevices();
for (int i = 0; i < testDevices.length; i++) {
IDevice device = testDevices[i];
registry.addDevice(device);
assertEquals(
"Expected the listener to return same object as added",
device,
listener.lastAdded);
IDevice queried = registry.getDevice(device.getGroupName(), device.getName());
assertEquals("Expected to find the same object as added", device, queried);
}
List groups = registry.getDeviceGroups();
assertTrue("Expected to find device group", groups.contains(testDevices[0].getGroupName()));
List groupDeviceList = registry.getDevices(testDevices[0].getGroupName());
assertEquals("Expected the same number of devices", testDevices.length, groupDeviceList.size());
for (int i = 0; i < testDevices.length; i++) {
IDevice device = testDevices[i];
registry.removeDevice(device);
assertEquals(
"Expected the listener to return same object as removed",
device,
listener.lastRemoved);
IDevice queried = registry.getDevice(device.getGroupName(), device.getName());
assertNull("Expected to not find the removed object", queried);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -