java.nio.file.attribute.UserPrincipalNotFoundException Java Examples

The following examples show how to use java.nio.file.attribute.UserPrincipalNotFoundException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserPrincipalNotFoundExceptionTest.java    From j2objc with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetters() throws Exception {
    final String name = "foobar";
    UserPrincipalNotFoundException upnfException =
        new UserPrincipalNotFoundException(name);
    assertEquals(name, upnfException.getName());
}
 
Example #2
Source File: UserLookupService.java    From jimfs with Apache License 2.0 5 votes vote down vote up
@Override
public GroupPrincipal lookupPrincipalByGroupName(String group) throws IOException {
  if (!supportsGroups) {
    throw new UserPrincipalNotFoundException(group); // required by spec
  }
  return createGroupPrincipal(group);
}
 
Example #3
Source File: UserLookupServiceTest.java    From jimfs with Apache License 2.0 5 votes vote down vote up
@Test
public void testServiceNotSupportingGroups() throws IOException {
  UserPrincipalLookupService service = new UserLookupService(false);

  try {
    service.lookupPrincipalByGroupName("group");
    fail();
  } catch (UserPrincipalNotFoundException expected) {
    assertThat(expected.getName()).isEqualTo("group");
  }
}