下面列出了怎么用java.nio.file.attribute.UserPrincipalNotFoundException的API类实例代码及写法,或者点击链接到github查看源代码。
@Test
public void testGetters() throws Exception {
final String name = "foobar";
UserPrincipalNotFoundException upnfException =
new UserPrincipalNotFoundException(name);
assertEquals(name, upnfException.getName());
}
@Override
public GroupPrincipal lookupPrincipalByGroupName(String group) throws IOException {
if (!supportsGroups) {
throw new UserPrincipalNotFoundException(group); // required by spec
}
return createGroupPrincipal(group);
}
@Test
public void testServiceNotSupportingGroups() throws IOException {
UserPrincipalLookupService service = new UserLookupService(false);
try {
service.lookupPrincipalByGroupName("group");
fail();
} catch (UserPrincipalNotFoundException expected) {
assertThat(expected.getName()).isEqualTo("group");
}
}