本文整理匯總了Java中javax.naming.directory.SearchResult.setNameInNamespace方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchResult.setNameInNamespace方法的具體用法?Java SearchResult.setNameInNamespace怎麽用?Java SearchResult.setNameInNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.naming.directory.SearchResult
的用法示例。
在下文中一共展示了SearchResult.setNameInNamespace方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getMockedLDAPSearchResult
import javax.naming.directory.SearchResult; //導入方法依賴的package包/類
private LDAPInitialDirContextFactoryImpl getMockedLDAPSearchResult(boolean withEmail) throws NamingException
{
@SuppressWarnings("unchecked")
NamingEnumeration<SearchResult> mockedNamingEnumeration = mock(NamingEnumeration.class);
when(mockedNamingEnumeration.hasMore()).thenReturn(true).thenReturn(false);
BasicAttributes attributes = new BasicAttributes();
attributes.put(new BasicAttribute("sAMAccountName", "U1"));
attributes.put(new BasicAttribute("givenName", "U1"));
if (withEmail)
{
attributes.put(new BasicAttribute("mail", "[email protected]"));
}
SearchResult mockedSearchResult = new SearchResult("CN:U1", null, attributes);
mockedSearchResult.setNameInNamespace("CN:U1");
when(mockedNamingEnumeration.next()).thenReturn(mockedSearchResult);
InitialDirContext mockedInitialDirContext = mock(InitialDirContext.class);
when(mockedInitialDirContext.search(any(String.class), any(String.class), any(SearchControls.class))).thenReturn(mockedNamingEnumeration);
LDAPInitialDirContextFactoryImpl mockedLdapInitialDirContextFactory = mock(LDAPInitialDirContextFactoryImpl.class);
when(mockedLdapInitialDirContextFactory.getDefaultIntialDirContext(0)).thenReturn(mockedInitialDirContext);
return mockedLdapInitialDirContextFactory;
}
示例2: retrieveName_notRelative
import javax.naming.directory.SearchResult; //導入方法依賴的package包/類
@Test
public void retrieveName_notRelative() {
// given
SearchResult searchResult = new SearchResult(null, null, null, false);
searchResult.setNameInNamespace("cn=ldap01");
searchResult
.setName("ldap://estdevmail1.dev.est.fujitsu.com:389/cn=ldap01");
ldapProps.put(Context.PROVIDER_URL, "");
// when
String name = realmImpl.retrieveName(ldapProps, searchResult);
// then
assertEquals("cn=ldap01", name);
assertEquals("ldap://estdevmail1.dev.est.fujitsu.com:389",
ldapProps.getProperty(Context.PROVIDER_URL));
}
示例3: retrieveName_notRelative_Empty
import javax.naming.directory.SearchResult; //導入方法依賴的package包/類
@Test
public void retrieveName_notRelative_Empty() {
// given
SearchResult searchResult = new SearchResult(null, null, null, false);
searchResult.setNameInNamespace("cn=ldap01");
searchResult.setName("");
ldapProps.put(Context.PROVIDER_URL, "a");
// when
String name = realmImpl.retrieveName(ldapProps, searchResult);
// then
assertEquals("cn=ldap01", name);
assertEquals("a", ldapProps.getProperty(Context.PROVIDER_URL));
}