Fix Formatting

This commit is contained in:
Josh Cummings
2024-08-15 11:22:29 -06:00
parent ea849cdebc
commit 159dfd1fcb
85 changed files with 964 additions and 644 deletions

View File

@@ -38,38 +38,50 @@ class LdapCoreRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection().registerType(TypeReference.of("com.sun.jndi.ldap.LdapCtxFactory"),
(builder) -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerType(AbstractContextSource.class, (builder) -> builder
hints.reflection()
.registerType(TypeReference.of("com.sun.jndi.ldap.LdapCtxFactory"),
(builder) -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection()
.registerType(AbstractContextSource.class, (builder) -> builder
.withMembers(MemberCategory.INTROSPECT_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS));
hints.reflection().registerType(DefaultDirObjectFactory.class,
(builder) -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerTypeIfPresent(classLoader, "javax.naming.ldap.PagedResultsControl",
(builder) -> builder.onReachableType(PagedResultsDirContextProcessor.class)
hints.reflection()
.registerType(DefaultDirObjectFactory.class,
(builder) -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection()
.registerTypeIfPresent(classLoader, "javax.naming.ldap.PagedResultsControl",
(builder) -> builder.onReachableType(PagedResultsDirContextProcessor.class)
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerTypeIfPresent(classLoader, "com.sun.jndi.ldap.ctl.PagedResultsControl",
(builder) -> builder.onReachableType(PagedResultsDirContextProcessor.class)
hints.reflection()
.registerTypeIfPresent(classLoader, "com.sun.jndi.ldap.ctl.PagedResultsControl",
(builder) -> builder.onReachableType(PagedResultsDirContextProcessor.class)
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerTypeIfPresent(classLoader, "javax.naming.ldap.PagedResultsResponseControl",
(builder) -> builder.onReachableType(PagedResultsDirContextProcessor.class)
hints.reflection()
.registerTypeIfPresent(classLoader, "javax.naming.ldap.PagedResultsResponseControl",
(builder) -> builder.onReachableType(PagedResultsDirContextProcessor.class)
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerTypeIfPresent(classLoader, "com.sun.jndi.ldap.ctl.PagedResultsResponseControl",
(builder) -> builder.onReachableType(PagedResultsDirContextProcessor.class)
hints.reflection()
.registerTypeIfPresent(classLoader, "com.sun.jndi.ldap.ctl.PagedResultsResponseControl",
(builder) -> builder.onReachableType(PagedResultsDirContextProcessor.class)
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerTypeIfPresent(classLoader, "javax.naming.ldap.SortControl",
(builder) -> builder.onReachableType(SortControlDirContextProcessor.class)
hints.reflection()
.registerTypeIfPresent(classLoader, "javax.naming.ldap.SortControl",
(builder) -> builder.onReachableType(SortControlDirContextProcessor.class)
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerTypeIfPresent(classLoader, "com.sun.jndi.ldap.ctl.SortControl",
(builder) -> builder.onReachableType(SortControlDirContextProcessor.class)
hints.reflection()
.registerTypeIfPresent(classLoader, "com.sun.jndi.ldap.ctl.SortControl",
(builder) -> builder.onReachableType(SortControlDirContextProcessor.class)
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerTypeIfPresent(classLoader, "javax.naming.ldap.SortResponseControl",
(builder) -> builder.onReachableType(SortControlDirContextProcessor.class)
hints.reflection()
.registerTypeIfPresent(classLoader, "javax.naming.ldap.SortResponseControl",
(builder) -> builder.onReachableType(SortControlDirContextProcessor.class)
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerTypeIfPresent(classLoader, "com.sun.jndi.ldap.ctl.SortResponseControl",
(builder) -> builder.onReachableType(SortControlDirContextProcessor.class)
hints.reflection()
.registerTypeIfPresent(classLoader, "com.sun.jndi.ldap.ctl.SortResponseControl",
(builder) -> builder.onReachableType(SortControlDirContextProcessor.class)
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
hints.reflection().registerType(TypeReference.of("javax.net.ssl.SSLSocketFactory"),
(builder) -> builder.withMethod("getDefault", Collections.emptyList(), ExecutableMode.INVOKE)
hints.reflection()
.registerType(TypeReference.of("javax.net.ssl.SSLSocketFactory"),
(builder) -> builder.withMethod("getDefault", Collections.emptyList(), ExecutableMode.INVOKE)
.onReachableType(TypeReference.of("com.sun.jndi.ldap.Connection")));
}

View File

@@ -177,7 +177,8 @@ public class ContextSourceParser implements BeanDefinitionParser {
builder.addPropertyValue("password", password);
BeanDefinitionBuilder urlsBuilder = BeanDefinitionBuilder.rootBeanDefinition(UrlsFactory.class)
.setFactoryMethod("urls").addConstructorArgValue(url);
.setFactoryMethod("urls")
.addConstructorArgValue(url);
builder.addPropertyValue("urls", urlsBuilder.getBeanDefinition());
builder.addPropertyValue("base", ParserUtils.getString(element, ATT_BASE, ""));
@@ -215,7 +216,7 @@ public class ContextSourceParser implements BeanDefinitionParser {
BeanDefinition actualContextSourceDefinition = targetContextSourceDefinition;
if (!anonymousReadOnly) {
BeanDefinitionBuilder proxyBuilder = BeanDefinitionBuilder
.rootBeanDefinition(TransactionAwareContextSourceProxy.class);
.rootBeanDefinition(TransactionAwareContextSourceProxy.class);
proxyBuilder.addConstructorArgValue(targetContextSourceDefinition);
actualContextSourceDefinition = proxyBuilder.getBeanDefinition();
}
@@ -306,7 +307,7 @@ public class ContextSourceParser implements BeanDefinitionParser {
builder.addPropertyValue("testWhileIdle", testWhileIdle);
BeanDefinitionBuilder validatorBuilder = BeanDefinitionBuilder
.rootBeanDefinition(DefaultDirContextValidator.class);
.rootBeanDefinition(DefaultDirContextValidator.class);
validatorBuilder.addPropertyValue("base", ParserUtils.getString(element, ATT_VALIDATION_QUERY_BASE, ""));
validatorBuilder.addPropertyValue("filter",
ParserUtils.getString(element, ATT_VALIDATION_QUERY_FILTER, DefaultDirContextValidator.DEFAULT_FILTER));
@@ -342,7 +343,7 @@ public class ContextSourceParser implements BeanDefinitionParser {
private void populatePoolValidationProperties(BeanDefinitionBuilder builder, Element element) {
BeanDefinitionBuilder validatorBuilder = BeanDefinitionBuilder
.rootBeanDefinition(org.springframework.ldap.pool2.validation.DefaultDirContextValidator.class);
.rootBeanDefinition(org.springframework.ldap.pool2.validation.DefaultDirContextValidator.class);
validatorBuilder.addPropertyValue("base", ParserUtils.getString(element, ATT_VALIDATION_QUERY_BASE, ""));
validatorBuilder.addPropertyValue("filter", ParserUtils.getString(element, ATT_VALIDATION_QUERY_FILTER,
org.springframework.ldap.pool2.validation.DefaultDirContextValidator.DEFAULT_FILTER));

View File

@@ -35,14 +35,15 @@ public class DefaultRenamingStrategyParser implements BeanDefinitionParser {
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder
.rootBeanDefinition(DefaultTempEntryRenamingStrategy.class);
.rootBeanDefinition(DefaultTempEntryRenamingStrategy.class);
builder.addPropertyValue("tempSuffix",
ParserUtils.getString(element, ATT_TEMP_SUFFIX, DefaultTempEntryRenamingStrategy.DEFAULT_TEMP_SUFFIX));
AbstractBeanDefinition beanDefinition = builder.getBeanDefinition();
parserContext.getContainingBeanDefinition().getPropertyValues().addPropertyValue("renamingStrategy",
beanDefinition);
parserContext.getContainingBeanDefinition()
.getPropertyValues()
.addPropertyValue("renamingStrategy", beanDefinition);
return beanDefinition;
}

View File

@@ -101,7 +101,7 @@ public class TransactionManagerParser implements BeanDefinitionParser {
private BeanDefinition parseDifferentSubtreeRenamingStrategy(Element element) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder
.rootBeanDefinition(DifferentSubtreeTempEntryRenamingStrategy.class);
.rootBeanDefinition(DifferentSubtreeTempEntryRenamingStrategy.class);
String subtreeNode = element.getAttribute(ATT_SUBTREE_NODE);
Assert.hasText(subtreeNode, ATT_SUBTREE_NODE + " must be specified");
@@ -113,7 +113,7 @@ public class TransactionManagerParser implements BeanDefinitionParser {
public BeanDefinition parseDefaultRenamingStrategy(Element element) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder
.rootBeanDefinition(DefaultTempEntryRenamingStrategy.class);
.rootBeanDefinition(DefaultTempEntryRenamingStrategy.class);
builder.addPropertyValue("tempSuffix",
ParserUtils.getString(element, ATT_TEMP_SUFFIX, DefaultTempEntryRenamingStrategy.DEFAULT_TEMP_SUFFIX));

View File

@@ -318,8 +318,10 @@ class DefaultLdapClient implements LdapClient {
Enumeration<S> enumeration = enumeration(results);
Function<? super S, T> function = mapper.wrap(this.namingExceptionHandler);
return StreamSupport
.stream(Spliterators.spliteratorUnknownSize(enumeration.asIterator(), Spliterator.ORDERED), false)
.map(function::apply).filter(Objects::nonNull).onClose(() -> closeNamingEnumeration(results));
.stream(Spliterators.spliteratorUnknownSize(enumeration.asIterator(), Spliterator.ORDERED), false)
.map(function::apply)
.filter(Objects::nonNull)
.onClose(() -> closeNamingEnumeration(results));
}
private void closeContext(DirContext ctx) {
@@ -467,7 +469,7 @@ class DefaultLdapClient implements LdapClient {
try {
String password = (this.password != null) ? new String(this.password) : null;
ctx = DefaultLdapClient.this.contextSource
.getContext(identification.get(0).getAbsoluteName().toString(), password);
.getContext(identification.get(0).getAbsoluteName().toString(), password);
return mapper.mapWithContext(ctx, identification.get(0));
}
finally {

View File

@@ -287,7 +287,7 @@ public class LdapRdn implements Serializable, Comparable {
mapWithImmutableRdns.put(rdnComponent.getKey(), rdnComponent.immutableLdapRdnComponent());
}
Map<String, LdapRdnComponent> unmodifiableMapOfImmutableRdns = Collections
.unmodifiableMap(mapWithImmutableRdns);
.unmodifiableMap(mapWithImmutableRdns);
LdapRdn immutableRdn = new LdapRdn();
immutableRdn.components = unmodifiableMapOfImmutableRdns;
return immutableRdn;

View File

@@ -1334,7 +1334,7 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
return authenticate(base, filter, password,
getDefaultSearchControls(this.defaultSearchScope, RETURN_OBJ_FLAG, null), callback, errorCallback)
.isSuccess();
.isSuccess();
}
private AuthenticationStatus authenticate(Name base, String filter, String password, SearchControls searchControls,
@@ -1572,10 +1572,11 @@ public class LdapTemplate implements LdapOperations, InitializingBean {
return Stream.empty();
}
return StreamSupport
.stream(Spliterators.spliteratorUnknownSize(CollectionUtils.toIterator(results), Spliterator.ORDERED),
false)
.map((nameClassPair) -> unchecked(() -> mapper.apply(nameClassPair))).filter(Objects::nonNull)
.onClose(() -> closeContextAndNamingEnumeration(ctx, results));
.stream(Spliterators.spliteratorUnknownSize(CollectionUtils.toIterator(results), Spliterator.ORDERED),
false)
.map((nameClassPair) -> unchecked(() -> mapper.apply(nameClassPair)))
.filter(Objects::nonNull)
.onClose(() -> closeContextAndNamingEnumeration(ctx, results));
}
/**

View File

@@ -94,7 +94,7 @@ public class BaseLdapPathBeanPostProcessor implements BeanPostProcessor, Applica
}
Collection<BaseLdapPathSource> beans = this.applicationContext.getBeansOfType(BaseLdapPathSource.class)
.values();
.values();
if (beans.isEmpty()) {
throw new NoSuchBeanDefinitionException("No BaseLdapPathSource implementation definition found");
}

View File

@@ -333,7 +333,7 @@ public class DefaultIncrementalAttributesMapper
*/
public static List<Object> lookupAttributeValues(LdapOperations ldapOperations, Name dn, String attribute) {
List<Object> values = loopForAllAttributeValues(ldapOperations, dn, new String[] { attribute })
.getValues(attribute);
.getValues(attribute);
if (values == null) {
values = Collections.emptyList();
}

View File

@@ -32,6 +32,7 @@ import java.lang.annotation.Target;
* {@link org.springframework.ldap.odm.annotations.Entry#base()} value will be used to
* figure out the distinguished name of entries to create and update.
* </p>
*
* @author Mattias Hellborg Arthursson
* @since 2.0
*/

View File

@@ -29,7 +29,6 @@ import java.lang.annotation.Target;
* annotated {@link Attribute}.
*
* @author Paul Harvey &lt;paul.at.pauls-place.me.uk&gt;
*
* @see Attribute
* @see javax.naming.Name
*/

View File

@@ -26,7 +26,6 @@ import java.lang.annotation.Target;
* <em>not</em> be persisted to LDAP.
*
* @author Paul Harvey &lt;paul@pauls-place.me.uk&gt;
*
* @see Entry
*/
@Target(ElementType.FIELD)

View File

@@ -209,7 +209,7 @@ public class DefaultObjectDirectoryMapper implements ObjectDirectoryMapper {
// but only if this is a new entry.
int numOcs = metaData.getObjectClasses().size();
CaseIgnoreString[] metaDataObjectClasses = metaData.getObjectClasses()
.toArray(new CaseIgnoreString[numOcs]);
.toArray(new CaseIgnoreString[numOcs]);
String[] stringOcs = new String[numOcs];
for (int ocIndex = 0; ocIndex < numOcs; ocIndex++) {

View File

@@ -139,8 +139,8 @@ import org.springframework.util.StringUtils;
if (currentAttributeMetaData.isId()) {
if (this.idAttribute != null) {
// There can be only one id field
throw new MetaDataException(String.format(
"You man have only one field with the %1$s annotation in class %2$s", Id.class, clazz));
throw new MetaDataException(String
.format("You man have only one field with the %1$s annotation in class %2$s", Id.class, clazz));
}
this.idAttribute = currentAttributeMetaData;
}

View File

@@ -152,7 +152,7 @@ class DirContextPoolableObjectFactory extends BaseKeyedPoolableObjectFactory {
if (this.logger.isDebugEnabled()) {
this.logger
.debug("Created new " + DirContextType.READ_WRITE + " DirContext='" + readWriteContext + "'");
.debug("Created new " + DirContextType.READ_WRITE + " DirContext='" + readWriteContext + "'");
}
return makeFailureAwareProxy(readWriteContext);

View File

@@ -213,7 +213,7 @@ class DirContextPooledObjectFactory extends BaseKeyedPooledObjectFactory<Object,
if (this.logger.isDebugEnabled()) {
this.logger
.debug("Created new " + DirContextType.READ_WRITE + " DirContext='" + readWriteContext + "'");
.debug("Created new " + DirContextType.READ_WRITE + " DirContext='" + readWriteContext + "'");
}
return makeFailureAwareProxy(readWriteContext);

View File

@@ -69,8 +69,9 @@ class DefaultContainerCriteria implements AppendableContainerCriteria {
@Override
public ContainerCriteria and(ContainerCriteria nested) {
if (this.type == CriteriaContainerType.OR) {
return new DefaultContainerCriteria(this.topQuery).withType(CriteriaContainerType.AND).append(this.filter())
.append(nested.filter());
return new DefaultContainerCriteria(this.topQuery).withType(CriteriaContainerType.AND)
.append(this.filter())
.append(nested.filter());
}
else {
this.type = CriteriaContainerType.AND;
@@ -82,8 +83,9 @@ class DefaultContainerCriteria implements AppendableContainerCriteria {
@Override
public ContainerCriteria or(ContainerCriteria nested) {
if (this.type == CriteriaContainerType.AND) {
return new DefaultContainerCriteria(this.topQuery).withType(CriteriaContainerType.OR).append(this.filter())
.append(nested.filter());
return new DefaultContainerCriteria(this.topQuery).withType(CriteriaContainerType.OR)
.append(this.filter())
.append(nested.filter());
}
else {
this.type = CriteriaContainerType.OR;

View File

@@ -114,7 +114,7 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran
protected void doCommit(DefaultTransactionStatus status) {
ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) status
.getTransaction();
.getTransaction();
try {
super.doCommit(new DefaultTransactionStatus(actualTransactionObject.getDataSourceTransactionObject(),
@@ -147,7 +147,7 @@ public class ContextSourceAndDataSourceTransactionManager extends DataSourceTran
@Override
protected void doRollback(DefaultTransactionStatus status) {
ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) status
.getTransaction();
.getTransaction();
super.doRollback(new DefaultTransactionStatus(actualTransactionObject.getDataSourceTransactionObject(),
status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),

View File

@@ -115,7 +115,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
protected void doCommit(DefaultTransactionStatus status) {
ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status
.getTransaction();
.getTransaction();
try {
super.doCommit(new DefaultTransactionStatus(actualTransactionObject.getHibernateTransactionObject(),
@@ -147,7 +147,7 @@ public class ContextSourceAndHibernateTransactionManager extends HibernateTransa
@Override
protected void doRollback(DefaultTransactionStatus status) {
ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status
.getTransaction();
.getTransaction();
super.doRollback(new DefaultTransactionStatus(actualTransactionObject.getHibernateTransactionObject(),
status.isNewTransaction(), status.isNewSynchronization(), status.isReadOnly(), status.isDebug(),

View File

@@ -104,7 +104,7 @@ public class TransactionAwareDirContextInvocationHandler implements InvocationHa
*/
void doCloseConnection(DirContext context, ContextSource contextSource) throws javax.naming.NamingException {
DirContextHolder transactionContextHolder = (DirContextHolder) TransactionSynchronizationManager
.getResource(contextSource);
.getResource(contextSource);
if (transactionContextHolder == null || transactionContextHolder.getCtx() != context) {
log.debug("Closing context");
// This is not the transactional context or the transaction is

View File

@@ -64,7 +64,7 @@ public abstract class AbstractCompensatingTransactionManagerDelegate {
*/
public Object doGetTransaction() throws TransactionException {
CompensatingTransactionHolderSupport holder = (CompensatingTransactionHolderSupport) TransactionSynchronizationManager
.getResource(getTransactionSynchronizationKey());
.getResource(getTransactionSynchronizationKey());
return new CompensatingTransactionObject(holder);
}

View File

@@ -50,11 +50,11 @@ public final class CompensatingTransactionUtils {
public static void performOperation(Object synchronizationKey, Object target, Method method, Object[] args)
throws Throwable {
CompensatingTransactionHolderSupport transactionResourceHolder = (CompensatingTransactionHolderSupport) TransactionSynchronizationManager
.getResource(synchronizationKey);
.getResource(synchronizationKey);
if (transactionResourceHolder != null) {
CompensatingTransactionOperationManager transactionOperationManager = transactionResourceHolder
.getTransactionOperationManager();
.getTransactionOperationManager();
transactionOperationManager.performOperation(transactionResourceHolder.getTransactedResource(),
method.getName(), args);
}

View File

@@ -46,9 +46,11 @@ public class NamingExceptionTests {
writeToStream(exception);
NamingException deSerializedException = readFromStream();
assertThat(exception.getResolvedObj())
.withFailMessage("Original exception resolvedObj after serialization should not be null").isNotNull();
.withFailMessage("Original exception resolvedObj after serialization should not be null")
.isNotNull();
assertThat(deSerializedException.getResolvedObj())
.withFailMessage("De-serialized exception resolvedObj should be null").isNull();
.withFailMessage("De-serialized exception resolvedObj should be null")
.isNull();
}
private NamingException readFromStream() throws IOException, ClassNotFoundException {

View File

@@ -46,65 +46,77 @@ public class LdapCoreRuntimeHintsTests {
@Before
public void setup() {
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories").load(RuntimeHintsRegistrar.class)
.forEach((registrar) -> registrar.registerHints(this.hints, ClassUtils.getDefaultClassLoader()));
SpringFactoriesLoader.forResourceLocation("META-INF/spring/aot.factories")
.load(RuntimeHintsRegistrar.class)
.forEach((registrar) -> registrar.registerHints(this.hints, ClassUtils.getDefaultClassLoader()));
}
@Test
public void ldapCtxFactoryHasHints() {
assertThat(RuntimeHintsPredicates.reflection().onType(TypeReference.of("com.sun.jndi.ldap.LdapCtxFactory"))
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS)).accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection()
.onType(TypeReference.of("com.sun.jndi.ldap.LdapCtxFactory"))
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS)).accepts(this.hints);
}
@Test
public void abstractContextSourceHasHints() {
assertThat(RuntimeHintsPredicates.reflection().onType(AbstractContextSource.class)
.withMemberCategories(MemberCategory.INTROSPECT_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection()
.onType(AbstractContextSource.class)
.withMemberCategories(MemberCategory.INTROSPECT_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS))
.accepts(this.hints);
}
@Test
public void defaultDirObjectFactoryHasHints() {
assertThat(RuntimeHintsPredicates.reflection().onType(DefaultDirObjectFactory.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS)).accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection()
.onType(DefaultDirObjectFactory.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS)).accepts(this.hints);
}
@Test
public void pagedResultsControlHasHints() {
assertThat(RuntimeHintsPredicates.reflection().onType(PagedResultsControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection().onType(com.sun.jndi.ldap.ctl.PagedResultsControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection().onType(PagedResultsResponseControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection().onType(com.sun.jndi.ldap.ctl.PagedResultsResponseControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection()
.onType(PagedResultsControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection()
.onType(com.sun.jndi.ldap.ctl.PagedResultsControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection()
.onType(PagedResultsResponseControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection()
.onType(com.sun.jndi.ldap.ctl.PagedResultsResponseControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
}
@Test
public void sortControlHasHints() {
assertThat(RuntimeHintsPredicates.reflection().onType(SortControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection().onType(com.sun.jndi.ldap.ctl.SortControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection().onType(SortResponseControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection().onType(com.sun.jndi.ldap.ctl.SortResponseControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection()
.onType(SortControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection()
.onType(com.sun.jndi.ldap.ctl.SortControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection()
.onType(SortResponseControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
assertThat(RuntimeHintsPredicates.reflection()
.onType(com.sun.jndi.ldap.ctl.SortResponseControl.class)
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS))
.accepts(this.hints);
}
@Test
public void sslSocketFactoryHasHints() throws Exception {
assertThat(RuntimeHintsPredicates.reflection().onMethod(SSLSocketFactory.class.getDeclaredMethod("getDefault")))
.accepts(this.hints);
.accepts(this.hints);
}
}

View File

@@ -73,7 +73,7 @@ public class LdapTemplateNamespaceHandlerTests {
assertThat("uid=admin").isEqualTo(getInternalState(contextSource, "userDn"));
assertThat("apassword").isEqualTo(getInternalState(contextSource, "password"));
assertThat(new String[] { "ldap://localhost:389" })
.isEqualTo((Object[]) getInternalState(contextSource, "urls"));
.isEqualTo((Object[]) getInternalState(contextSource, "urls"));
assertThat(Boolean.FALSE).isEqualTo(getInternalState(contextSource, "pooled"));
assertThat(Boolean.FALSE).isEqualTo(getInternalState(contextSource, "anonymousReadOnly"));
assertThat((Object) getInternalState(contextSource, "referral")).isNull();
@@ -148,7 +148,7 @@ public class LdapTemplateNamespaceHandlerTests {
assertThat("uid=admin").isEqualTo(getInternalState(contextSource, "userDn"));
assertThat("apassword").isEqualTo(getInternalState(contextSource, "password"));
assertThat(new String[] { "ldap://localhost:389" })
.isEqualTo((Object[]) getInternalState(contextSource, "urls"));
.isEqualTo((Object[]) getInternalState(contextSource, "urls"));
assertThat(Boolean.TRUE).isEqualTo(getInternalState(contextSource, "pooled"));
assertThat(Boolean.FALSE).isEqualTo(getInternalState(contextSource, "anonymousReadOnly"));
assertThat("follow").isEqualTo(getInternalState(contextSource, "referral"));
@@ -176,7 +176,7 @@ public class LdapTemplateNamespaceHandlerTests {
assertThat("uid=admin").isEqualTo(getInternalState(contextSource, "userDn"));
assertThat("apassword").isEqualTo(getInternalState(contextSource, "password"));
assertThat(new String[] { "ldap://localhost:389" })
.isEqualTo((Object[]) getInternalState(contextSource, "urls"));
.isEqualTo((Object[]) getInternalState(contextSource, "urls"));
}
@@ -192,7 +192,7 @@ public class LdapTemplateNamespaceHandlerTests {
ContextSource contextSource = ((TransactionAwareContextSourceProxy) outerContextSource).getTarget();
assertThat(new String[] { "ldap://a.localhost:389", "ldap://b.localhost:389" })
.isEqualTo(getInternalState(contextSource, "urls"));
.isEqualTo(getInternalState(contextSource, "urls"));
}
@@ -207,7 +207,7 @@ public class LdapTemplateNamespaceHandlerTests {
ContextSource contextSource = ((TransactionAwareContextSourceProxy) outerContextSource).getTarget();
assertThat(new String[] { "ldap://a.localhost:389", "ldap://b.localhost:389" })
.isEqualTo(getInternalState(contextSource, "urls"));
.isEqualTo(getInternalState(contextSource, "urls"));
}
@@ -404,7 +404,7 @@ public class LdapTemplateNamespaceHandlerTests {
assertThat(objectPool.getMinIdlePerKey()).isEqualTo(0);
assertThat(objectPool.getBlockWhenExhausted()).isEqualTo(true);
assertThat(objectPool.getEvictionPolicyClassName())
.isEqualTo(GenericKeyedObjectPoolConfig.DEFAULT_EVICTION_POLICY_CLASS_NAME);
.isEqualTo(GenericKeyedObjectPoolConfig.DEFAULT_EVICTION_POLICY_CLASS_NAME);
assertThat(objectPool.getFairness()).isEqualTo(false);
// ensures the pool is registered
@@ -445,7 +445,7 @@ public class LdapTemplateNamespaceHandlerTests {
assertThat(objectPool.getMinIdlePerKey()).isEqualTo(14);
assertThat(objectPool.getBlockWhenExhausted()).isEqualTo(true);
assertThat(objectPool.getEvictionPolicyClassName())
.isEqualTo("org.springframework.ldap.pool2.DummyEvictionPolicy");
.isEqualTo("org.springframework.ldap.pool2.DummyEvictionPolicy");
assertThat(objectPool.getFairness()).isEqualTo(true);
assertThat(objectPool.getLifo()).isEqualTo(false);

View File

@@ -104,7 +104,7 @@ public class RequestControlDirContextProcessorTests {
this.tested.preProcess(this.ldapContextMock);
verify(this.ldapContextMock)
.setRequestControls(new Control[] { this.requestControl2Mock, this.requestControlMock });
.setRequestControls(new Control[] { this.requestControl2Mock, this.requestControlMock });
}
@Test

View File

@@ -41,7 +41,7 @@ public class CollectingNameClassPairCallbackHandlerTests {
this.tested = new CollectingNameClassPairCallbackHandler() {
public Object getObjectFromNameClassPair(NameClassPair nameClassPair) {
assertThat(nameClassPair)
.isSameAs(CollectingNameClassPairCallbackHandlerTests.this.expectedNameClassPair);
.isSameAs(CollectingNameClassPairCallbackHandlerTests.this.expectedNameClassPair);
return CollectingNameClassPairCallbackHandlerTests.this.expectedResult;
}
};

View File

@@ -144,7 +144,7 @@ public class DefaultLdapClientListTests {
given(this.dirContextMock.list(this.nameMock)).willThrow(pre);
assertThatExceptionOfType(PartialResultException.class)
.isThrownBy(() -> this.tested.list(NAME).toList(NameClassPair::getName));
.isThrownBy(() -> this.tested.list(NAME).toList(NameClassPair::getName));
verify(this.dirContextMock).close();
}
@@ -156,7 +156,7 @@ public class DefaultLdapClientListTests {
given(this.dirContextMock.list(this.nameMock)).willThrow(pre);
assertThatExceptionOfType(PartialResultException.class)
.isThrownBy(() -> this.tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList()));
.isThrownBy(() -> this.tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList()));
verify(this.dirContextMock).close();
}
@@ -202,7 +202,7 @@ public class DefaultLdapClientListTests {
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
given(this.dirContextMock.list(this.nameMock)).willThrow(ne);
assertThatExceptionOfType(LimitExceededException.class)
.isThrownBy(() -> this.tested.list(NAME).toList(NameClassPair::getName));
.isThrownBy(() -> this.tested.list(NAME).toList(NameClassPair::getName));
verify(this.dirContextMock).close();
}
@@ -212,7 +212,7 @@ public class DefaultLdapClientListTests {
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
given(this.dirContextMock.list(this.nameMock)).willThrow(ne);
assertThatExceptionOfType(LimitExceededException.class)
.isThrownBy(() -> this.tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList()));
.isThrownBy(() -> this.tested.list(NAME).toStream(NameClassPair::getName).collect(Collectors.toList()));
verify(this.dirContextMock).close();
}

View File

@@ -101,7 +101,7 @@ public class DefaultLdapClientLookupTests {
whenSearching(this.name).willThrow(ne);
assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected")
.isThrownBy(() -> this.tested.search().name(this.name).toEntry());
.isThrownBy(() -> this.tested.search().name(this.name).toEntry());
verify(this.dirContextMock).close();
}
@@ -142,7 +142,7 @@ public class DefaultLdapClientLookupTests {
AttributesMapper<?> mapper = (attributes) -> attributes;
assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected")
.isThrownBy(() -> this.tested.search().name(this.name).toObject(mapper));
.isThrownBy(() -> this.tested.search().name(this.name).toObject(mapper));
verify(this.dirContextMock).close();
}
@@ -185,7 +185,7 @@ public class DefaultLdapClientLookupTests {
ContextMapper<?> mapper = (ctx) -> ctx;
assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected")
.isThrownBy(() -> this.tested.search().name(this.name).toObject(mapper));
.isThrownBy(() -> this.tested.search().name(this.name).toObject(mapper));
verify(this.dirContextMock).close();
}

View File

@@ -146,9 +146,9 @@ public class DefaultLdapClientTests {
singleSearchResult(searchControlsOneLevel(), searchResult);
this.tested.search().query(
(builder) -> builder.base(this.nameMock).searchScope(SearchScope.ONELEVEL).filter("(ou=somevalue)"))
.toObject(this.contextMapperMock);
this.tested.search()
.query((builder) -> builder.base(this.nameMock).searchScope(SearchScope.ONELEVEL).filter("(ou=somevalue)"))
.toObject(this.contextMapperMock);
verify(this.contextMapperMock).mapFromContext(any());
verify(this.dirContextMock).close();
@@ -164,8 +164,11 @@ public class DefaultLdapClientTests {
singleSearchResultWithStringBase(controls, searchResult);
this.tested.search().query((builder) -> builder.base(DEFAULT_BASE.toString()).searchScope(SearchScope.ONELEVEL)
.filter("(ou=somevalue)")).toObject(this.contextMapperMock);
this.tested.search()
.query((builder) -> builder.base(DEFAULT_BASE.toString())
.searchScope(SearchScope.ONELEVEL)
.filter("(ou=somevalue)"))
.toObject(this.contextMapperMock);
verify(this.contextMapperMock).mapFromContext(any());
verify(this.dirContextMock).close();
@@ -182,9 +185,9 @@ public class DefaultLdapClientTests {
singleSearchResult(controls, searchResult);
this.tested.search().query(
(builder) -> builder.base(this.nameMock).searchScope(SearchScope.SUBTREE).filter("(ou=somevalue)"))
.toObject(this.attributesMapperMock);
this.tested.search()
.query((builder) -> builder.base(this.nameMock).searchScope(SearchScope.SUBTREE).filter("(ou=somevalue)"))
.toObject(this.attributesMapperMock);
verify(this.attributesMapperMock).mapFromAttributes(any());
verify(this.dirContextMock).close();
@@ -201,8 +204,11 @@ public class DefaultLdapClientTests {
singleSearchResultWithStringBase(controls, searchResult);
this.tested.search().query((builder) -> builder.base(DEFAULT_BASE.toString()).searchScope(SearchScope.SUBTREE)
.filter("(ou=somevalue)")).toObject(this.attributesMapperMock);
this.tested.search()
.query((builder) -> builder.base(DEFAULT_BASE.toString())
.searchScope(SearchScope.SUBTREE)
.filter("(ou=somevalue)"))
.toObject(this.attributesMapperMock);
verify(this.attributesMapperMock).mapFromAttributes(any());
verify(this.dirContextMock).close();
@@ -217,12 +223,15 @@ public class DefaultLdapClientTests {
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException("some text");
given(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).willThrow(ne);
argThat(new SearchControlsMatcher(controls))))
.willThrow(ne);
try {
this.tested.search().query(
(builder) -> builder.base(this.nameMock).searchScope(SearchScope.SUBTREE).filter("(ou=somevalue)"))
.toObject(this.attributesMapperMock);
this.tested.search()
.query((builder) -> builder.base(this.nameMock)
.searchScope(SearchScope.SUBTREE)
.filter("(ou=somevalue)"))
.toObject(this.attributesMapperMock);
fail("NameNotFoundException expected");
}
catch (NameNotFoundException expected) {
@@ -240,11 +249,13 @@ public class DefaultLdapClientTests {
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
given(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).willThrow(ne);
argThat(new SearchControlsMatcher(controls))))
.willThrow(ne);
try {
this.tested.search().query((builder) -> builder.base(this.nameMock).filter("(ou=somevalue)"))
.toObject(this.attributesMapperMock);
this.tested.search()
.query((builder) -> builder.base(this.nameMock).filter("(ou=somevalue)"))
.toObject(this.attributesMapperMock);
fail("LimitExceededException expected");
}
catch (LimitExceededException expected) {
@@ -258,8 +269,10 @@ public class DefaultLdapClientTests {
public void verifyThatDefaultSearchControlParametersAreAutomaticallyAppliedInSearch() throws Exception {
Supplier<SearchControls> defaults = mock(Supplier.class);
given(defaults.get()).willReturn(new SearchControls());
LdapClient tested = LdapClient.builder().contextSource(this.contextSourceMock).defaultSearchControls(defaults)
.build();
LdapClient tested = LdapClient.builder()
.contextSource(this.contextSourceMock)
.defaultSearchControls(defaults)
.build();
expectGetReadOnlyContext();
@@ -395,8 +408,11 @@ public class DefaultLdapClientTests {
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
this.tested.bind(this.nameMock).object(expectedObject).attributes(expectedAttributes).replaceExisting(true)
.execute();
this.tested.bind(this.nameMock)
.object(expectedObject)
.attributes(expectedAttributes)
.replaceExisting(true)
.execute();
verify(this.dirContextMock).rebind(this.nameMock, expectedObject, expectedAttributes);
verify(this.dirContextMock).close();
@@ -409,8 +425,11 @@ public class DefaultLdapClientTests {
Object expectedObject = new Object();
BasicAttributes expectedAttributes = new BasicAttributes();
this.tested.bind(DEFAULT_BASE.toString()).object(expectedObject).attributes(expectedAttributes)
.replaceExisting(true).execute();
this.tested.bind(DEFAULT_BASE.toString())
.object(expectedObject)
.attributes(expectedAttributes)
.replaceExisting(true)
.execute();
verify(this.dirContextMock).rebind(DEFAULT_BASE, expectedObject, expectedAttributes);
verify(this.dirContextMock).close();
@@ -516,13 +535,15 @@ public class DefaultLdapClientTests {
@Test
public void testSearch_PartialResult_IgnoreSet() throws Exception {
LdapClient tested = LdapClient.builder().contextSource(this.contextSourceMock)
.ignorePartialResultException(true).build();
LdapClient tested = LdapClient.builder()
.contextSource(this.contextSourceMock)
.ignorePartialResultException(true)
.build();
expectGetReadOnlyContext();
given(this.dirContextMock.search(eq(this.nameMock), anyString(), any()))
.willThrow(javax.naming.PartialResultException.class);
.willThrow(javax.naming.PartialResultException.class);
tested.search().name(this.nameMock).toEntryStream();
@@ -542,7 +563,7 @@ public class DefaultLdapClientTests {
singleSearchResult(searchControlsRecursive(), searchResult);
given(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
.willReturn(this.authenticatedContextMock);
.willReturn(this.authenticatedContextMock);
given(entryContextMapper.mapWithContext(any(), any())).willReturn(new Object());
LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)");
@@ -584,7 +605,7 @@ public class DefaultLdapClientTests {
LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)");
assertThatExceptionOfType(EmptyResultDataAccessException.class)
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
verify(this.dirContextMock).close();
}
@@ -598,7 +619,9 @@ public class DefaultLdapClientTests {
LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)");
assertThatExceptionOfType(EmptyResultDataAccessException.class).isThrownBy(() -> this.tested.authenticate()
.query(query).password("password").execute((ctx, entry) -> new Object()));
.query(query)
.password("password")
.execute((ctx, entry) -> new Object()));
verify(this.dirContextMock).close();
}
@@ -614,17 +637,18 @@ public class DefaultLdapClientTests {
singleSearchResult(searchControlsRecursive(), searchResult);
given(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
.willThrow(new UncategorizedLdapException("Authentication failed"));
.willThrow(new UncategorizedLdapException("Authentication failed"));
LdapQuery query = LdapQueryBuilder.query().base(this.nameMock).filter("(ou=somevalue)");
assertThatExceptionOfType(UncategorizedLdapException.class)
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
verify(this.dirContextMock).close();
}
private void noSearchResults(SearchControls controls) throws Exception {
given(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).willReturn(this.namingEnumerationMock);
argThat(new SearchControlsMatcher(controls))))
.willReturn(this.namingEnumerationMock);
given(this.namingEnumerationMock.hasMore()).willReturn(false);
}
@@ -635,7 +659,8 @@ public class DefaultLdapClientTests {
private void setupSearchResults(SearchControls controls, SearchResult... searchResults) throws Exception {
given(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).willReturn(this.namingEnumerationMock);
argThat(new SearchControlsMatcher(controls))))
.willReturn(this.namingEnumerationMock);
if (searchResults.length == 1) {
given(this.namingEnumerationMock.hasMore()).willReturn(true, false);
@@ -652,7 +677,8 @@ public class DefaultLdapClientTests {
private void singleSearchResultWithStringBase(SearchControls controls, SearchResult searchResult) throws Exception {
given(this.dirContextMock.search(eq(DEFAULT_BASE), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).willReturn(this.namingEnumerationMock);
argThat(new SearchControlsMatcher(controls))))
.willReturn(this.namingEnumerationMock);
given(this.namingEnumerationMock.hasMore()).willReturn(true, false);
given(this.namingEnumerationMock.next()).willReturn(searchResult);

View File

@@ -217,7 +217,8 @@ public class LdapTemplateTests {
javax.naming.NameNotFoundException ne = new javax.naming.NameNotFoundException("some text");
given(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).willThrow(ne);
argThat(new SearchControlsMatcher(controls))))
.willThrow(ne);
try {
this.tested.search(this.nameMock, "(ou=somevalue)", this.handlerMock);
@@ -238,7 +239,8 @@ public class LdapTemplateTests {
javax.naming.LimitExceededException ne = new javax.naming.LimitExceededException();
given(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).willThrow(ne);
argThat(new SearchControlsMatcher(controls))))
.willThrow(ne);
try {
this.tested.search(this.nameMock, "(ou=somevalue)", this.handlerMock);
@@ -617,7 +619,7 @@ public class LdapTemplateTests {
given(this.contextSourceMock.getReadOnlyContext()).willReturn(this.dirContextMock);
given(this.odmMock.filterFor(expectedClass, new EqualsFilter("ou", "somevalue")))
.willReturn(new EqualsFilter("ou", "somevalue"));
.willReturn(new EqualsFilter("ou", "somevalue"));
DirContextAdapter expectedObject = new DirContextAdapter();
SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes());
@@ -640,7 +642,7 @@ public class LdapTemplateTests {
given(this.contextSourceMock.getReadOnlyContext()).willReturn(this.dirContextMock);
given(this.odmMock.filterFor(expectedClass, new EqualsFilter("ou", "somevalue")))
.willReturn(new EqualsFilter("ou", "somevalue"));
.willReturn(new EqualsFilter("ou", "somevalue"));
noSearchResults(searchControlsRecursive());
@@ -663,7 +665,7 @@ public class LdapTemplateTests {
given(this.contextSourceMock.getReadOnlyContext()).willReturn(this.dirContextMock);
given(this.odmMock.filterFor(expectedClass, new EqualsFilter("ou", "somevalue")))
.willReturn(new EqualsFilter("ou", "somevalue"));
.willReturn(new EqualsFilter("ou", "somevalue"));
DirContextAdapter expectedObject = new DirContextAdapter();
SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes());
@@ -1508,7 +1510,7 @@ public class LdapTemplateTests {
expectGetReadOnlyContext();
given(this.searchExecutorMock.executeSearch(this.dirContextMock))
.willThrow(new javax.naming.NameNotFoundException());
.willThrow(new javax.naming.NameNotFoundException());
try {
this.tested.search(this.searchExecutorMock, this.handlerMock);
@@ -1548,7 +1550,7 @@ public class LdapTemplateTests {
expectGetReadOnlyContext();
given(this.searchExecutorMock.executeSearch(this.dirContextMock))
.willThrow(new javax.naming.PartialResultException());
.willThrow(new javax.naming.PartialResultException());
this.tested.search(this.searchExecutorMock, this.handlerMock, this.dirContextProcessorMock);
@@ -1679,7 +1681,8 @@ public class LdapTemplateTests {
SearchResult searchResult = new SearchResult("", expectedObject, new BasicAttributes());
given(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).willReturn(this.namingEnumerationMock);
argThat(new SearchControlsMatcher(controls))))
.willReturn(this.namingEnumerationMock);
given(this.namingEnumerationMock.hasMore()).willReturn(true, true, false);
given(this.namingEnumerationMock.next()).willReturn(searchResult, searchResult);
@@ -1728,7 +1731,7 @@ public class LdapTemplateTests {
singleSearchResult(searchControlsRecursive(), searchResult);
given(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
.willReturn(this.authenticatedContextMock);
.willReturn(this.authenticatedContextMock);
this.entryContextCallbackMock.executeWithContext(this.authenticatedContextMock, new LdapEntryIdentification(
LdapUtils.newLdapName("cn=john doe,dc=jayway,dc=se"), LdapUtils.newLdapName("cn=john doe")));
@@ -1784,7 +1787,7 @@ public class LdapTemplateTests {
given(this.contextSourceMock.getReadOnlyContext()).willReturn(this.dirContextMock);
given(this.dirContextMock.search(any(Name.class), any(String.class), any(SearchControls.class)))
.willReturn(this.namingEnumerationMock);
.willReturn(this.namingEnumerationMock);
given(this.namingEnumerationMock.hasMore()).willReturn(false);
@@ -1804,7 +1807,7 @@ public class LdapTemplateTests {
given(this.contextSourceMock.getReadOnlyContext()).willReturn(this.dirContextMock);
given(this.dirContextMock.search(any(Name.class), any(String.class), any(SearchControls.class)))
.willReturn(this.namingEnumerationMock);
.willReturn(this.namingEnumerationMock);
given(this.namingEnumerationMock.hasMore()).willReturn(false);
@@ -1828,7 +1831,7 @@ public class LdapTemplateTests {
singleSearchResult(searchControlsRecursive(), searchResult);
given(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
.willThrow(new UncategorizedLdapException("Authentication failed"));
.willThrow(new UncategorizedLdapException("Authentication failed"));
boolean result = this.tested.authenticate(this.nameMock, "(ou=somevalue)", "password",
this.entryContextCallbackMock);
@@ -1849,10 +1852,10 @@ public class LdapTemplateTests {
singleSearchResult(searchControlsRecursive(), searchResult);
given(this.contextSourceMock.getContext("cn=john doe,dc=jayway,dc=se", "password"))
.willReturn(this.authenticatedContextMock);
.willReturn(this.authenticatedContextMock);
willThrow(new UncategorizedLdapException("Authentication failed")).given(this.entryContextCallbackMock)
.executeWithContext(this.authenticatedContextMock, new LdapEntryIdentification(
LdapUtils.newLdapName("cn=john doe,dc=jayway,dc=se"), LdapUtils.newLdapName("cn=john doe")));
.executeWithContext(this.authenticatedContextMock, new LdapEntryIdentification(
LdapUtils.newLdapName("cn=john doe,dc=jayway,dc=se"), LdapUtils.newLdapName("cn=john doe")));
boolean result = this.tested.authenticate(this.nameMock, "(ou=somevalue)", "password",
this.entryContextCallbackMock);
@@ -1865,7 +1868,8 @@ public class LdapTemplateTests {
private void noSearchResults(SearchControls controls) throws Exception {
given(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).willReturn(this.namingEnumerationMock);
argThat(new SearchControlsMatcher(controls))))
.willReturn(this.namingEnumerationMock);
given(this.namingEnumerationMock.hasMore()).willReturn(false);
}
@@ -1876,7 +1880,8 @@ public class LdapTemplateTests {
private void setupSearchResults(SearchControls controls, SearchResult... searchResults) throws Exception {
given(this.dirContextMock.search(eq(this.nameMock), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).willReturn(this.namingEnumerationMock);
argThat(new SearchControlsMatcher(controls))))
.willReturn(this.namingEnumerationMock);
if (searchResults.length == 1) {
given(this.namingEnumerationMock.hasMore()).willReturn(true, false);
@@ -1893,7 +1898,8 @@ public class LdapTemplateTests {
private void singleSearchResultWithStringBase(SearchControls controls, SearchResult searchResult) throws Exception {
given(this.dirContextMock.search(eq(DEFAULT_BASE_STRING), eq("(ou=somevalue)"),
argThat(new SearchControlsMatcher(controls)))).willReturn(this.namingEnumerationMock);
argThat(new SearchControlsMatcher(controls))))
.willReturn(this.namingEnumerationMock);
given(this.namingEnumerationMock.hasMore()).willReturn(true, false);
given(this.namingEnumerationMock.next()).willReturn(searchResult);

View File

@@ -123,7 +123,7 @@ public class BaseLdapPathBeanPostProcessorTests {
@Test
public void testGetAbstractContextSourceFromApplicationContext() throws Exception {
given(this.applicationContextMock.getBeanNamesForType(BaseLdapPathSource.class))
.willReturn(new String[] { "contextSource" });
.willReturn(new String[] { "contextSource" });
final LdapContextSource expectedContextSource = new LdapContextSource();
HashMap<String, BaseLdapPathSource> expectedBeans = new HashMap<String, BaseLdapPathSource>() {

View File

@@ -73,7 +73,7 @@ public class LdapContextSourceTests {
// check that base was added to environment
assertThat(env.get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY))
.isEqualTo(LdapUtils.newLdapName("dc=some example,dc=se"));
.isEqualTo(LdapUtils.newLdapName("dc=some example,dc=se"));
// Verify that changing values does not change the environment values.
this.tested.setBase("dc=other,dc=se");
@@ -87,7 +87,7 @@ public class LdapContextSourceTests {
assertThat(env.get(Context.SECURITY_CREDENTIALS)).isNull();
assertThat(env.get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY))
.isEqualTo(LdapUtils.newLdapName("dc=some example,dc=se"));
.isEqualTo(LdapUtils.newLdapName("dc=some example,dc=se"));
}
@Test
@@ -155,7 +155,7 @@ public class LdapContextSourceTests {
// check that base was added to environment
assertThat(env.get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY))
.isEqualTo(LdapUtils.newLdapName("dc=example,dc=se"));
.isEqualTo(LdapUtils.newLdapName("dc=example,dc=se"));
}
@Test

View File

@@ -49,8 +49,9 @@ public class AndFilterTests {
@Test
public void testThree() {
AndFilter aq = new AndFilter().and(new EqualsFilter("a", "b")).and(new EqualsFilter("c", "d"))
.and(new EqualsFilter("e", "f"));
AndFilter aq = new AndFilter().and(new EqualsFilter("a", "b"))
.and(new EqualsFilter("c", "d"))
.and(new EqualsFilter("e", "f"));
assertThat(aq.encode()).isEqualTo("(&(a=b)(c=d)(e=f))");
}

View File

@@ -50,8 +50,9 @@ public class OrFilterTests {
@Test
public void testThree() {
OrFilter of = new OrFilter().or(new EqualsFilter("a", "b")).or(new EqualsFilter("c", "d"))
.or(new EqualsFilter("e", "f"));
OrFilter of = new OrFilter().or(new EqualsFilter("a", "b"))
.or(new EqualsFilter("c", "d"))
.or(new EqualsFilter("e", "f"));
assertThat(of.encode()).isEqualTo("(|(a=b)(c=d)(e=f))");
}

View File

@@ -68,9 +68,16 @@ public class DefaultObjectDirectoryMapperTests {
DefaultObjectDirectoryMapper.EntityData entityData = this.tested.getMetaDataMap().get(UnitTestPerson.class);
assertThat(entityData).isNotNull();
assertThat(entityData.ocFilter).isEqualTo(LdapQueryBuilder.query().where("objectclass").is("inetOrgPerson")
.and("objectclass").is("organizationalPerson").and("objectclass").is("person").and("objectclass")
.is("top").filter());
assertThat(entityData.ocFilter).isEqualTo(LdapQueryBuilder.query()
.where("objectclass")
.is("inetOrgPerson")
.and("objectclass")
.is("organizationalPerson")
.and("objectclass")
.is("person")
.and("objectclass")
.is("top")
.filter());
assertThat(entityData.metaData).hasSize(8);

View File

@@ -422,7 +422,7 @@ public class DelegatingContextTests extends AbstractPoolTestCase {
@Test
public void testPoolExceptionOnClose() throws Exception {
willThrow(new Exception("Fake Pool returnObject Exception")).given(keyedObjectPoolMock)
.returnObject(DirContextType.READ_ONLY, contextMock);
.returnObject(DirContextType.READ_ONLY, contextMock);
final DelegatingContext delegatingContext = new DelegatingContext(keyedObjectPoolMock, contextMock,
DirContextType.READ_ONLY);

View File

@@ -185,7 +185,7 @@ public class DirContextPoolableObjectFactoryTests extends AbstractPoolTestCase {
DirContextValidator secondDirContextValidatorMock = mock(DirContextValidator.class);
given(secondDirContextValidatorMock.validateDirContext(DirContextType.READ_ONLY, dirContextMock))
.willThrow(new RuntimeException("Failed to validate"));
.willThrow(new RuntimeException("Failed to validate"));
objectFactory.setDirContextValidator(secondDirContextValidatorMock);
final boolean valid2 = objectFactory.validateObject(DirContextType.READ_ONLY, dirContextMock);

View File

@@ -52,7 +52,7 @@ public class DefaultDirContextValidatorTests {
public void testSearchScopeOneLevelScopeSetInConstructorIsUsed() throws Exception {
DefaultDirContextValidator tested = new DefaultDirContextValidator(SearchControls.ONELEVEL_SCOPE);
assertThat(tested.getSearchControls().getSearchScope()).as("ONELEVEL_SCOPE, ")
.isEqualTo(SearchControls.ONELEVEL_SCOPE);
.isEqualTo(SearchControls.ONELEVEL_SCOPE);
}
// LDAP-189
@@ -60,7 +60,7 @@ public class DefaultDirContextValidatorTests {
public void testSearchScopeSubTreeScopeSetInConstructorIsUsed() throws Exception {
DefaultDirContextValidator tested = new DefaultDirContextValidator(SearchControls.SUBTREE_SCOPE);
assertThat(tested.getSearchControls().getSearchScope()).as("SUBTREE_SCOPE, ")
.isEqualTo(SearchControls.SUBTREE_SCOPE);
.isEqualTo(SearchControls.SUBTREE_SCOPE);
}
// LDAP-189
@@ -68,7 +68,7 @@ public class DefaultDirContextValidatorTests {
public void testSearchScopeObjectScopeSetInConstructorIsUsed() throws Exception {
DefaultDirContextValidator tested = new DefaultDirContextValidator(SearchControls.OBJECT_SCOPE);
assertThat(tested.getSearchControls().getSearchScope()).as("OBJECT_SCOPE, ")
.isEqualTo(SearchControls.OBJECT_SCOPE);
.isEqualTo(SearchControls.OBJECT_SCOPE);
}
@Test
@@ -164,7 +164,7 @@ public class DefaultDirContextValidatorTests {
final SearchControls searchControls = dirContextValidator.getSearchControls();
given(this.dirContextMock.search(baseName, filter, searchControls))
.willThrow(new NamingException("Failed to search"));
.willThrow(new NamingException("Failed to search"));
final boolean valid = dirContextValidator.validateDirContext(DirContextType.READ_ONLY, this.dirContextMock);

View File

@@ -422,7 +422,7 @@ public class DelegatingContextTests extends AbstractPoolTestCase {
@Test
public void testPoolExceptionOnClose() throws Exception {
willThrow(new Exception("Fake Pool returnObject Exception")).given(keyedObjectPoolMock)
.returnObject(DirContextType.READ_ONLY, contextMock);
.returnObject(DirContextType.READ_ONLY, contextMock);
final DelegatingContext delegatingContext = new DelegatingContext(keyedObjectPoolMock, contextMock,
DirContextType.READ_ONLY);

View File

@@ -192,7 +192,7 @@ public class DirContextPooledObjectFactoryTests extends AbstractPoolTestCase {
DirContextValidator secondDirContextValidatorMock = mock(DirContextValidator.class);
given(secondDirContextValidatorMock.validateDirContext(DirContextType.READ_ONLY, dirContextMock))
.willThrow(new RuntimeException("Failed to validate"));
.willThrow(new RuntimeException("Failed to validate"));
objectFactory.setDirContextValidator(secondDirContextValidatorMock);
final boolean valid2 = objectFactory.validateObject(DirContextType.READ_ONLY, pooledObject);

View File

@@ -103,8 +103,15 @@ public class LdapQueryBuilderTests {
@Test
public void testBuildSimpleAnd() {
LdapQuery query = LdapQueryBuilder.query().base("dc=261consulting, dc=com").searchScope(SearchScope.ONELEVEL)
.timeLimit(200).countLimit(221).where("objectclass").is("person").and("cn").is("John Doe");
LdapQuery query = LdapQueryBuilder.query()
.base("dc=261consulting, dc=com")
.searchScope(SearchScope.ONELEVEL)
.timeLimit(200)
.countLimit(221)
.where("objectclass")
.is("person")
.and("cn")
.is("John Doe");
assertThat(query.base()).isEqualTo(LdapUtils.newLdapName("dc=261consulting, dc=com"));
assertThat(query.searchScope()).isEqualTo(SearchScope.ONELEVEL);
@@ -122,8 +129,12 @@ public class LdapQueryBuilderTests {
@Test
public void buildAndOrPrecedence() {
LdapQuery result = LdapQueryBuilder.query().where("objectclass").is("person").and("cn").is("John Doe")
.or(LdapQueryBuilder.query().where("sn").is("Doe"));
LdapQuery result = LdapQueryBuilder.query()
.where("objectclass")
.is("person")
.and("cn")
.is("John Doe")
.or(LdapQueryBuilder.query().where("sn").is("Doe"));
assertThat(result.filter().encode()).isEqualTo("(|(&(objectclass=person)(cn=John Doe))(sn=Doe))");
}
@@ -136,8 +147,10 @@ public class LdapQueryBuilderTests {
@Test
public void buildNestedAnd() {
LdapQuery result = LdapQueryBuilder.query().where("objectclass").is("person")
.and(LdapQueryBuilder.query().where("sn").is("Doe").or("sn").like("Die"));
LdapQuery result = LdapQueryBuilder.query()
.where("objectclass")
.is("person")
.and(LdapQueryBuilder.query().where("sn").is("Doe").or("sn").like("Die"));
assertThat(result.filter().encode()).isEqualTo("(&(objectclass=person)(|(sn=Doe)(sn=Die)))");
}

View File

@@ -39,8 +39,8 @@ public class LdapNameBuilderTests {
@Test
public void testAddComponentToBaseName() {
LdapNameBuilder tested = LdapNameBuilder.newInstance(LdapUtils.newLdapName("dc=com")).add("dc",
"261consulting");
LdapNameBuilder tested = LdapNameBuilder.newInstance(LdapUtils.newLdapName("dc=com"))
.add("dc", "261consulting");
assertThat(tested.build().toString()).isEqualTo("dc=261consulting,dc=com");
}
@@ -53,7 +53,7 @@ public class LdapNameBuilderTests {
@Test
public void testAddNameToBaseString() {
LdapNameBuilder tested = LdapNameBuilder.newInstance("dc=261consulting,dc=com")
.add(LdapUtils.newLdapName("ou=people"));
.add(LdapUtils.newLdapName("ou=people"));
assertThat(tested.build().toString()).isEqualTo("ou=people,dc=261consulting,dc=com");
}

View File

@@ -302,138 +302,138 @@ public class LdapUtilsTests {
// Test the Exceptions in the javax.naming package
assertThat(LdapUtils.convertLdapException(new javax.naming.directory.AttributeInUseException()).getClass())
.isEqualTo(org.springframework.ldap.AttributeInUseException.class);
.isEqualTo(org.springframework.ldap.AttributeInUseException.class);
assertThat(
LdapUtils.convertLdapException(new javax.naming.directory.AttributeModificationException()).getClass())
.isEqualTo(org.springframework.ldap.AttributeModificationException.class);
.isEqualTo(org.springframework.ldap.AttributeModificationException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.CannotProceedException()).getClass())
.isEqualTo(org.springframework.ldap.CannotProceedException.class);
.isEqualTo(org.springframework.ldap.CannotProceedException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.CommunicationException()).getClass())
.isEqualTo(org.springframework.ldap.CommunicationException.class);
.isEqualTo(org.springframework.ldap.CommunicationException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.ConfigurationException()).getClass())
.isEqualTo(org.springframework.ldap.ConfigurationException.class);
.isEqualTo(org.springframework.ldap.ConfigurationException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.ContextNotEmptyException()).getClass())
.isEqualTo(org.springframework.ldap.ContextNotEmptyException.class);
.isEqualTo(org.springframework.ldap.ContextNotEmptyException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.InsufficientResourcesException()).getClass())
.isEqualTo(org.springframework.ldap.InsufficientResourcesException.class);
.isEqualTo(org.springframework.ldap.InsufficientResourcesException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.InterruptedNamingException()).getClass())
.isEqualTo(org.springframework.ldap.InterruptedNamingException.class);
.isEqualTo(org.springframework.ldap.InterruptedNamingException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.directory.InvalidAttributeIdentifierException())
.getClass()).isEqualTo(org.springframework.ldap.InvalidAttributeIdentifierException.class);
.getClass()).isEqualTo(org.springframework.ldap.InvalidAttributeIdentifierException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.directory.InvalidAttributesException()).getClass())
.isEqualTo(org.springframework.ldap.InvalidAttributesException.class);
.isEqualTo(org.springframework.ldap.InvalidAttributesException.class);
assertThat(
LdapUtils.convertLdapException(new javax.naming.directory.InvalidAttributeValueException()).getClass())
.isEqualTo(org.springframework.ldap.InvalidAttributeValueException.class);
.isEqualTo(org.springframework.ldap.InvalidAttributeValueException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.InvalidNameException()).getClass())
.isEqualTo(org.springframework.ldap.InvalidNameException.class);
.isEqualTo(org.springframework.ldap.InvalidNameException.class);
assertThat(
LdapUtils.convertLdapException(new javax.naming.directory.InvalidSearchControlsException()).getClass())
.isEqualTo(org.springframework.ldap.InvalidSearchControlsException.class);
.isEqualTo(org.springframework.ldap.InvalidSearchControlsException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.directory.InvalidSearchFilterException()).getClass())
.isEqualTo(org.springframework.ldap.InvalidSearchFilterException.class);
.isEqualTo(org.springframework.ldap.InvalidSearchFilterException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.SizeLimitExceededException()).getClass())
.isEqualTo(org.springframework.ldap.SizeLimitExceededException.class);
.isEqualTo(org.springframework.ldap.SizeLimitExceededException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.TimeLimitExceededException()).getClass())
.isEqualTo(org.springframework.ldap.TimeLimitExceededException.class);
.isEqualTo(org.springframework.ldap.TimeLimitExceededException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.LimitExceededException()).getClass())
.isEqualTo(org.springframework.ldap.LimitExceededException.class);
.isEqualTo(org.springframework.ldap.LimitExceededException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.LinkLoopException()).getClass())
.isEqualTo(org.springframework.ldap.LinkLoopException.class);
.isEqualTo(org.springframework.ldap.LinkLoopException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.MalformedLinkException()).getClass())
.isEqualTo(org.springframework.ldap.MalformedLinkException.class);
.isEqualTo(org.springframework.ldap.MalformedLinkException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.LinkException()).getClass())
.isEqualTo(org.springframework.ldap.LinkException.class);
.isEqualTo(org.springframework.ldap.LinkException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.NameAlreadyBoundException()).getClass())
.isEqualTo(org.springframework.ldap.NameAlreadyBoundException.class);
.isEqualTo(org.springframework.ldap.NameAlreadyBoundException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.NameNotFoundException()).getClass())
.isEqualTo(org.springframework.ldap.NameNotFoundException.class);
.isEqualTo(org.springframework.ldap.NameNotFoundException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.NoPermissionException()).getClass())
.isEqualTo(org.springframework.ldap.NoPermissionException.class);
.isEqualTo(org.springframework.ldap.NoPermissionException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.AuthenticationException()).getClass())
.isEqualTo(org.springframework.ldap.AuthenticationException.class);
.isEqualTo(org.springframework.ldap.AuthenticationException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.AuthenticationNotSupportedException()).getClass())
.isEqualTo(org.springframework.ldap.AuthenticationNotSupportedException.class);
.isEqualTo(org.springframework.ldap.AuthenticationNotSupportedException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.NoInitialContextException()).getClass())
.isEqualTo(org.springframework.ldap.NoInitialContextException.class);
.isEqualTo(org.springframework.ldap.NoInitialContextException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.directory.NoSuchAttributeException()).getClass())
.isEqualTo(org.springframework.ldap.NoSuchAttributeException.class);
.isEqualTo(org.springframework.ldap.NoSuchAttributeException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.NotContextException()).getClass())
.isEqualTo(org.springframework.ldap.NotContextException.class);
.isEqualTo(org.springframework.ldap.NotContextException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.OperationNotSupportedException()).getClass())
.isEqualTo(org.springframework.ldap.OperationNotSupportedException.class);
.isEqualTo(org.springframework.ldap.OperationNotSupportedException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.PartialResultException()).getClass())
.isEqualTo(org.springframework.ldap.PartialResultException.class);
.isEqualTo(org.springframework.ldap.PartialResultException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.directory.SchemaViolationException()).getClass())
.isEqualTo(org.springframework.ldap.SchemaViolationException.class);
.isEqualTo(org.springframework.ldap.SchemaViolationException.class);
assertThat(LdapUtils.convertLdapException(new javax.naming.ServiceUnavailableException()).getClass())
.isEqualTo(org.springframework.ldap.ServiceUnavailableException.class);
.isEqualTo(org.springframework.ldap.ServiceUnavailableException.class);
// Test Exceptions that extend javax.naming packaage extensions
assertThat(LdapUtils.convertLdapException(new MockAttributeInUseException()).getClass())
.isEqualTo(org.springframework.ldap.AttributeInUseException.class);
.isEqualTo(org.springframework.ldap.AttributeInUseException.class);
assertThat(LdapUtils.convertLdapException(new MockAttributeModificationException()).getClass())
.isEqualTo(org.springframework.ldap.AttributeModificationException.class);
.isEqualTo(org.springframework.ldap.AttributeModificationException.class);
assertThat(LdapUtils.convertLdapException(new MockCannotProceedException()).getClass())
.isEqualTo(org.springframework.ldap.CannotProceedException.class);
.isEqualTo(org.springframework.ldap.CannotProceedException.class);
assertThat(LdapUtils.convertLdapException(new MockCommunicationException()).getClass())
.isEqualTo(org.springframework.ldap.CommunicationException.class);
.isEqualTo(org.springframework.ldap.CommunicationException.class);
assertThat(LdapUtils.convertLdapException(new MockConfigurationException()).getClass())
.isEqualTo(org.springframework.ldap.ConfigurationException.class);
.isEqualTo(org.springframework.ldap.ConfigurationException.class);
assertThat(LdapUtils.convertLdapException(new MockContextNotEmptyException()).getClass())
.isEqualTo(org.springframework.ldap.ContextNotEmptyException.class);
.isEqualTo(org.springframework.ldap.ContextNotEmptyException.class);
assertThat(LdapUtils.convertLdapException(new MockInsufficientResourcesException()).getClass())
.isEqualTo(org.springframework.ldap.InsufficientResourcesException.class);
.isEqualTo(org.springframework.ldap.InsufficientResourcesException.class);
assertThat(LdapUtils.convertLdapException(new MockInterruptedNamingException()).getClass())
.isEqualTo(org.springframework.ldap.InterruptedNamingException.class);
.isEqualTo(org.springframework.ldap.InterruptedNamingException.class);
assertThat(LdapUtils.convertLdapException(new MockInvalidAttributeIdentifierException()).getClass())
.isEqualTo(org.springframework.ldap.InvalidAttributeIdentifierException.class);
.isEqualTo(org.springframework.ldap.InvalidAttributeIdentifierException.class);
assertThat(LdapUtils.convertLdapException(new MockInvalidAttributesException()).getClass())
.isEqualTo(org.springframework.ldap.InvalidAttributesException.class);
.isEqualTo(org.springframework.ldap.InvalidAttributesException.class);
assertThat(LdapUtils.convertLdapException(new MockInvalidAttributeValueException()).getClass())
.isEqualTo(org.springframework.ldap.InvalidAttributeValueException.class);
.isEqualTo(org.springframework.ldap.InvalidAttributeValueException.class);
assertThat(LdapUtils.convertLdapException(new MockInvalidNameException()).getClass())
.isEqualTo(org.springframework.ldap.InvalidNameException.class);
.isEqualTo(org.springframework.ldap.InvalidNameException.class);
assertThat(LdapUtils.convertLdapException(new MockInvalidSearchControlsException()).getClass())
.isEqualTo(org.springframework.ldap.InvalidSearchControlsException.class);
.isEqualTo(org.springframework.ldap.InvalidSearchControlsException.class);
assertThat(LdapUtils.convertLdapException(new MockInvalidSearchFilterException()).getClass())
.isEqualTo(org.springframework.ldap.InvalidSearchFilterException.class);
.isEqualTo(org.springframework.ldap.InvalidSearchFilterException.class);
assertThat(LdapUtils.convertLdapException(new MockSizeLimitExceededException()).getClass())
.isEqualTo(org.springframework.ldap.SizeLimitExceededException.class);
.isEqualTo(org.springframework.ldap.SizeLimitExceededException.class);
assertThat(LdapUtils.convertLdapException(new MockTimeLimitExceededException()).getClass())
.isEqualTo(org.springframework.ldap.TimeLimitExceededException.class);
.isEqualTo(org.springframework.ldap.TimeLimitExceededException.class);
assertThat(LdapUtils.convertLdapException(new MockLimitExceededException()).getClass())
.isEqualTo(org.springframework.ldap.LimitExceededException.class);
.isEqualTo(org.springframework.ldap.LimitExceededException.class);
assertThat(LdapUtils.convertLdapException(new MockLinkLoopException()).getClass())
.isEqualTo(org.springframework.ldap.LinkLoopException.class);
.isEqualTo(org.springframework.ldap.LinkLoopException.class);
assertThat(LdapUtils.convertLdapException(new MockMalformedLinkException()).getClass())
.isEqualTo(org.springframework.ldap.MalformedLinkException.class);
.isEqualTo(org.springframework.ldap.MalformedLinkException.class);
assertThat(LdapUtils.convertLdapException(new MockLinkException()).getClass())
.isEqualTo(org.springframework.ldap.LinkException.class);
.isEqualTo(org.springframework.ldap.LinkException.class);
assertThat(LdapUtils.convertLdapException(new MockNameAlreadyBoundException()).getClass())
.isEqualTo(org.springframework.ldap.NameAlreadyBoundException.class);
.isEqualTo(org.springframework.ldap.NameAlreadyBoundException.class);
assertThat(LdapUtils.convertLdapException(new MockNameNotFoundException()).getClass())
.isEqualTo(org.springframework.ldap.NameNotFoundException.class);
.isEqualTo(org.springframework.ldap.NameNotFoundException.class);
assertThat(LdapUtils.convertLdapException(new MockNoPermissionException()).getClass())
.isEqualTo(org.springframework.ldap.NoPermissionException.class);
.isEqualTo(org.springframework.ldap.NoPermissionException.class);
assertThat(LdapUtils.convertLdapException(new MockAuthenticationException()).getClass())
.isEqualTo(org.springframework.ldap.AuthenticationException.class);
.isEqualTo(org.springframework.ldap.AuthenticationException.class);
assertThat(LdapUtils.convertLdapException(new MockAuthenticationNotSupportedException()).getClass())
.isEqualTo(org.springframework.ldap.AuthenticationNotSupportedException.class);
.isEqualTo(org.springframework.ldap.AuthenticationNotSupportedException.class);
assertThat(LdapUtils.convertLdapException(new MockNoInitialContextException()).getClass())
.isEqualTo(org.springframework.ldap.NoInitialContextException.class);
.isEqualTo(org.springframework.ldap.NoInitialContextException.class);
assertThat(LdapUtils.convertLdapException(new MockNoSuchAttributeException()).getClass())
.isEqualTo(org.springframework.ldap.NoSuchAttributeException.class);
.isEqualTo(org.springframework.ldap.NoSuchAttributeException.class);
assertThat(LdapUtils.convertLdapException(new MockNotContextException()).getClass())
.isEqualTo(org.springframework.ldap.NotContextException.class);
.isEqualTo(org.springframework.ldap.NotContextException.class);
assertThat(LdapUtils.convertLdapException(new MockOperationNotSupportedException()).getClass())
.isEqualTo(org.springframework.ldap.OperationNotSupportedException.class);
.isEqualTo(org.springframework.ldap.OperationNotSupportedException.class);
assertThat(LdapUtils.convertLdapException(new MockPartialResultException()).getClass())
.isEqualTo(org.springframework.ldap.PartialResultException.class);
.isEqualTo(org.springframework.ldap.PartialResultException.class);
assertThat(LdapUtils.convertLdapException(new MockSchemaViolationException()).getClass())
.isEqualTo(org.springframework.ldap.SchemaViolationException.class);
.isEqualTo(org.springframework.ldap.SchemaViolationException.class);
assertThat(LdapUtils.convertLdapException(new MockServiceUnavailableException()).getClass())
.isEqualTo(org.springframework.ldap.ServiceUnavailableException.class);
.isEqualTo(org.springframework.ldap.ServiceUnavailableException.class);
}
public class MockAttributeInUseException extends javax.naming.directory.AttributeInUseException {

View File

@@ -48,7 +48,7 @@ public class BindOperationRecorderTests {
BasicAttributes expectedAttributes = new BasicAttributes();
// Perform test.
CompensatingTransactionOperationExecutor operation = tested
.recordOperation(new Object[] { expectedDn, expectedObject, expectedAttributes });
.recordOperation(new Object[] { expectedDn, expectedObject, expectedAttributes });
assertThat(operation instanceof BindOperationExecutor).isTrue();
BindOperationExecutor rollbackOperation = (BindOperationExecutor) operation;
@@ -67,7 +67,7 @@ public class BindOperationRecorderTests {
BasicAttributes expectedAttributes = new BasicAttributes();
// Perform test.
CompensatingTransactionOperationExecutor operation = tested
.recordOperation(new Object[] { expectedDn, expectedObject, expectedAttributes });
.recordOperation(new Object[] { expectedDn, expectedObject, expectedAttributes });
assertThat(operation instanceof BindOperationExecutor).isTrue();
BindOperationExecutor rollbackOperation = (BindOperationExecutor) operation;

View File

@@ -81,12 +81,12 @@ public class ModifyAttributesOperationRecorderTests {
given(this.attributesMapperMock.hasMore()).willReturn(true, false);
given(this.attributesMapperMock.getAttributesForLookup()).willReturn(new String[] { "attribute1" });
given(this.ldapOperationsMock.lookup(expectedName, new String[] { "attribute1" }, this.attributesMapperMock))
.willReturn(expectedAttributes);
.willReturn(expectedAttributes);
given(this.attributesMapperMock.getCollectedAttributes()).willReturn(expectedAttributes);
// Perform test
CompensatingTransactionOperationExecutor operation = this.tested
.recordOperation(new Object[] { expectedName, incomingMods });
.recordOperation(new Object[] { expectedName, incomingMods });
// Verify outcome
assertThat(operation instanceof ModifyAttributesOperationExecutor).isTrue();

View File

@@ -57,7 +57,7 @@ public class RebindOperationRecorderTests {
// perform test
CompensatingTransactionOperationExecutor result = tested
.recordOperation(new Object[] { expectedDn, expectedObject, expectedAttributes });
.recordOperation(new Object[] { expectedDn, expectedObject, expectedAttributes });
assertThat(result instanceof RebindOperationExecutor).isTrue();
RebindOperationExecutor rollbackOperation = (RebindOperationExecutor) result;
assertThat(rollbackOperation.getLdapOperations()).isSameAs(this.ldapOperationsMock);

View File

@@ -40,7 +40,7 @@ public class RenameOperationRecorderTests {
// Perform test
CompensatingTransactionOperationExecutor operation = tested
.recordOperation(new Object[] { "ou=someou", "ou=newou" });
.recordOperation(new Object[] { "ou=someou", "ou=newou" });
assertThat(operation instanceof RenameOperationExecutor).isTrue();
RenameOperationExecutor rollbackOperation = (RenameOperationExecutor) operation;

View File

@@ -102,7 +102,7 @@ public class ContextSourceTransactionManagerTests {
this.tested.doBegin(expectedTransactionObject, this.transactionDefinitionMock);
DirContextHolder foundContextHolder = (DirContextHolder) TransactionSynchronizationManager
.getResource(this.contextSourceMock);
.getResource(this.contextSourceMock);
assertThat(foundContextHolder.getCtx()).isSameAs(this.contextMock);
}
@@ -168,8 +168,8 @@ public class ContextSourceTransactionManagerTests {
final ContextSourceTransactionManager txMgrInner = new ContextSourceTransactionManager();
txMgrInner.setContextSource(unconnectableContextSourceMock);
final TransactionStatus txInner = txMgrInner.getTransaction(
new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW));
final TransactionStatus txInner = txMgrInner
.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW));
try {
// Do something with the connection that succeeds or fails

View File

@@ -54,7 +54,7 @@ public class DefaultCompensatingTransactionOperationManagerTests {
Object expectedResource = new Object();
given(this.operationFactoryMock.createRecordingOperation(expectedResource, "some method"))
.willReturn(this.operationRecorderMock);
.willReturn(this.operationRecorderMock);
given(this.operationRecorderMock.recordOperation(expectedArgs)).willReturn(this.operationExecutorMock);
DefaultCompensatingTransactionOperationManager tested = new DefaultCompensatingTransactionOperationManager(

View File

@@ -253,82 +253,83 @@ public class LdifParser implements Parser, InitializingBean {
LineIdentifier identifier = this.separatorPolicy.assess(line);
switch (identifier) {
case NewRecord:
LOG.trace("Starting new record.");
// Start new record.
record = new LdapAttributes(this.caseInsensitive);
builder = new StringBuilder(line);
case NewRecord:
LOG.trace("Starting new record.");
// Start new record.
record = new LdapAttributes(this.caseInsensitive);
builder = new StringBuilder(line);
break;
break;
case Control:
LOG.trace("'control' encountered.");
case Control:
LOG.trace("'control' encountered.");
// Log WARN and discard record.
LOG.warn("LDIF change records have no implementation: record will be ignored.");
builder = null;
record = null;
// Log WARN and discard record.
LOG.warn("LDIF change records have no implementation: record will be ignored.");
builder = null;
record = null;
break;
break;
case ChangeType:
LOG.trace("'changetype' encountered.");
case ChangeType:
LOG.trace("'changetype' encountered.");
// Log WARN and discard record.
LOG.warn("LDIF change records have no implementation: record will be ignored.");
builder = null;
record = null;
// Log WARN and discard record.
LOG.warn("LDIF change records have no implementation: record will be ignored.");
builder = null;
record = null;
break;
break;
case Attribute:
// flush buffer.
addAttributeToRecord(builder.toString(), record);
case Attribute:
// flush buffer.
addAttributeToRecord(builder.toString(), record);
LOG.trace("Starting new attribute.");
// Start new attribute.
builder = new StringBuilder(line);
LOG.trace("Starting new attribute.");
// Start new attribute.
builder = new StringBuilder(line);
break;
break;
case Continuation:
LOG.trace("...appending line to buffer.");
// Append line to buffer.
builder.append(line.replaceFirst(" ", ""));
case Continuation:
LOG.trace("...appending line to buffer.");
// Append line to buffer.
builder.append(line.replaceFirst(" ", ""));
break;
break;
case EndOfRecord:
LOG.trace("...done parsing record. (EndOfRecord)");
case EndOfRecord:
LOG.trace("...done parsing record. (EndOfRecord)");
// Validate record and return.
if (record == null) {
return null;
}
else {
try {
// flush buffer.
addAttributeToRecord(builder.toString(), record);
if (this.specification.isSatisfiedBy(record)) {
LOG.debug("record parsed:\n" + record);
return record;
}
else {
throw new InvalidRecordFormatException(
"Record [dn: " + record.getDN() + "] does not conform to specification.");
}
}
catch (NamingException ex) {
LOG.error("Error adding attribute to record", ex);
// Validate record and return.
if (record == null) {
return null;
}
}
else {
try {
// flush buffer.
addAttributeToRecord(builder.toString(), record);
default:
// Take no action -- applies to VersionIdentifier, Comments, and voided
// records.
if (this.specification.isSatisfiedBy(record)) {
LOG.debug("record parsed:\n" + record);
return record;
}
else {
throw new InvalidRecordFormatException(
"Record [dn: " + record.getDN() + "] does not conform to specification.");
}
}
catch (NamingException ex) {
LOG.error("Error adding attribute to record", ex);
return null;
}
}
default:
// Take no action -- applies to VersionIdentifier, Comments, and
// voided
// records.
}
line = this.reader.readLine();

View File

@@ -68,8 +68,8 @@ public class DefaultAttributeValidationPolicyTests {
private AttributeType type;
private List<String> exceptions = Arrays
.asList(new String[] { "description: :A big sailing fan.", "cn;lang-ja:: 5bCP56yg5Y6fIO.ODreODieODi+ODvA==",
"url:< https://java.sun.com/j2se/1.3/docs/guide/collections/designfaq.html#28" });
.asList(new String[] { "description: :A big sailing fan.", "cn;lang-ja:: 5bCP56yg5Y6fIO.ODreODieODi+ODvA==",
"url:< https://java.sun.com/j2se/1.3/docs/guide/collections/designfaq.html#28" });
/**
* The data set to parse.
@@ -165,7 +165,8 @@ public class DefaultAttributeValidationPolicyTests {
LdapAttribute attribute = (LdapAttribute) policy.parse(this.line);
assertThat(this.id.equalsIgnoreCase(attribute.getID()))
.as("IDs do not match: [expected: " + attribute.getID() + ", obtained: " + this.id + "]").isTrue();
.as("IDs do not match: [expected: " + attribute.getID() + ", obtained: " + this.id + "]")
.isTrue();
String[] expected = !StringUtils.hasLength(this.options) ? new String[] {}
: this.options.replaceFirst(";", "").split(";");
@@ -175,27 +176,27 @@ public class DefaultAttributeValidationPolicyTests {
assertThat(obtained).as("Options do not match: ").isEqualTo(expected);
switch (this.type) {
case STRING:
assertThat(attribute.get() instanceof String).as("Value is not a string.").isTrue();
assertThat(attribute.get()).as("Values do not match: ").isEqualTo(this.value);
break;
case STRING:
assertThat(attribute.get() instanceof String).as("Value is not a string.").isTrue();
assertThat(attribute.get()).as("Values do not match: ").isEqualTo(this.value);
break;
case BASE64:
byte[] bytes = LdapEncoder.parseBase64Binary(this.value);
assertThat(attribute.get() instanceof byte[]).as("Value is not a byte[].").isTrue();
assertThat((byte[]) attribute.get()).as("Values do not match: ").isEqualTo(bytes);
break;
case BASE64:
byte[] bytes = LdapEncoder.parseBase64Binary(this.value);
assertThat(attribute.get() instanceof byte[]).as("Value is not a byte[].").isTrue();
assertThat((byte[]) attribute.get()).as("Values do not match: ").isEqualTo(bytes);
break;
case URL:
URI url = new URI(this.value);
assertThat(attribute.get() instanceof URI).as("Value is not a URL.").isTrue();
assertThat(attribute.get()).as("Values do not match: ").isEqualTo(url);
break;
case URL:
URI url = new URI(this.value);
assertThat(attribute.get() instanceof URI).as("Value is not a URL.").isTrue();
assertThat(attribute.get()).as("Values do not match: ").isEqualTo(url);
break;
case UTF8:
assertThat(attribute.get() instanceof String).as("Value is not a UTF8.").isTrue();
assertThat(attribute.get()).as("Values do not match: ").isEqualTo(this.value);
break;
case UTF8:
assertThat(attribute.get() instanceof String).as("Value is not a UTF8.").isTrue();
assertThat(attribute.get()).as("Values do not match: ").isEqualTo(this.value);
break;
}
log.info("Success!");

View File

@@ -166,23 +166,23 @@ import org.springframework.ldap.odm.tools.SyntaxToJavaClass.ClassInfo;
while (currentValues.hasMoreElements()) {
String currentValue = (String) currentValues.nextElement();
switch (type) {
case SUP:
// Its a super class
String lowerCased = currentValue.toLowerCase();
if (!schema.getObjectClass().contains(lowerCased)) {
supList.add(lowerCased);
}
break;
case MUST:
// Add must attribute
schema.addMust(createAttributeSchema(currentValue, schemaContext));
break;
case MAY:
// Add may attribute
schema.addMay(createAttributeSchema(currentValue, schemaContext));
break;
default:
// Nothing to do
case SUP:
// Its a super class
String lowerCased = currentValue.toLowerCase();
if (!schema.getObjectClass().contains(lowerCased)) {
supList.add(lowerCased);
}
break;
case MUST:
// Add must attribute
schema.addMust(createAttributeSchema(currentValue, schemaContext));
break;
case MAY:
// Add may attribute
schema.addMay(createAttributeSchema(currentValue, schemaContext));
break;
default:
// Nothing to do
}
}
}

View File

@@ -119,9 +119,9 @@ public final class SchemaToJava {
// Command line flags
private enum Flag {
URL("l", "url"), USERNAME("u", "username"), PASSWORD("p", "password"), OBJECTCLASS("o", "objectclasses"), CLASS(
"c", "class"), PACKAGE("k",
"package"), SYNTAX_MAP("s", "syntaxmap"), OUTPUT_DIR("t", "outputdir"), HELP("h", "help");
URL("l", "url"), USERNAME("u", "username"), PASSWORD("p", "password"), OBJECTCLASS("o", "objectclasses"),
CLASS("c", "class"), PACKAGE("k", "package"), SYNTAX_MAP("s", "syntaxmap"), OUTPUT_DIR("t", "outputdir"),
HELP("h", "help");
private String shortName;

View File

@@ -66,9 +66,8 @@ public final class SchemaViewer {
private enum Flag {
URL("l", "url"), USERNAME("u", "username"), PASSWORD("p", "password"), OBJECTCLASS("o",
"objectclass"), ATTRIBUTE("a",
"attribute"), SYNTAX("s", "syntax"), HELP("h", "help"), ERROR("e", "error");
URL("l", "url"), USERNAME("u", "username"), PASSWORD("p", "password"), OBJECTCLASS("o", "objectclass"),
ATTRIBUTE("a", "attribute"), SYNTAX("s", "syntax"), HELP("h", "help"), ERROR("e", "error");
private String shortName;

View File

@@ -67,7 +67,7 @@ public class ConverterFactoryTests {
new ExecuteRunnable<ConverterTestData>().runTests(new RunnableTests<ConverterTestData>() {
public void runTest(ConverterTestData testData) {
assertThat(testData.canConvert)
.isEqualTo(converterManager.canConvert(testData.fromClass, testData.syntax, testData.toClass));
.isEqualTo(converterManager.canConvert(testData.fromClass, testData.syntax, testData.toClass));
}
}, this.converterTestData);
}

View File

@@ -102,7 +102,7 @@ public final class ConverterManagerTests {
new ExecuteRunnable<ConverterTestData<?>>().runTests(new RunnableTests<ConverterTestData<?>>() {
public void runTest(ConverterTestData<?> testData) {
assertThat(testData.expectedValue).isEqualTo(ConverterManagerTests.this.converterManager
.convert(testData.sourceData, "", testData.destClass));
.convert(testData.sourceData, "", testData.destClass));
}
}, primitiveTypeTests);
}
@@ -134,7 +134,7 @@ public final class ConverterManagerTests {
new ExecuteRunnable<ConverterTestData<?>>().runTests(new RunnableTests<ConverterTestData<?>>() {
public void runTest(ConverterTestData<?> testData) {
assertThat(testData.expectedValue).isEqualTo(ConverterManagerTests.this.converterManager
.convert(testData.sourceData, testData.syntax, testData.destClass));
.convert(testData.sourceData, testData.syntax, testData.destClass));
}
}, syntaxTests);

View File

@@ -312,7 +312,7 @@ public final class LdapTests {
this.searchControls);
LOG.debug(String.format("Found - %1$s", allOus));
assertThat(new HashSet<OrganizationalUnit>(Arrays.asList(ouTestData)))
.isEqualTo(new HashSet<OrganizationalUnit>(allOus));
.isEqualTo(new HashSet<OrganizationalUnit>(allOus));
OrganizationalUnit testOu = ouTestData[OrganizationalName.ASSISTANTS.getIndex()];
LOG.debug(String.format("Reading - %1$s", testOu.getDn()));
@@ -337,7 +337,7 @@ public final class LdapTests {
assertThat(9).isEqualTo(allPeople.size());
assertThat(CollectionUtils.containsInstance(allPeople, null)).isFalse()
.withFailMessage("No nulls should have been returned");
.withFailMessage("No nulls should have been returned");
}
@Test

View File

@@ -215,7 +215,7 @@ public final class SchemaToJavaTests {
Method telephoneNumberIteratorMethod = clazz.getMethod("getTelephoneNumberIterator");
@SuppressWarnings("unchecked")
Iterator<Integer> telephoneNumberIterator = (Iterator<Integer>) telephoneNumberIteratorMethod
.invoke(fromDirectory);
.invoke(fromDirectory);
int telephoneNumberCount = 0;
while (telephoneNumberIterator.hasNext()) {
telephoneNumberCount++;

View File

@@ -33,7 +33,7 @@ public final class CompilerInterface {
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
Iterable<? extends JavaFileObject> javaFileObjects = fileManager
.getJavaFileObjectsFromFiles(Arrays.asList(toCompile));
.getJavaFileObjectsFromFiles(Arrays.asList(toCompile));
compiler.getTask(null, fileManager, null, null, null, javaFileObjects).call();
fileManager.close();

View File

@@ -164,20 +164,20 @@ public class VirtualListViewControlDirContextProcessorTests {
targetType >>= 3;
ber.parseLength(); // ignore
switch (targetType) {
case 0: // byOffset
int actualOffset = ber.parseInt();
int actualContentCount = ber.parseInt();
assertThat(expectedBeforeCount).isEqualTo(actualBeforeCount);
assertThat(expectedAfterCount).isEqualTo(actualAfterCount);
assertThat(expectedOffset).isEqualTo(actualOffset);
assertThat(actualContentCount).isEqualTo(expectedContentCount);
break;
case 0: // byOffset
int actualOffset = ber.parseInt();
int actualContentCount = ber.parseInt();
assertThat(expectedBeforeCount).isEqualTo(actualBeforeCount);
assertThat(expectedAfterCount).isEqualTo(actualAfterCount);
assertThat(expectedOffset).isEqualTo(actualOffset);
assertThat(actualContentCount).isEqualTo(expectedContentCount);
break;
case 1: // greaterThanOrEqual
throw new AssertionFailedError("CHOICE value greaterThanOrEqual not supported");
case 1: // greaterThanOrEqual
throw new AssertionFailedError("CHOICE value greaterThanOrEqual not supported");
default:
throw new AssertionFailedError("illegal CHOICE value: " + targetType);
default:
throw new AssertionFailedError("illegal CHOICE value: " + targetType);
}
byte[] bs = ber.parseOctetString(Ber.ASN_OCTET_STR, null);
assertContextId(expectedContextId, bs);

View File

@@ -129,7 +129,7 @@ public abstract class AbstractEc2InstanceLaunchingFactoryBean extends AbstractFa
LOG.info("Instance still starting up; sleeping " + INSTANCE_START_SLEEP_TIME + "ms");
Thread.sleep(INSTANCE_START_SLEEP_TIME);
reservationDescription = jec2.describeInstances(Collections.singletonList(this.instance.getInstanceId()))
.get(0);
.get(0);
this.instance = reservationDescription.getInstances().get(0);
}

View File

@@ -225,7 +225,7 @@ public class IncrementalAttributeMapperITests extends AbstractJUnit4SpringContex
// LDAP-234: After rollback the attribute values were cleared after rollback
assertThat(DefaultIncrementalAttributesMapper.lookupAttributeValues(this.ldapTemplate, GROUP_DN, "member")
.size()).isEqualTo(1501);
.size()).isEqualTo(1501);
}
}

View File

@@ -76,7 +76,7 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
LdapQuery query = LdapQueryBuilder.query().filter(filter);
assertThatExceptionOfType(AuthenticationException.class)
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
}
@Test
@@ -86,7 +86,7 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
LdapQuery query = LdapQueryBuilder.query().where("objectclass").is("person").and("uid").is("some.person3");
assertThatExceptionOfType(AuthenticationException.class)
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
}
@Test
@@ -114,8 +114,10 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
@Category(NoAdTests.class)
public void testAuthenticateWithLdapQueryAndMapper() {
LdapQuery query = LdapQueryBuilder.query().where("objectclass").is("person").and("uid").is("some.person3");
DirContextOperations ctx = this.tested.authenticate().query(query).password("password")
.execute(new LookupAttemptingCallback());
DirContextOperations ctx = this.tested.authenticate()
.query(query)
.password("password")
.execute(new LookupAttemptingCallback());
assertThat(ctx).isNotNull();
assertThat(ctx.getStringAttribute("uid")).isEqualTo("some.person3");
@@ -126,7 +128,9 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
public void testAuthenticateWithLdapQueryAndMapperAndInvalidPassword() {
LdapQuery query = LdapQueryBuilder.query().where("objectclass").is("person").and("uid").is("some.person3");
assertThatExceptionOfType(AuthenticationException.class).isThrownBy(() -> this.tested.authenticate()
.query(query).password("invalidpassword").execute(new LookupAttemptingCallback()));
.query(query)
.password("invalidpassword")
.execute(new LookupAttemptingCallback()));
}
@Test
@@ -136,7 +140,7 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
LdapQuery query = LdapQueryBuilder.query().filter(filter);
assertThatExceptionOfType(AuthenticationException.class)
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
.isThrownBy(() -> this.tested.authenticate().query(query).password("invalidpassword").execute());
}
@Test
@@ -144,10 +148,10 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
public void testAuthenticateWithFilterThatDoesNotMatchAnything() {
AndFilter filter = new AndFilter();
filter.and(new EqualsFilter("objectclass", "person"))
.and(new EqualsFilter("uid", "some.person.that.isnt.there"));
.and(new EqualsFilter("uid", "some.person.that.isnt.there"));
LdapQuery query = LdapQueryBuilder.query().filter(filter);
assertThatExceptionOfType(EmptyResultDataAccessException.class)
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
}
@Test
@@ -157,7 +161,7 @@ public class DefaultLdapClientAuthenticationITests extends AbstractLdapTemplateI
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("cn", "Some Person"));
LdapQuery query = LdapQueryBuilder.query().filter(filter);
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class)
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
.isThrownBy(() -> this.tested.authenticate().query(query).password("password").execute());
}
@Test

View File

@@ -158,7 +158,7 @@ public class DefaultLdapClientBindUnbindITests extends AbstractLdapTemplateInteg
private void verifyCleanup() {
assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected")
.isThrownBy(() -> this.tested.search().name(DN).toEntry());
.isThrownBy(() -> this.tested.search().name(DN).toEntry());
}
}

View File

@@ -73,7 +73,7 @@ public class DefaultLdapClientListITests extends AbstractLdapTemplateIntegration
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.listBindings("ou=company2,ou=Sweden" + BASE_STRING)
.toList(this.contextMapper);
.toList(this.contextMapper);
assertThat(list).hasSize(1);
}

View File

@@ -82,8 +82,9 @@ public class DefaultLdapClientLookupITests extends AbstractLdapTemplateIntegrati
@Test
public void testLookup_AttributesMapper_LdapName() {
AttributesMapper<Person> mapper = new PersonAttributesMapper();
Person person = this.tested.search().name(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden"))
.toObject(mapper);
Person person = this.tested.search()
.name(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden"))
.toObject(mapper);
assertThat(person.getFullname()).isEqualTo("Some Person2");
assertThat(person.getLastname()).isEqualTo("Person2");
@@ -99,8 +100,8 @@ public class DefaultLdapClientLookupITests extends AbstractLdapTemplateIntegrati
AttributesMapper<Person> mapper = new SubsetPersonAttributesMapper();
Person person = this.tested.search()
.query((builder) -> builder.base("cn=Some Person2, ou=company1,ou=Sweden").attributes("cn"))
.toObject(mapper);
.query((builder) -> builder.base("cn=Some Person2, ou=company1,ou=Sweden").attributes("cn"))
.toObject(mapper);
assertThat(person.getFullname()).isEqualTo("Some Person2");
assertThat(person.getLastname()).as("lastName should not be set").isNull();
@@ -114,10 +115,10 @@ public class DefaultLdapClientLookupITests extends AbstractLdapTemplateIntegrati
@Test
public void testLookup_ReturnAttributes_AttributesMapper_LdapName() {
AttributesMapper<Person> mapper = new SubsetPersonAttributesMapper();
Person person = this.tested
.search().query((builder) -> builder
.base(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden")).attributes("cn"))
.toObject(mapper);
Person person = this.tested.search()
.query((builder) -> builder.base(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden"))
.attributes("cn"))
.toObject(mapper);
assertThat(person.getFullname()).isEqualTo("Some Person2");
assertThat(person.getLastname()).as("lastName should not be set").isNull();
@@ -148,8 +149,8 @@ public class DefaultLdapClientLookupITests extends AbstractLdapTemplateIntegrati
ContextMapper<Person> mapper = new PersonContextMapper();
Person person = this.tested.search()
.query((builder) -> builder.base("cn=Some Person2, ou=company1,ou=Sweden").attributes("cn"))
.toObject(mapper);
.query((builder) -> builder.base("cn=Some Person2, ou=company1,ou=Sweden").attributes("cn"))
.toObject(mapper);
assertThat(person.getFullname()).isEqualTo("Some Person2");
assertThat(person.getLastname()).as("lastName should not be set").isNull();

View File

@@ -76,8 +76,9 @@ public class DefaultLdapClientLookupMultiRdnITests extends AbstractLdapTemplateI
@Test
@Category(NoAdTests.class)
public void testLookup_GetNameInNamespace_MultiRdn() {
DirContextOperations result = this.tested.search().name("cn=Some Person+sn=Person,ou=company1,ou=Norway")
.toEntry();
DirContextOperations result = this.tested.search()
.name("cn=Some Person+sn=Person,ou=company1,ou=Norway")
.toEntry();
assertThat(result.getDn().toString()).isEqualTo("cn=Some Person+sn=Person,ou=company1,ou=Norway");
assertThat(result.getNameInNamespace()).isEqualTo("cn=Some Person+sn=Person,ou=company1,ou=Norway," + base);
}

View File

@@ -123,8 +123,8 @@ public class DefaultLdapClientRecursiveDeleteITests extends AbstractLdapTemplate
private void verifyDeleted(Name dn) {
assertThatExceptionOfType(NameNotFoundException.class)
.describedAs("Expected entry '" + dn + "' to be non-existent")
.isThrownBy(() -> this.tested.list(dn).toList(NameClassPair::getName));
.describedAs("Expected entry '" + dn + "' to be non-existent")
.isThrownBy(() -> this.tested.list(dn).toList(NameClassPair::getName));
}
}

View File

@@ -106,9 +106,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search().query(
LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.attributesMapper);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -117,9 +117,10 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search().query(
LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.attributesMapper).collect(Collectors.toList());
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -128,8 +129,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn")
.where("objectclass").is("person").and("sn").is("Person2")).toList(this.attributesMapper);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query()
.base(BASE_STRING)
.attributes("cn")
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toList(this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -138,10 +146,16 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
List<Object> list = this.tested
.search().query(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn").where("objectclass")
.is("person").and("sn").is("Person2"))
.toStream(this.attributesMapper).collect(Collectors.toList());
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query()
.base(BASE_STRING)
.attributes("cn")
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toStream(this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -150,9 +164,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING)
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.attributesMapper);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query()
.base(BASE_STRING)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toList(this.attributesMapper);
assertThat(list).isEmpty();
}
@@ -162,9 +182,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.ONELEVEL).where("objectclass")
.is("person").and("sn").is("Person2"))
.toStream(this.attributesMapper).collect(Collectors.toList());
.query(LdapQueryBuilder.query()
.base(BASE_STRING)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toStream(this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).isEmpty();
}
@@ -173,9 +199,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.attributesMapper);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toList(this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -185,9 +217,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query().base("ou=company1,ou=Sweden").searchScope(SearchScope.ONELEVEL)
.where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.attributesMapper).collect(Collectors.toList());
.query(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toStream(this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -197,8 +235,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.attributesMapper);
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -208,8 +246,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.attributesMapper).collect(Collectors.toList());
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -218,9 +257,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search().query(
LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.attributesMapper);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.attributesMapper);
assertThat(list).isEmpty();
}
@@ -229,9 +268,10 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search().query(
LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.attributesMapper).collect(Collectors.toList());
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).isEmpty();
}
@@ -239,9 +279,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
public void testSearch_SearchScope_AttributesMapper() {
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search().query(
LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
.toList(this.attributesMapper);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
.toList(this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -250,9 +290,13 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedAttributes(CN_SN_ATTRS);
this.attributesMapper.setExpectedValues(CN_SN_VALUES);
this.attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING)
.searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING))
.toList(this.attributesMapper);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query()
.base(BASE_STRING)
.searchScope(SearchScope.SUBTREE)
.attributes(CN_SN_ATTRS)
.filter(FILTER_STRING))
.toList(this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -260,8 +304,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
public void testSearch_AttributesMapper_Name() {
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_NAME).filter(FILTER_STRING))
.toList(this.attributesMapper);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_NAME).filter(FILTER_STRING))
.toList(this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -270,8 +315,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
.toList(this.attributesMapper);
.query(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
.toList(this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -280,9 +325,13 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.attributesMapper.setExpectedAttributes(CN_SN_ATTRS);
this.attributesMapper.setExpectedValues(CN_SN_VALUES);
this.attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
List<Object> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_NAME)
.searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING))
.toList(this.attributesMapper);
List<Object> list = this.tested.search()
.query(LdapQueryBuilder.query()
.base(BASE_NAME)
.searchScope(SearchScope.SUBTREE)
.attributes(CN_SN_ATTRS)
.filter(FILTER_STRING))
.toList(this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -291,7 +340,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_STRING).filter(FILTER_STRING)).toList(this.contextMapper);
.query(LdapQueryBuilder.query().base(BASE_STRING).filter(FILTER_STRING))
.toList(this.contextMapper);
assertThat(list).hasSize(1);
}
@@ -300,21 +350,25 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
DirContextAdapter result = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_STRING).filter(FILTER_STRING)).toObject(this.contextMapper);
.query(LdapQueryBuilder.query().base(BASE_STRING).filter(FILTER_STRING))
.toObject(this.contextMapper);
assertThat(result).isNotNull();
}
@Test(expected = IncorrectResultSizeDataAccessException.class)
public void testSearchForObjectWithMultipleHits() {
this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING).filter("(&(objectclass=person)(sn=*))"))
.toObject((Object ctx) -> ctx);
this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_STRING).filter("(&(objectclass=person)(sn=*))"))
.toObject((Object ctx) -> ctx);
}
@Test // (expected = EmptyResultDataAccessException.class)
public void testSearchForObjectNoHits() {
Object result = this.tested.search().query(
LdapQueryBuilder.query().base(BASE_STRING).filter("(&(objectclass=person)(sn=Person does not exist))"))
.toObject((Object ctx) -> ctx);
Object result = this.tested.search()
.query(LdapQueryBuilder.query()
.base(BASE_STRING)
.filter("(&(objectclass=person)(sn=Person does not exist))"))
.toObject((Object ctx) -> ctx);
assertThat(result).isNull();
}
@@ -322,9 +376,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
public void testSearch_SearchScope_ContextMapper() {
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search().query(
LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
.toList(this.contextMapper);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
.toList(this.contextMapper);
assertThat(list).hasSize(1);
}
@@ -333,9 +387,13 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.contextMapper.setExpectedAttributes(CN_SN_ATTRS);
this.contextMapper.setExpectedValues(CN_SN_VALUES);
this.contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
List<DirContextAdapter> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING)
.searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING))
.toList(this.contextMapper);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query()
.base(BASE_STRING)
.searchScope(SearchScope.SUBTREE)
.attributes(CN_SN_ATTRS)
.filter(FILTER_STRING))
.toList(this.contextMapper);
assertThat(list).hasSize(1);
}
@@ -344,7 +402,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_NAME).filter(FILTER_STRING)).toList(this.contextMapper);
.query(LdapQueryBuilder.query().base(BASE_NAME).filter(FILTER_STRING))
.toList(this.contextMapper);
assertThat(list).hasSize(1);
}
@@ -352,9 +411,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
public void testSearch_ContextMapper_LdapQuery() {
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search().query(
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.contextMapper);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.contextMapper);
assertThat(list).hasSize(1);
}
@@ -362,9 +421,10 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
public void testSearchForStream_ContextMapper_LdapQuery() {
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search().query(
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.contextMapper).collect(Collectors.toList());
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.contextMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -373,8 +433,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.contextMapper);
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.contextMapper);
assertThat(list).hasSize(1);
}
@@ -383,8 +443,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.contextMapper).collect(Collectors.toList());
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.contextMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -392,9 +453,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
public void testSearch_ContextMapper_LdapQuery_SearchScope() {
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_NAME)
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.contextMapper);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query()
.base(BASE_NAME)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toList(this.contextMapper);
assertThat(list).isEmpty();
}
@@ -403,9 +470,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.ONELEVEL).where("objectclass")
.is("person").and("sn").is("Person2"))
.toStream(this.contextMapper).collect(Collectors.toList());
.query(LdapQueryBuilder.query()
.base(BASE_NAME)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toStream(this.contextMapper)
.collect(Collectors.toList());
assertThat(list).isEmpty();
}
@@ -413,9 +486,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
public void testSearch_ContextMapper_LdapQuery_SearchScope_CorrectBase() {
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search().query(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"))
.toList(this.contextMapper);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toList(this.contextMapper);
assertThat(list).hasSize(1);
}
@@ -424,9 +503,15 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query().base("ou=company1,ou=Sweden").searchScope(SearchScope.ONELEVEL)
.where("objectclass").is("person").and("sn").is("Person2"))
.toStream(this.contextMapper).collect(Collectors.toList());
.query(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toStream(this.contextMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -434,16 +519,22 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
public void testSearchForContext_LdapQuery() {
ContextMapper<DirContextOperations> mapper = (result) -> (DirContextOperations) result;
DirContextOperations result = this.tested.search()
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
.toObject(mapper);
.query(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"))
.toObject(mapper);
assertThat(result).isNotNull();
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
}
@Test // (expected = EmptyResultDataAccessException.class)
public void testSearchForContext_LdapQuery_SearchScopeNotFound() {
Object result = this.tested.search().query(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL)
.where("objectclass").is("person").and("sn").is("Person2")).toObject(this.attributesMapper);
Object result = this.tested.search()
.query(LdapQueryBuilder.query()
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toObject(this.attributesMapper);
assertThat(result).isNull();
}
@@ -451,9 +542,14 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
public void testSearchForContext_LdapQuery_SearchScope_CorrectBase() {
ContextMapper<DirContextOperations> mapper = (result) -> (DirContextOperations) result;
DirContextOperations result = this.tested.search()
.query(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL).base("ou=company1,ou=Sweden")
.where("objectclass").is("person").and("sn").is("Person2"))
.toObject(mapper);
.query(LdapQueryBuilder.query()
.searchScope(SearchScope.ONELEVEL)
.base("ou=company1,ou=Sweden")
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"))
.toObject(mapper);
assertThat(result).isNotNull();
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
@@ -464,8 +560,8 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
.toList(this.contextMapper);
.query(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING))
.toList(this.contextMapper);
assertThat(list).hasSize(1);
}
@@ -474,19 +570,26 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.contextMapper.setExpectedAttributes(CN_SN_ATTRS);
this.contextMapper.setExpectedValues(CN_SN_VALUES);
this.contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
List<DirContextAdapter> list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_NAME)
.searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING))
.toList(this.contextMapper);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query()
.base(BASE_NAME)
.searchScope(SearchScope.SUBTREE)
.attributes(CN_SN_ATTRS)
.filter(FILTER_STRING))
.toList(this.contextMapper);
assertThat(list).hasSize(1);
}
@Test
public void testSearchWithInvalidSearchBaseShouldByDefaultThrowException() {
try {
this.tested
.search().query(LdapQueryBuilder.query().base(BASE_NAME + "ou=unknown")
.searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING))
.toObject(this.contextMapper);
this.tested.search()
.query(LdapQueryBuilder.query()
.base(BASE_NAME + "ou=unknown")
.searchScope(SearchScope.SUBTREE)
.attributes(CN_SN_ATTRS)
.filter(FILTER_STRING))
.toObject(this.contextMapper);
fail("NameNotFoundException expected");
}
catch (NameNotFoundException expected) {
@@ -501,17 +604,20 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
this.contextMapper.setExpectedValues(CN_SN_VALUES);
this.contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
List<DirContextAdapter> list = this.tested.search()
.query(LdapQueryBuilder.query().base(BASE_NAME + "ou=unknown").searchScope(SearchScope.SUBTREE)
.attributes(CN_SN_ATTRS).filter(FILTER_STRING))
.toList(this.contextMapper);
.query(LdapQueryBuilder.query()
.base(BASE_NAME + "ou=unknown")
.searchScope(SearchScope.SUBTREE)
.attributes(CN_SN_ATTRS)
.filter(FILTER_STRING))
.toList(this.contextMapper);
assertThat(list).isEmpty();
}
@Test
public void verifyThatSearchWithCountLimitReturnsTheEntriesFoundSoFar() {
List<Object> result = this.tested.search()
.query(LdapQueryBuilder.query().countLimit(3).where("objectclass").is("person"))
.toList((Object ctx) -> new Object());
.query(LdapQueryBuilder.query().countLimit(3).where("objectclass").is("person"))
.toList((Object ctx) -> new Object());
assertThat(result).hasSize(3);
}
@@ -519,8 +625,9 @@ public class DefaultLdapClientSearchResultITests extends AbstractLdapTemplateInt
@Test(expected = SizeLimitExceededException.class)
public void verifyThatSearchWithCountLimitWithFlagToFalseThrowsException() {
ReflectionTestUtils.setField(this.tested, "ignoreSizeLimitExceededException", false);
this.tested.search().query(LdapQueryBuilder.query().countLimit(3).where("objectclass").is("person"))
.toList((Object ctx) -> ctx);
this.tested.search()
.query(LdapQueryBuilder.query().countLimit(3).where("objectclass").is("person"))
.toList((Object ctx) -> ctx);
}
}

View File

@@ -134,9 +134,11 @@ public class LdapTemplateAuthenticationITests extends AbstractLdapTemplateIntegr
final Exception error = errorCallback.getError();
assertThat(error).as("collected error should not be null").isNotNull();
assertThat(error instanceof AuthenticationException)
.as("expected org.springframework.ldap.AuthenticationException").isTrue();
.as("expected org.springframework.ldap.AuthenticationException")
.isTrue();
assertThat(error.getCause() instanceof javax.naming.AuthenticationException)
.as("expected javax.naming.AuthenticationException").isTrue();
.as("expected javax.naming.AuthenticationException")
.isTrue();
}
@Test
@@ -144,7 +146,7 @@ public class LdapTemplateAuthenticationITests extends AbstractLdapTemplateIntegr
public void testAuthenticateWithFilterThatDoesNotMatchAnything() {
AndFilter filter = new AndFilter();
filter.and(new EqualsFilter("objectclass", "person"))
.and(new EqualsFilter("uid", "some.person.that.isnt.there"));
.and(new EqualsFilter("uid", "some.person.that.isnt.there"));
assertThat(this.tested.authenticate("", filter.toString(), "password")).isFalse();
}

View File

@@ -69,7 +69,7 @@ public class LdapTemplateLookupMultiRdnITests extends AbstractLdapTemplateIntegr
@Category(NoAdTests.class)
public void testLookup_MultiValuedRdn_DirContextAdapter() {
DirContextAdapter result = (DirContextAdapter) this.tested
.lookup("cn=Some Person+sn=Person, ou=company1,ou=Norway");
.lookup("cn=Some Person+sn=Person, ou=company1,ou=Norway");
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person");
assertThat(result.getStringAttribute("sn")).isEqualTo("Person");
@@ -80,7 +80,7 @@ public class LdapTemplateLookupMultiRdnITests extends AbstractLdapTemplateIntegr
@Category(NoAdTests.class)
public void testLookup_GetNameInNamespace_MultiRdn() {
DirContextAdapter result = (DirContextAdapter) this.tested
.lookup("cn=Some Person+sn=Person,ou=company1,ou=Norway");
.lookup("cn=Some Person+sn=Person,ou=company1,ou=Norway");
assertThat(result.getDn().toString()).isEqualTo("cn=Some Person+sn=Person,ou=company1,ou=Norway");
assertThat(result.getNameInNamespace()).isEqualTo("cn=Some Person+sn=Person,ou=company1,ou=Norway," + base);

View File

@@ -87,7 +87,7 @@ public class LdapTemplateNoBaseSuffixITests extends AbstractLdapTemplateIntegrat
this.tested.bind("cn=Some Person4, ou=company1, ou=Sweden," + base, adapter, null);
DirContextAdapter result = (DirContextAdapter) this.tested
.lookup("cn=Some Person4, ou=company1, ou=Sweden," + base);
.lookup("cn=Some Person4, ou=company1, ou=Sweden," + base);
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4");
assertThat(result.getStringAttribute("sn")).isEqualTo("Person4");

View File

@@ -121,7 +121,8 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
List<Object> list = this.tested.searchForStream(
LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper).collect(Collectors.toList());
this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -130,8 +131,13 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
List<Object> list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn")
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper);
List<Object> list = this.tested.search(LdapQueryBuilder.query()
.base(BASE_STRING)
.attributes("cn")
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -140,9 +146,15 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
List<Object> list = this.tested.searchForStream(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn")
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper)
.collect(Collectors.toList());
List<Object> list = this.tested
.searchForStream(LdapQueryBuilder.query()
.base(BASE_STRING)
.attributes("cn")
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -151,9 +163,13 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING)
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper);
List<Object> list = this.tested.search(LdapQueryBuilder.query()
.base(BASE_STRING)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper);
assertThat(list).isEmpty();
}
@@ -163,9 +179,14 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested
.searchForStream(LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.ONELEVEL)
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper)
.collect(Collectors.toList());
.searchForStream(LdapQueryBuilder.query()
.base(BASE_STRING)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).isEmpty();
}
@@ -174,9 +195,13 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper);
List<Object> list = this.tested.search(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -185,9 +210,15 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.searchForStream(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper).collect(Collectors.toList());
List<Object> list = this.tested
.searchForStream(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -208,9 +239,9 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper)
.collect(Collectors.toList());
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -232,7 +263,8 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
List<Object> list = this.tested.searchForStream(
LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper).collect(Collectors.toList());
this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).isEmpty();
}
@@ -358,9 +390,11 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
public void testSearchForStream_ContextMapper_LdapQuery() {
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.searchForStream(
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper).collect(Collectors.toList());
List<DirContextAdapter> list = this.tested
.searchForStream(
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -378,9 +412,9 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper)
.collect(Collectors.toList());
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -388,9 +422,13 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
public void testSearch_ContextMapper_LdapQuery_SearchScope() {
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query().base(BASE_NAME)
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper);
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query()
.base(BASE_NAME)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.contextMapper);
assertThat(list).isEmpty();
}
@@ -399,9 +437,14 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested
.searchForStream(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.ONELEVEL)
.where("objectclass").is("person").and("sn").is("Person2"), this.contextMapper)
.collect(Collectors.toList());
.searchForStream(LdapQueryBuilder.query()
.base(BASE_NAME)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.contextMapper)
.collect(Collectors.toList());
assertThat(list).isEmpty();
}
@@ -409,9 +452,13 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
public void testSearch_ContextMapper_LdapQuery_SearchScope_CorrectBase() {
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper);
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.contextMapper);
assertThat(list).hasSize(1);
}
@@ -420,17 +467,21 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested
.searchForStream(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper)
.collect(Collectors.toList());
.searchForStream(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.contextMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@Test
public void testSearchForContext_LdapQuery() {
DirContextOperations result = this.tested
.searchForContext(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"));
.searchForContext(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"));
assertThat(result).isNotNull();
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
@@ -438,15 +489,23 @@ public class LdapTemplateSearchResultITests extends AbstractLdapTemplateIntegrat
@Test(expected = EmptyResultDataAccessException.class)
public void testSearchForContext_LdapQuery_SearchScopeNotFound() {
this.tested.searchForContext(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL).where("objectclass")
.is("person").and("sn").is("Person2"));
this.tested.searchForContext(LdapQueryBuilder.query()
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"));
}
@Test
public void testSearchForContext_LdapQuery_SearchScope_CorrectBase() {
DirContextOperations result = this.tested
.searchForContext(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL)
.base("ou=company1,ou=Sweden").where("objectclass").is("person").and("sn").is("Person2"));
DirContextOperations result = this.tested.searchForContext(LdapQueryBuilder.query()
.searchScope(SearchScope.ONELEVEL)
.base("ou=company1,ou=Sweden")
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"));
assertThat(result).isNotNull();
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");

View File

@@ -118,7 +118,8 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
List<Object> list = this.tested.searchForStream(
LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper).collect(Collectors.toList());
this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -127,8 +128,13 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
List<Object> list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn")
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper);
List<Object> list = this.tested.search(LdapQueryBuilder.query()
.base(BASE_STRING)
.attributes("cn")
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -137,9 +143,15 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
this.attributesMapper.setExpectedAttributes(new String[] { "cn" });
this.attributesMapper.setExpectedValues(new String[] { "Some Person2" });
List<Object> list = this.tested.searchForStream(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn")
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper)
.collect(Collectors.toList());
List<Object> list = this.tested
.searchForStream(LdapQueryBuilder.query()
.base(BASE_STRING)
.attributes("cn")
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -148,9 +160,13 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING)
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper);
List<Object> list = this.tested.search(LdapQueryBuilder.query()
.base(BASE_STRING)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper);
assertThat(list).isEmpty();
}
@@ -160,9 +176,14 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested
.searchForStream(LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.ONELEVEL)
.where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper)
.collect(Collectors.toList());
.searchForStream(LdapQueryBuilder.query()
.base(BASE_STRING)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).isEmpty();
}
@@ -171,9 +192,13 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.search(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper);
List<Object> list = this.tested.search(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper);
assertThat(list).hasSize(1);
}
@@ -182,9 +207,15 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested.searchForStream(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper).collect(Collectors.toList());
List<Object> list = this.tested
.searchForStream(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -205,9 +236,9 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
this.attributesMapper.setExpectedValues(ALL_VALUES);
List<Object> list = this.tested
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper)
.collect(Collectors.toList());
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -229,7 +260,8 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
List<Object> list = this.tested.searchForStream(
LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2"),
this.attributesMapper).collect(Collectors.toList());
this.attributesMapper)
.collect(Collectors.toList());
assertThat(list).isEmpty();
}
@@ -355,9 +387,11 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
public void testSearchForStream_ContextMapper_LdapQuery() {
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.searchForStream(
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper).collect(Collectors.toList());
List<DirContextAdapter> list = this.tested
.searchForStream(
LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -375,9 +409,9 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper)
.collect(Collectors.toList());
.searchForStream(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@@ -385,9 +419,13 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
public void testSearch_ContextMapper_LdapQuery_SearchScope() {
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query().base(BASE_NAME)
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper);
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query()
.base(BASE_NAME)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.contextMapper);
assertThat(list).isEmpty();
}
@@ -396,9 +434,14 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested
.searchForStream(LdapQueryBuilder.query().base(BASE_NAME).searchScope(SearchScope.ONELEVEL)
.where("objectclass").is("person").and("sn").is("Person2"), this.contextMapper)
.collect(Collectors.toList());
.searchForStream(LdapQueryBuilder.query()
.base(BASE_NAME)
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.contextMapper)
.collect(Collectors.toList());
assertThat(list).isEmpty();
}
@@ -406,9 +449,13 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
public void testSearch_ContextMapper_LdapQuery_SearchScope_CorrectBase() {
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper);
List<DirContextAdapter> list = this.tested.search(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.contextMapper);
assertThat(list).hasSize(1);
}
@@ -417,17 +464,21 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
this.contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = this.tested
.searchForStream(LdapQueryBuilder.query().base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"),
this.contextMapper)
.collect(Collectors.toList());
.searchForStream(LdapQueryBuilder.query()
.base("ou=company1,ou=Sweden")
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"), this.contextMapper)
.collect(Collectors.toList());
assertThat(list).hasSize(1);
}
@Test
public void testSearchForContext_LdapQuery() {
DirContextOperations result = this.tested
.searchForContext(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"));
.searchForContext(LdapQueryBuilder.query().where("objectclass").is("person").and("sn").is("Person2"));
assertThat(result).isNotNull();
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
@@ -435,15 +486,23 @@ public class LdapTemplateSearchResultNamespaceConfigITests extends AbstractLdapT
@Test(expected = EmptyResultDataAccessException.class)
public void testSearchForContext_LdapQuery_SearchScopeNotFound() {
this.tested.searchForContext(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL).where("objectclass")
.is("person").and("sn").is("Person2"));
this.tested.searchForContext(LdapQueryBuilder.query()
.searchScope(SearchScope.ONELEVEL)
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"));
}
@Test
public void testSearchForContext_LdapQuery_SearchScope_CorrectBase() {
DirContextOperations result = this.tested
.searchForContext(LdapQueryBuilder.query().searchScope(SearchScope.ONELEVEL)
.base("ou=company1,ou=Sweden").where("objectclass").is("person").and("sn").is("Person2"));
DirContextOperations result = this.tested.searchForContext(LdapQueryBuilder.query()
.searchScope(SearchScope.ONELEVEL)
.base("ou=company1,ou=Sweden")
.where("objectclass")
.is("person")
.and("sn")
.is("Person2"));
assertThat(result).isNotNull();
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");

View File

@@ -75,7 +75,7 @@ public class SupportedControlsITests extends AbstractLdapTemplateIntegrationTest
HashSet<String> controlsSet = new HashSet<String>(Arrays.asList(controls));
assertThat(controlsSet.contains("1.3.6.1.4.1.4203.1.10.1")).as("Entry Change Notification LDAPv3 control,")
.isTrue();
.isTrue();
assertThat(controlsSet.contains("1.3.6.1.4.1.4203.1.10.1")).as("Subentries Control,").isTrue();
assertThat(controlsSet.contains("2.16.840.1.113730.3.4.2")).as("Manage DSA IT LDAPv3 control,").isTrue();
}

View File

@@ -142,7 +142,7 @@ public class SimpleLdapTemplateITests extends AbstractLdapTemplateIntegrationTes
@Test
public void testModifyAttributesName() {
DirContextOperations ctx = this.ldapTemplate
.lookupContext(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden"));
.lookupContext(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden"));
ctx.setAttributeValue("description", "updated description");
ctx.setAttributeValue("telephoneNumber", "0000001");

View File

@@ -55,7 +55,7 @@ import static org.assertj.core.api.Assertions.fail;
public class ContextSourceAndDataSourceTransactionManagerIntegrationTests extends AbstractLdapTemplateIntegrationTests {
private static Logger log = LoggerFactory
.getLogger(ContextSourceAndDataSourceTransactionManagerIntegrationTests.class);
.getLogger(ContextSourceAndDataSourceTransactionManagerIntegrationTests.class);
@Autowired
@Qualifier("dummyDao")
@@ -75,7 +75,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTests extend
this.jdbcTemplate.execute("drop table PERSON if exists");
this.jdbcTemplate
.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
this.jdbcTemplate.update("insert into PERSON values(?, ?, ?)",
new Object[] { "Some Person", "Person", "Sweden, Company1, Some Person" });
}

View File

@@ -47,7 +47,7 @@ public class ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests
extends AbstractJUnit4SpringContextTests {
private static Logger log = LoggerFactory
.getLogger(ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.class);
.getLogger(ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.class);
@Autowired
@Qualifier("dummyDao")

View File

@@ -56,7 +56,7 @@ import static org.assertj.core.api.Assertions.fail;
public class ContextSourceAndDataSourceTransactionManagerNamespaceITests extends AbstractLdapTemplateIntegrationTests {
private static Logger log = LoggerFactory
.getLogger(ContextSourceAndDataSourceTransactionManagerNamespaceITests.class);
.getLogger(ContextSourceAndDataSourceTransactionManagerNamespaceITests.class);
@Autowired
@Qualifier("dummyDao")
@@ -76,7 +76,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITests extends
this.jdbcTemplate.execute("drop table PERSON if exists");
this.jdbcTemplate
.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
.execute("create table PERSON(fullname VARCHAR(256), lastname VARCHAR(256), description VARCHAR(256))");
this.jdbcTemplate.update("insert into PERSON values(?, ?, ?)",
new Object[] { "Some Person", "Person", "Sweden, Company1, Some Person" });
}

View File

@@ -57,7 +57,7 @@ import static org.assertj.core.api.Assertions.fail;
public class ContextSourceAndHibernateTransactionManagerIntegrationTests extends AbstractLdapTemplateIntegrationTests {
private static Logger log = LoggerFactory
.getLogger(ContextSourceAndHibernateTransactionManagerIntegrationTests.class);
.getLogger(ContextSourceAndHibernateTransactionManagerIntegrationTests.class);
@Autowired
@Qualifier("dummyDao")

View File

@@ -44,7 +44,7 @@ public class ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests
extends AbstractJUnit4SpringContextTests {
private static Logger log = LoggerFactory
.getLogger(ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.class);
.getLogger(ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.class);
@Autowired
@Qualifier("dummyDao")

View File

@@ -58,7 +58,7 @@ import static org.assertj.core.api.Assertions.fail;
public class ContextSourceAndHibernateTransactionManagerNamespaceITests extends AbstractLdapTemplateIntegrationTests {
private static Logger log = LoggerFactory
.getLogger(ContextSourceAndHibernateTransactionManagerNamespaceITests.class);
.getLogger(ContextSourceAndHibernateTransactionManagerNamespaceITests.class);
@Autowired
@Qualifier("dummyDao")

View File

@@ -60,8 +60,8 @@ public class LdapTemplateOdmWithDnAnnotationsITests extends AbstractLdapTemplate
@Test
public void testFindByDn() {
PersonWithDnAnnotations person = this.tested.findByDn(
LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"), PersonWithDnAnnotations.class);
PersonWithDnAnnotations person = this.tested
.findByDn(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"), PersonWithDnAnnotations.class);
assertThat(person).isNotNull();
assertThat(person.getCommonName()).isEqualTo("Some Person3");
@@ -77,8 +77,8 @@ public class LdapTemplateOdmWithDnAnnotationsITests extends AbstractLdapTemplate
@Test
public void testFindInCountry() {
List<PersonWithDnAnnotations> persons = this.tested.find(
LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(), PersonWithDnAnnotations.class);
List<PersonWithDnAnnotations> persons = this.tested
.find(LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(), PersonWithDnAnnotations.class);
assertThat(persons).hasSize(4);
@@ -93,9 +93,9 @@ public class LdapTemplateOdmWithDnAnnotationsITests extends AbstractLdapTemplate
@Test
public void testFindForStreamInCountry() {
List<PersonWithDnAnnotations> persons = this.tested
.findForStream(LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(),
PersonWithDnAnnotations.class)
.collect(Collectors.toList());
.findForStream(LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(),
PersonWithDnAnnotations.class)
.collect(Collectors.toList());
assertThat(persons).hasSize(4);

View File

@@ -97,8 +97,8 @@ public class LdapTemplateOdmWithNoDnAnnotationsITests extends AbstractLdapTempla
@Test
public void testFindForStream() {
List<Person> persons = this.tested
.findForStream(LdapQueryBuilder.query().where("cn").is("Some Person3"), Person.class)
.collect(Collectors.toList());
.findForStream(LdapQueryBuilder.query().where("cn").is("Some Person3"), Person.class)
.collect(Collectors.toList());
assertThat(persons).hasSize(1);
Person person = persons.get(0);
@@ -125,8 +125,8 @@ public class LdapTemplateOdmWithNoDnAnnotationsITests extends AbstractLdapTempla
@Test
public void testFindForStreamInCountry() {
List<Person> persons = this.tested
.findForStream(LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(), Person.class)
.collect(Collectors.toList());
.findForStream(LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(), Person.class)
.collect(Collectors.toList());
assertThat(persons).hasSize(4);
Person person = persons.get(0);