public void testMoveDevice() throws Throwable {
TemporaryFileManager manager = new TemporaryFileManager(
new TestDeviceRepositoryCreator());
manager.executeWith(new TemporaryFileExecutor() {
public void execute(File repository) throws Exception {
EclipseDeviceRepository accessor = new
EclipseDeviceRepository(repository.getPath(),
transformerMetaFactory, jdomFactory, false, true, null);
// move the PC device to TV
Element pc = null;
try {
pc = (Element) PrivateAccessor.invoke(
accessor,
"getHierarchyDeviceElement",
new Class[]{String.class},
new String[]{"PC"});
} catch (Throwable throwable) {
throw new Exception(throwable);
}
// check that the TV device is not already the parent of the PC
assertNotEquals(pc.getParent().getAttributeValue(
DeviceRepositorySchemaConstants.
DEVICE_NAME_ATTRIBUTE),
"TV");
// do the move
accessor.moveDevice("PC", "TV");
// check that the TV device is the new parent of the PC device
assertEquals("Device was not moved",
"TV",
pc.getParent().getAttributeValue(
DeviceRepositorySchemaConstants.