Java Code Examples for java.nio.file.attribute.UserPrincipalNotFoundException

The following examples show how to use java.nio.file.attribute.UserPrincipalNotFoundException. These examples are extracted from open source projects. 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 Project: j2objc   Source File: UserPrincipalNotFoundExceptionTest.java    License: 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 Project: jimfs   Source File: UserLookupService.java    License: 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 Project: jimfs   Source File: UserLookupServiceTest.java    License: 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");
  }
}