当前位置: 首页>>代码示例>>Java>>正文


Java LdapUtils.emptyLdapName方法代码示例

本文整理汇总了Java中org.springframework.ldap.support.LdapUtils.emptyLdapName方法的典型用法代码示例。如果您正苦于以下问题:Java LdapUtils.emptyLdapName方法的具体用法?Java LdapUtils.emptyLdapName怎么用?Java LdapUtils.emptyLdapName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.ldap.support.LdapUtils的用法示例。


在下文中一共展示了LdapUtils.emptyLdapName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLookupContextWithName

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testLookupContextWithName() {
	final DirContextAdapter expectedResult = new DirContextAdapter();

       final LdapName expectedName = LdapUtils.emptyLdapName();
       LdapTemplate tested = new LdapTemplate() {
		public Object lookup(Name dn) {
			assertThat(dn).isSameAs(dn);
			return expectedResult;
		}
	};

	DirContextOperations result = tested.lookupContext(expectedName);
	assertThat(result).isSameAs(expectedResult);

}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:17,代码来源:LdapTemplateTest.java

示例2: testModifyAttributesWithDirContextOperations

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testModifyAttributesWithDirContextOperations() throws Exception {
	final ModificationItem[] expectedModifications = new ModificationItem[0];

       final LdapName epectedDn = LdapUtils.emptyLdapName();
       when(dirContextOperationsMock.getDn()).thenReturn(epectedDn);
	when(dirContextOperationsMock.isUpdateMode()).thenReturn(true);
	when(dirContextOperationsMock.getModificationItems()).thenReturn(expectedModifications);

	LdapTemplate tested = new LdapTemplate() {
		public void modifyAttributes(Name dn, ModificationItem[] mods) {
			assertThat(dn).isSameAs(epectedDn);
			assertThat(mods).isSameAs(expectedModifications);
		}
	};

	tested.modifyAttributes(dirContextOperationsMock);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:19,代码来源:LdapTemplateTest.java

示例3: setBase

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
 * Set the base suffix from which all operations should origin. If a base
 * suffix is set, you will not have to (and, indeed, must not) specify the
 * full distinguished names in any operations performed.
 *
 * @param base the base suffix.
 */
public void setBase(String base) {
       if (base != null) {
           this.base = LdapUtils.newLdapName(base);
       } else {
           this.base = LdapUtils.emptyLdapName();
       }
   }
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:15,代码来源:AbstractContextSource.java

示例4: find

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <T> List<T> find(Name base, Filter filter, SearchControls searchControls, final Class<T> clazz) {
	Filter finalFilter = odm.filterFor(clazz, filter);

    // Search from the root if we are not told where to search from
    Name localBase = base;
    if (base == null || base.size() == 0) {
        localBase = LdapUtils.emptyLdapName();
    }

    // extend search controls with the attributes to return
    String[] attributes = odm.manageClass(clazz);
    searchControls.setReturningAttributes(attributes);
    
    if (LOG.isDebugEnabled()) {
        LOG.debug(String.format("Searching - base=%1$s, finalFilter=%2$s, scope=%3$s", base, finalFilter, searchControls));
    }

    List<T> result = search(localBase, finalFilter.encode(), searchControls, new ContextMapper<T>() {
        @Override
        public T mapFromContext(Object ctx) throws javax.naming.NamingException {
            return odm.mapFromLdapDataEntry((DirContextOperations) ctx, clazz);
        }
    });
    result.remove(null);

    if (LOG.isDebugEnabled()) {
        LOG.debug(String.format("Found %1$s Entries - %2$s", result.size(), result));
    }

    return result;
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:36,代码来源:LdapTemplate.java

示例5: DirContextAdapter

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
 * Create a new adapter from the supplied attributes, dn, base, and referral
 * url.
 * @param attrs the attributes.
 * @param dn the dn.
 * @param base the base.
 * @param referralUrl the referral url (if this instance results from a
 * referral).
 */
public DirContextAdapter(Attributes attrs, Name dn, Name base,
		String referralUrl) {
	if (attrs != null) {
		this.originalAttrs = new NameAwareAttributes(attrs);
	}
	else {
		this.originalAttrs = new NameAwareAttributes();
	}

       if (dn != null) {
           this.dn = LdapUtils.newLdapName(dn);
       }
       else {
           this.dn = LdapUtils.emptyLdapName();
       }
       if (base != null) {
           this.base = LdapUtils.newLdapName(base);
       }
       else {
           this.base = LdapUtils.emptyLdapName();
       }

       if (referralUrl != null) {
		this.referralUrl = referralUrl;
	}
	else {
		this.referralUrl = EMPTY_STRING;
	}
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:39,代码来源:DirContextAdapter.java

示例6: setUp

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {

	// Setup ContextSource mock
	contextSourceMock = mock(ContextSource.class);
	// Setup LdapContext mock
	dirContextMock = mock(LdapContext.class);
	// Setup NamingEnumeration mock
	namingEnumerationMock = mock(NamingEnumeration.class);
	// Setup Name mock
	nameMock = LdapUtils.emptyLdapName();
	// Setup Handler mock
	handlerMock = mock(NameClassPairCallbackHandler.class);
	contextMapperMock = mock(ContextMapper.class);
	attributesMapperMock = mock(AttributesMapper.class);
	contextExecutorMock = mock(ContextExecutor.class);
	searchExecutorMock = mock(SearchExecutor.class);
	dirContextProcessorMock = mock(DirContextProcessor.class);
	dirContextOperationsMock = mock(DirContextOperations.class);
	authenticatedContextMock = mock(DirContext.class);
	entryContextCallbackMock = mock(AuthenticatedLdapEntryContextCallback.class);
       odmMock = mock(ObjectDirectoryMapper.class);
	query = LdapQueryBuilder.query().base("ou=spring").filter("ou=user");
	authContextMapperMock = mock(AuthenticatedLdapEntryContextMapper.class);

       tested = new LdapTemplate(contextSourceMock);
       tested.setObjectDirectoryMapper(odmMock);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:29,代码来源:LdapTemplateTest.java

示例7: testResetAttributeValuesNotReportedAsModifications

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testResetAttributeValuesNotReportedAsModifications() {
    BasicAttributes attrs = new BasicAttributes("myattr", "a");
    attrs.get("myattr").add("b");
    attrs.get("myattr").add("c");
    UpdateAdapter ctx = new UpdateAdapter(attrs, LdapUtils.emptyLdapName());

    ctx.setAttributeValues("myattr", new String[] { "a", "b" });
    ctx.setAttributeValues("myattr", new String[] { "a", "b", "c" });

    assertThat(ctx.getModificationItems().length).isEqualTo(0);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:13,代码来源:DirContextAdapterBugTest.java

示例8: testResetAttributeValuesSameLengthNotReportedAsModifications

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testResetAttributeValuesSameLengthNotReportedAsModifications() {
    BasicAttributes attrs = new BasicAttributes("myattr", "a");
    attrs.get("myattr").add("b");
    attrs.get("myattr").add("c");
    UpdateAdapter ctx = new UpdateAdapter(attrs, LdapUtils.emptyLdapName());

    ctx.setAttributeValues("myattr", new String[] { "a", "b", "d" });
    ctx.setAttributeValues("myattr", new String[] { "a", "b", "c" });

    assertThat(ctx.getModificationItems().length).isEqualTo(0);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:13,代码来源:DirContextAdapterBugTest.java

示例9: testResetNullAttributeValuesReportedAsModifications

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
/**
 * This test starts with an array with a null value in it (because that's
 * how BasicAttributes will do it), changes to <code>[a]</code>, and then
 * changes to <code>null</code>. The current code interprets this as a
 * change and will replace the original array with an empty array.
 * 
 * TODO Is this correct behaviour?
 */
@Test
public void testResetNullAttributeValuesReportedAsModifications() {
    BasicAttributes attrs = new BasicAttributes("myattr", null);
    UpdateAdapter ctx = new UpdateAdapter(attrs, LdapUtils.emptyLdapName());

    ctx.setAttributeValues("myattr", new String[] { "a" });
    ctx.setAttributeValues("myattr", null);

    assertThat(ctx.getModificationItems().length).isEqualTo(1);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:19,代码来源:DirContextAdapterBugTest.java

示例10: testResetNullAttributeValueNotReportedAsModification

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
@Test
public void testResetNullAttributeValueNotReportedAsModification() throws Exception {
    BasicAttributes attrs = new BasicAttributes("myattr", "b");
    UpdateAdapter ctx = new UpdateAdapter(attrs, LdapUtils.emptyLdapName());

    ctx.setAttributeValue("myattr", "a");
    ctx.setAttributeValue("myattr", "b");

    assertThat(ctx.getModificationItems().length).isEqualTo(0);
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:11,代码来源:DirContextAdapterBugTest.java

示例11: getRoot

import org.springframework.ldap.support.LdapUtils; //导入方法依赖的package包/类
protected Name getRoot() {
	return LdapUtils.emptyLdapName();
}
 
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:4,代码来源:AbstractLdapTemplateIntegrationTest.java


注:本文中的org.springframework.ldap.support.LdapUtils.emptyLdapName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。