### Question:
AccessControlList implements Writable { public boolean isUserAllowed(UserGroupInformation ugi) { if (allAllowed || users.contains(ugi.getShortUserName())) { return true; } else { for(String group: ugi.getGroupNames()) { if (groups.contains(group)) { return true; } } } return false; } AccessControlList();  AccessControlList(String aclString); boolean isAllAllowed(); void addUser(String user); void addGroup(String group); void removeUser(String user); void removeGroup(String group); boolean isUserAllowed(UserGroupInformation ugi); @Override String toString(); String getAclString(); void write(DataOutput out); void readFields(DataInput in); static final String WILDCARD_ACL_VALUE; }### Answer:
@Test public void testIsUserAllowed() { AccessControlList acl; UserGroupInformation drwho = UserGroupInformation.createUserForTesting("drwho@APACHE.ORG", new String[] { "aliens", "humanoids", "timelord" }); UserGroupInformation susan = UserGroupInformation.createUserForTesting("susan@APACHE.ORG", new String[] { "aliens", "humanoids", "timelord" }); UserGroupInformation barbara = UserGroupInformation.createUserForTesting("barbara@APACHE.ORG", new String[] { "humans", "teachers" }); UserGroupInformation ian = UserGroupInformation.createUserForTesting("ian@APACHE.ORG", new String[] { "humans", "teachers" }); acl = new AccessControlList("drwho humanoids"); assertUserAllowed(drwho, acl); assertUserAllowed(susan, acl); assertUserNotAllowed(barbara, acl); assertUserNotAllowed(ian, acl); acl = new AccessControlList("drwho"); assertUserAllowed(drwho, acl); assertUserNotAllowed(susan, acl); assertUserNotAllowed(barbara, acl); assertUserNotAllowed(ian, acl); acl = new AccessControlList("drwho "); assertUserAllowed(drwho, acl); assertUserNotAllowed(susan, acl); assertUserNotAllowed(barbara, acl); assertUserNotAllowed(ian, acl); acl = new AccessControlList(" humanoids"); assertUserAllowed(drwho, acl); assertUserAllowed(susan, acl); assertUserNotAllowed(barbara, acl); assertUserNotAllowed(ian, acl); acl = new AccessControlList("drwho,ian aliens,teachers"); assertUserAllowed(drwho, acl); assertUserAllowed(susan, acl); assertUserAllowed(barbara, acl); assertUserAllowed(ian, acl); }