TemporaryFileManager tempFileMgr = new TemporaryFileManager(
new TestDeviceRepositoryCreator());
tempFileMgr.executeWith(new TemporaryFileExecutor() {
public void execute(File repository) throws Exception {
DeviceRepositoryAccessorManager manager =
new DeviceRepositoryAccessorManager(
repository.getPath(),
new TestTransformerMetaFactory(),
new DefaultJDOMFactory(), false);
DeviceHeaderPattern[] patterns
= new DeviceHeaderPattern[] {
new DeviceHeaderPattern("name1", "re1", "baseDevice1"),
new DeviceHeaderPattern("name2", "re2", "baseDevice2")
};
manager.setHeaderPatterns("PC", patterns);
DeviceHeaderPattern[] updated = manager.getHeaderPatterns("PC");
assertEquals("Expected 2 header patterns ", 2, updated.length);
assertEquals("unexpected first header name",
"name1",
updated[0].getName());
assertEquals("unexpected first baseDevice",
"baseDevice1",
updated[0].getBaseDevice());
assertEquals("unexpected first regular expression",
"re1",
updated[0].getRegularExpression());
assertEquals("unexpected second header name",
"name2",
updated[1].getName());
assertEquals("unexpected second baseDevice",
"baseDevice2",
updated[1].getBaseDevice());
assertEquals("unexpected second regular expression",
"re2",
updated[1].getRegularExpression());
patterns = new DeviceHeaderPattern[] {
new DeviceHeaderPattern("name1", "re1", "")
};
manager.setHeaderPatterns("PC", patterns);
updated = manager.getHeaderPatterns("PC");
assertEquals("unexpected first baseDevice",
null,
updated[0].getBaseDevice());
}