update unit test for Windows environment, closes #647

pull/653/head
Justin Richer 2014-07-31 23:22:06 -04:00
parent 2ae06b2611
commit 78f3e68e8b
1 changed files with 30 additions and 21 deletions

View File

@ -162,27 +162,36 @@ public class TestJWKSetKeyStore {
/* First, test with file without "read" permission */
if (file.exists()) {
file.setReadable(false);
}
Resource loc_noread = new FileSystemResource(file);
assertTrue(loc_noread.exists());
assertTrue(!loc_noread.isReadable());
boolean set = false;
boolean thrown = false;
try {
ks.setLocation(loc_noread);
} catch (IllegalArgumentException e) {
thrown = true;
}
assertTrue(thrown);
if (file.exists()) {
set = file.setReadable(false);
}
/* Now, make cache file readable */
// skip this part of the test on systems that don't allow the settable function, like Windows
if (set) {
if (file.exists()) {
file.setReadable(true);
}
Resource loc = new FileSystemResource(file);
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());