AclScanner implements ArtifactInstaller { @Override public void install(File artifact) throws Exception { logger.info("Installing Acl {}", artifact.getAbsolutePath()); addAcl(artifact); }  @Override boolean canHandle(File artifact); @Override void install(File artifact); @Override void update(File artifact); @Override void uninstall(File artifact); static final String ACL_DIRECTORY; }
@Test public void testCorrectFileInstall() throws Exception { File file = new File(AclScannerTest.class.getResource("/xacml_correct.xml").toURI()); ManagedAcl acl = new ManagedAclImpl(1L, "TestAcl", "org", new AccessControlList()); Option<ManagedAcl> managedAcl = Option.some(acl); EasyMock.expect(aclDb.createAcl(anyObject(Organization.class), anyObject(AccessControlList.class), anyString())) .andReturn(managedAcl).times(3); EasyMock.expect(aclDb.getAcls(anyObject(Organization.class))).andReturn(new ArrayList<ManagedAcl>()).times(3); EasyMock.replay(aclDb); aclScanner.install(file); EasyMock.verify(aclDb); }
@Test public void testCorruptedFileInstall() throws Exception { File file = new File(AclScannerTest.class.getResource("/xacml_errors.xml").toURI()); try { aclScanner.install(file); fail("Should not be parsed."); } catch (XACMLParsingException e) { assertTrue("The file can not be parsed.", e.getCause() instanceof UnmarshalException); } }