class TestSecurityManager extends SecurityManager {
private boolean called = false;
private String name = null;
void reset(){
called = false;
name = null;
}
String getName(){return name;}
@Override
public void checkRead(String name) {
called = true;
this.name = name;
super.checkRead(name);
}
@Override
public void checkPermission(Permission permission) {
}
}
File file = File.createTempFile("foo", "zip");
String filename = file.getAbsolutePath();
TestSecurityManager s = new TestSecurityManager();
System.setSecurityManager(s);
s.reset();
try {
new ZipFile(filename);
} catch (ZipException ex) {
// Ignore.
}
assertTrue("java.util.zip.ZipFile() construcor must call checkRead on security permissions", s.called);
assertEquals("Argument of checkPermission is not correct", filename, s.getName());