/* Empty constructor with valid Resource */
@Test
public void ksEmptyConstructorkLoc() {
JWKSetKeyStore ks = new JWKSetKeyStore();
File file = new File(ks_file);
/* First, test with file without "read" permission */
boolean set = false;
if (file.exists()) {
set = file.setReadable(false);
}
// skip this part of the test on systems that don't allow the settable function, like Windows
if (set) {
Resource loc_noread = new FileSystemResource(file);
assertTrue(loc_noread.exists());
// assertTrue(!loc_noread.isReadable());
boolean thrown = false;
try {
ks.setLocation(loc_noread);
} catch (IllegalArgumentException e) {
thrown = true;
}
assertTrue(thrown);
/* Now, make cache file readable */
if (file.exists()) {
file.setReadable(true);
}
}
Resource loc = new FileSystemResource(file);
assertTrue(loc.exists());
assertTrue(loc.isReadable());
ks.setLocation(loc);
assertEquals(loc.getFilename(),ks.getLocation().getFilename());
}