public void execute(File file) throws Exception {
DeviceRepositoryFactory factory =
DeviceRepositoryFactory.getDefaultInstance();
URL deviceRepositoryUrl = file.toURL();
DeviceRepository repository = factory.getDeviceRepository(
deviceRepositoryUrl, null);
// Test match pattern*
String pattern = "Nokia-3*";
List actual = repository.getDevices(pattern);
// Create expected values based on the pattern
String[] expected = new String[] {
// "Nokia-3280",
// "Nokia-3589i",
"Nokia-3350",
"Nokia-3410",
// "Nokia-3510",
// "Nokia-3510_m",
// "Nokia-3510i",
// "Nokia-3510i_m",
// "Nokia-3530",
// "Nokia-3530_m",
// "Nokia-3585i",
// "Nokia-3610",
"Nokia-3330",
"Nokia-3360",
// "Nokia-3620",
// "Nokia-3620_m",
// "Nokia-3650",
// "Nokia-3650-Opera6",
// "Nokia-3650_m",
// "Nokia-3660",
// "Nokia-3660_m",
// "Nokia-3600",
// "Nokia-3600_m",
// "Nokia-3100",
// "Nokia-3100_m",
// "Nokia-3108",
// "Nokia-3108_m",
// "Nokia-3200",
// "Nokia-3200_m",
// "Nokia-3300",
// "Nokia-3300-1",
// "Nokia-3300-2",
// "Nokia-3300_m",
// "Nokia-3560",
// "Nokia-3590",
// "Nokia-3590_m",
// "Nokia-3595",
// "Nokia-3595_m",
// "Nokia-3520"
};
// Check success of test
assertNotNull("Should be some devices (1)", actual);
// NOTE: convert to set so order is not relied on.
assertEquals("Actual and expected arrays should match (1)",
Arrays.asList(expected), actual);
// Test match *pattern
pattern = "*400";
actual = repository.getDevices(pattern);
// Create expected values based on the pattern
expected = new String[] {
// "LG-G5400",
"Samsung-SPH-A400",
// "Samsung-SGH-T400",
// "Samsung-SGH-P400",
"Samsung-SGH-A400",
"Samsung-SGH-N400",
// "Sanyo-SCP-5400",
// "Sanyo-SCP-6400",
// "Motorola-V400",
// "Samsung-SPH-N400"
};
// Check success of test
assertNotNull("Should be some devices (2)", actual);
// NOTE: convert to set so order is not relied on.
assertEquals("Actual and expected arrays should match (2)",
Arrays.asList(expected), actual);
// Test match pattern (no wildcards)
pattern = "Master";
actual = repository.getDevices(pattern);
// Create expected values based on the pattern
expected = new String[] {
"Master"
};