public void testMultiFSPolicy() throws Exception {
File globalPolicyFile = new File(Files.createTempDir(), "global-policy.ini");
File dbPolicyFile = new File(Files.createTempDir(), "db11-policy.ini");
// Create global policy file
PolicyFile dbPolicy = new PolicyFile()
.addPermissionsToRole("db11_role", "server=server1->db=db11")
.addRolesToGroup("group1", "db11_role");
dbPolicy.write(dbPolicyFile);
Path dbPolicyPath = new Path(etc, "db11-policy.ini");
// create per-db policy file
PolicyFile globalPolicy = new PolicyFile()
.addPermissionsToRole("admin_role", "server=server1")
.addRolesToGroup("admin_group", "admin_role")
.addGroupsToUser("db", "admin_group");
globalPolicy.addDatabase("db11", dbPolicyPath.toUri().toString());
globalPolicy.write(globalPolicyFile);
PolicyFiles.copyFilesToDir(fileSystem, etc, globalPolicyFile);
PolicyFiles.copyFilesToDir(fileSystem, etc, dbPolicyFile);
DBPolicyFileBackend multiFSEngine =