f.delete();
}
subdir.delete();
}
subdir.mkdirs();
PropDb db = new PropDb();
db.read(subdir);
assertNull(db.getCount());
assertNull(db.getPackageName());
db = new PropDb();
Properties p = new Properties();
FileOutputStream fos = new FileOutputStream(new File(dir,
PropDb.FILE_NAME));
p.store(fos, "broken");
fos.close();
try {
db.read(dir);
fail();
} catch (Exception e) {
assertTrue(e.getMessage().indexOf(PropDb.FILE_NAME) > -1);
}
db = new PropDb() {
@Override
Properties makeProperties() {
return new Properties() {
private static final long serialVersionUID = 1L;
@Override
public void load(InputStream is) throws IOException {
throw new IOException("Sabotage");
}
@Override
public void store(OutputStream is, String comment)
throws IOException {
throw new IOException("Sabotage");
}
};
}
};
try {
db.read(dir);
fail();
} catch (IOException e) {
assertEquals(e.getMessage(), "Sabotage");
}
try {
db.setPackageName("foo");
db.setCount(12);
db.write(dir);
fail();
} catch (IOException e) {
assertEquals(e.getMessage(), "Sabotage");
}