public void notestRenameDevice() throws Exception {
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, true, true, null);
try {
accessor.renameDevice(null, null);
fail("Expected an IllegalArgumentException");
} catch (IllegalArgumentException e) {
// success
}
try {
accessor.renameDevice("PC", null);
fail("Expected an IllegalArgumentException");
} catch (IllegalArgumentException e) {
// success
}
try {
accessor.renameDevice("xxx", "WP");
fail("RepositoryException expected");
} catch (RepositoryException e) {
// success
}
accessor.renameDevice("PC", "PeeCee");
assertFalse("PC should not be found",
accessor.deviceExists("PC"));
assertTrue("PeeCee should be found",
accessor.deviceExists("PeeCee"));
accessor.renameDevice("WAP-Handset", "WP");
assertFalse("WAP-Handset should not be found",
accessor.deviceExists("WAP-Handset"));
assertTrue("WP should be found",
accessor.deviceExists("WP"));
// Save the repository contents.
writeRepository(accessor);
// Read the contents back to verify them.