TemporaryFileManager manager = new TemporaryFileManager(
new TestDeviceRepositoryCreator());
manager.executeWith(new TemporaryFileExecutor() {
public void execute(final File repository) throws Exception {
AbstractDeviceRepositoryAccessor accessor =
createAccessor(repository);
accessor.initializeDevicePatternCache(null);
// Access a device for which an initial KeyInfo was set up
String devName = accessor.retrieveMatchingDeviceName("profile: http://nds.nokia.com/uaprof/N6210r100.xml");
assertEquals("Nokia 6210 should be retrieved by UAProf URI",
"Nokia-6210", devName);
// Access a device which will be in the default profile bucket
devName = accessor.retrieveMatchingDeviceName("profile: http://device.sprintpcs.com/Handspring/HSTR300HK");
assertEquals("Handspring should be retrieved by UAProf URI",
"SprintPCS-HSTR-300", devName);
// Attempt to access a non-existent device
devName = accessor.retrieveMatchingDeviceName("profile: http://www.volantis.com/uaprof/NoSuchPhone.xml");
assertNull("No device should be retrieved for unknown UAProf URI",
devName);
}
});
}