From fd8d1eb0f35a2f42342c29425690a452a138357f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:39:46 +0000 Subject: [PATCH 1/2] Bump io.spring.javaformat:spring-javaformat-gradle-plugin Bumps [io.spring.javaformat:spring-javaformat-gradle-plugin](https://github.com/spring-io/spring-javaformat) from 0.0.15 to 0.0.43. - [Release notes](https://github.com/spring-io/spring-javaformat/releases) - [Commits](https://github.com/spring-io/spring-javaformat/compare/v0.0.15...v0.0.43) --- updated-dependencies: - dependency-name: io.spring.javaformat:spring-javaformat-gradle-plugin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- buildSrc/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 5a88a8347..f851abb59 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -89,7 +89,7 @@ dependencies { implementation 'com.apollographql.apollo:apollo-runtime:2.4.6' implementation 'com.github.ben-manes:gradle-versions-plugin:0.38.0' implementation 'com.github.spullara.mustache.java:compiler:0.9.14' - implementation 'io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.15' + implementation 'io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.43' implementation 'io.spring.gradle:spring-security-release-plugin:1.0.3' implementation 'io.spring.nohttp:nohttp-gradle:0.0.11' implementation 'net.sourceforge.htmlunit:htmlunit:2.37.0' From 05aba7cd59e60afaea15ec914de407d4e22c9fde Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Thu, 15 Aug 2024 11:22:29 -0600 Subject: [PATCH 2/2] Fix Formatting --- .../ldap/aot/hint/LdapCoreRuntimeHints.java | 58 ++-- .../ldap/config/ContextSourceParser.java | 9 +- .../config/DefaultRenamingStrategyParser.java | 7 +- .../ldap/config/TransactionManagerParser.java | 4 +- .../ldap/core/DefaultLdapClient.java | 8 +- .../springframework/ldap/core/LdapRdn.java | 2 +- .../ldap/core/LdapTemplate.java | 11 +- .../BaseLdapPathBeanPostProcessor.java | 2 +- .../DefaultIncrementalAttributesMapper.java | 2 +- .../ldap/odm/annotations/DnAttribute.java | 1 + .../ldap/odm/annotations/Id.java | 1 - .../ldap/odm/annotations/Transient.java | 1 - .../impl/DefaultObjectDirectoryMapper.java | 2 +- .../ldap/odm/core/impl/ObjectMetaData.java | 4 +- .../DirContextPoolableObjectFactory.java | 2 +- .../DirContextPooledObjectFactory.java | 2 +- .../ldap/query/DefaultContainerCriteria.java | 10 +- ...SourceAndDataSourceTransactionManager.java | 4 +- ...tSourceAndHibernateTransactionManager.java | 4 +- ...ctionAwareDirContextInvocationHandler.java | 2 +- ...ompensatingTransactionManagerDelegate.java | 2 +- .../support/CompensatingTransactionUtils.java | 4 +- .../ldap/NamingExceptionTests.java | 6 +- .../aot/hint/LdapCoreRuntimeHintsTests.java | 80 +++-- .../LdapTemplateNamespaceHandlerTests.java | 14 +- ...equestControlDirContextProcessorTests.java | 2 +- ...tingNameClassPairCallbackHandlerTests.java | 2 +- .../ldap/core/DefaultLdapClientListTests.java | 8 +- .../core/DefaultLdapClientLookupTests.java | 6 +- .../ldap/core/DefaultLdapClientTests.java | 94 ++++-- .../ldap/core/LdapTemplateTests.java | 42 ++- .../BaseLdapPathBeanPostProcessorTests.java | 2 +- .../core/support/LdapContextSourceTests.java | 6 +- .../ldap/filter/AndFilterTests.java | 5 +- .../ldap/filter/OrFilterTests.java | 5 +- .../DefaultObjectDirectoryMapperTests.java | 13 +- .../ldap/pool/DelegatingContextTests.java | 2 +- .../DirContextPoolableObjectFactoryTests.java | 2 +- .../DefaultDirContextValidatorTests.java | 8 +- .../ldap/pool2/DelegatingContextTests.java | 2 +- .../DirContextPooledObjectFactoryTests.java | 2 +- .../ldap/query/LdapQueryBuilderTests.java | 25 +- .../ldap/support/LdapNameBuilderTests.java | 6 +- .../ldap/support/LdapUtilsTests.java | 128 +++---- .../BindOperationRecorderTests.java | 4 +- ...odifyAttributesOperationRecorderTests.java | 4 +- .../RebindOperationRecorderTests.java | 2 +- .../RenameOperationRecorderTests.java | 2 +- .../ContextSourceTransactionManagerTests.java | 6 +- ...atingTransactionOperationManagerTests.java | 2 +- .../ldap/ldif/parser/LdifParser.java | 117 +++---- ...DefaultAttributeValidationPolicyTests.java | 49 +-- .../ldap/odm/tools/SchemaReader.java | 34 +- .../ldap/odm/tools/SchemaToJava.java | 6 +- .../ldap/odm/tools/SchemaViewer.java | 5 +- .../ldap/odm/test/ConverterFactoryTests.java | 2 +- .../ldap/odm/test/ConverterManagerTests.java | 4 +- .../ldap/odm/test/LdapTests.java | 4 +- .../ldap/odm/test/SchemaToJavaTests.java | 2 +- .../odm/test/utils/CompilerInterface.java | 2 +- ...stViewControlDirContextProcessorTests.java | 28 +- ...stractEc2InstanceLaunchingFactoryBean.java | 2 +- .../ad/IncrementalAttributeMapperITests.java | 2 +- ...DefaultLdapClientAuthenticationITests.java | 22 +- .../DefaultLdapClientBindUnbindITests.java | 2 +- .../itest/DefaultLdapClientListITests.java | 2 +- .../itest/DefaultLdapClientLookupITests.java | 21 +- ...DefaultLdapClientLookupMultiRdnITests.java | 5 +- ...efaultLdapClientRecursiveDeleteITests.java | 4 +- .../DefaultLdapClientSearchResultITests.java | 319 ++++++++++++------ .../LdapTemplateAuthenticationITests.java | 8 +- .../LdapTemplateLookupMultiRdnITests.java | 4 +- .../itest/LdapTemplateNoBaseSuffixITests.java | 2 +- .../itest/LdapTemplateSearchResultITests.java | 153 ++++++--- ...lateSearchResultNamespaceConfigITests.java | 153 ++++++--- .../control/SupportedControlsITests.java | 2 +- .../core/simple/SimpleLdapTemplateITests.java | 2 +- ...rceTransactionManagerIntegrationTests.java | 4 +- ...sactionManagerLdap179IntegrationTests.java | 2 +- ...urceTransactionManagerNamespaceITests.java | 4 +- ...ateTransactionManagerIntegrationTests.java | 2 +- ...sactionManagerLdap179IntegrationTests.java | 2 +- ...nateTransactionManagerNamespaceITests.java | 2 +- ...dapTemplateOdmWithDnAnnotationsITests.java | 14 +- ...pTemplateOdmWithNoDnAnnotationsITests.java | 8 +- 85 files changed, 968 insertions(+), 648 deletions(-) diff --git a/core/src/main/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHints.java b/core/src/main/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHints.java index 6844176df..130bf2caa 100644 --- a/core/src/main/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHints.java +++ b/core/src/main/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHints.java @@ -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"))); } diff --git a/core/src/main/java/org/springframework/ldap/config/ContextSourceParser.java b/core/src/main/java/org/springframework/ldap/config/ContextSourceParser.java index 73c8d3b47..3510388b8 100644 --- a/core/src/main/java/org/springframework/ldap/config/ContextSourceParser.java +++ b/core/src/main/java/org/springframework/ldap/config/ContextSourceParser.java @@ -177,7 +177,8 @@ public BeanDefinition parse(Element element, ParserContext parserContext) { 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 BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinition actualContextSourceDefinition = targetContextSourceDefinition; if (!anonymousReadOnly) { BeanDefinitionBuilder proxyBuilder = BeanDefinitionBuilder - .rootBeanDefinition(TransactionAwareContextSourceProxy.class); + .rootBeanDefinition(TransactionAwareContextSourceProxy.class); proxyBuilder.addConstructorArgValue(targetContextSourceDefinition); actualContextSourceDefinition = proxyBuilder.getBeanDefinition(); } @@ -306,7 +307,7 @@ private void populatePoolValidationProperties(BeanDefinitionBuilder builder, Ele 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 @@ private void populatePoolValidationProperties(BeanDefinitionBuilder builder, Ele 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)); diff --git a/core/src/main/java/org/springframework/ldap/config/DefaultRenamingStrategyParser.java b/core/src/main/java/org/springframework/ldap/config/DefaultRenamingStrategyParser.java index 87d7d91fb..7af4dffe5 100644 --- a/core/src/main/java/org/springframework/ldap/config/DefaultRenamingStrategyParser.java +++ b/core/src/main/java/org/springframework/ldap/config/DefaultRenamingStrategyParser.java @@ -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; } diff --git a/core/src/main/java/org/springframework/ldap/config/TransactionManagerParser.java b/core/src/main/java/org/springframework/ldap/config/TransactionManagerParser.java index 18b4b870e..550a2904a 100644 --- a/core/src/main/java/org/springframework/ldap/config/TransactionManagerParser.java +++ b/core/src/main/java/org/springframework/ldap/config/TransactionManagerParser.java @@ -101,7 +101,7 @@ else if (StringUtils.hasText(sessionFactoryRef)) { 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 @@ private BeanDefinition parseDifferentSubtreeRenamingStrategy(Element element) { 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)); diff --git a/core/src/main/java/org/springframework/ldap/core/DefaultLdapClient.java b/core/src/main/java/org/springframework/ldap/core/DefaultLdapClient.java index b620e0182..1f8cd0b7e 100644 --- a/core/src/main/java/org/springframework/ldap/core/DefaultLdapClient.java +++ b/core/src/main/java/org/springframework/ldap/core/DefaultLdapClient.java @@ -318,8 +318,10 @@ private Stream toStream(NamingEnumeration res Enumeration enumeration = enumeration(results); Function 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 @@ else if (identification.size() != 1) { 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 { diff --git a/core/src/main/java/org/springframework/ldap/core/LdapRdn.java b/core/src/main/java/org/springframework/ldap/core/LdapRdn.java index 1256b98b8..d6dd3b28f 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapRdn.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapRdn.java @@ -287,7 +287,7 @@ public LdapRdn immutableLdapRdn() { mapWithImmutableRdns.put(rdnComponent.getKey(), rdnComponent.immutableLdapRdnComponent()); } Map unmodifiableMapOfImmutableRdns = Collections - .unmodifiableMap(mapWithImmutableRdns); + .unmodifiableMap(mapWithImmutableRdns); LdapRdn immutableRdn = new LdapRdn(); immutableRdn.components = unmodifiableMapOfImmutableRdns; return immutableRdn; diff --git a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java index 07651c113..1c89bf342 100644 --- a/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java +++ b/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java @@ -1334,7 +1334,7 @@ public boolean authenticate(Name base, String filter, String password, 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 @@ Stream searchForStream(LdapQuery query, Function mapper) 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)); } /** diff --git a/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java b/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java index 5914883ba..e99e034e0 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java +++ b/core/src/main/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessor.java @@ -94,7 +94,7 @@ BaseLdapPathSource getBaseLdapPathSourceFromApplicationContext() { } Collection beans = this.applicationContext.getBeansOfType(BaseLdapPathSource.class) - .values(); + .values(); if (beans.isEmpty()) { throw new NoSuchBeanDefinitionException("No BaseLdapPathSource implementation definition found"); } diff --git a/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java b/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java index 4464e575e..422cdfa94 100644 --- a/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java +++ b/core/src/main/java/org/springframework/ldap/core/support/DefaultIncrementalAttributesMapper.java @@ -333,7 +333,7 @@ public static List lookupAttributeValues(LdapOperations ldapOperations, */ public static List lookupAttributeValues(LdapOperations ldapOperations, Name dn, String attribute) { List values = loopForAllAttributeValues(ldapOperations, dn, new String[] { attribute }) - .getValues(attribute); + .getValues(attribute); if (values == null) { values = Collections.emptyList(); } diff --git a/core/src/main/java/org/springframework/ldap/odm/annotations/DnAttribute.java b/core/src/main/java/org/springframework/ldap/odm/annotations/DnAttribute.java index 0d51b5c5a..ae9612e1b 100644 --- a/core/src/main/java/org/springframework/ldap/odm/annotations/DnAttribute.java +++ b/core/src/main/java/org/springframework/ldap/odm/annotations/DnAttribute.java @@ -32,6 +32,7 @@ * {@link org.springframework.ldap.odm.annotations.Entry#base()} value will be used to * figure out the distinguished name of entries to create and update. *

+ * * @author Mattias Hellborg Arthursson * @since 2.0 */ diff --git a/core/src/main/java/org/springframework/ldap/odm/annotations/Id.java b/core/src/main/java/org/springframework/ldap/odm/annotations/Id.java index 1a7daf0fc..0fcdfff08 100755 --- a/core/src/main/java/org/springframework/ldap/odm/annotations/Id.java +++ b/core/src/main/java/org/springframework/ldap/odm/annotations/Id.java @@ -29,7 +29,6 @@ * annotated {@link Attribute}. * * @author Paul Harvey <paul.at.pauls-place.me.uk> - * * @see Attribute * @see javax.naming.Name */ diff --git a/core/src/main/java/org/springframework/ldap/odm/annotations/Transient.java b/core/src/main/java/org/springframework/ldap/odm/annotations/Transient.java index 8801dd6cd..43aba6b97 100755 --- a/core/src/main/java/org/springframework/ldap/odm/annotations/Transient.java +++ b/core/src/main/java/org/springframework/ldap/odm/annotations/Transient.java @@ -26,7 +26,6 @@ * not be persisted to LDAP. * * @author Paul Harvey <paul@pauls-place.me.uk> - * * @see Entry */ @Target(ElementType.FIELD) diff --git a/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java b/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java index f3773b6dc..f55b33b0f 100644 --- a/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java +++ b/core/src/main/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapper.java @@ -209,7 +209,7 @@ public void mapToLdapDataEntry(Object entry, LdapDataEntry context) { // 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++) { diff --git a/core/src/main/java/org/springframework/ldap/odm/core/impl/ObjectMetaData.java b/core/src/main/java/org/springframework/ldap/odm/core/impl/ObjectMetaData.java index 2388f15a2..f0092441a 100755 --- a/core/src/main/java/org/springframework/ldap/odm/core/impl/ObjectMetaData.java +++ b/core/src/main/java/org/springframework/ldap/odm/core/impl/ObjectMetaData.java @@ -139,8 +139,8 @@ AttributeMetaData getAttribute(Field field) { 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; } diff --git a/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java b/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java index 59c77ea4b..4746dc67a 100644 --- a/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java +++ b/core/src/main/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactory.java @@ -152,7 +152,7 @@ public Object makeObject(Object key) throws Exception { 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); diff --git a/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactory.java b/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactory.java index d79bc1efd..092b33060 100644 --- a/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactory.java +++ b/core/src/main/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactory.java @@ -213,7 +213,7 @@ public Object create(Object key) throws Exception { 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); diff --git a/core/src/main/java/org/springframework/ldap/query/DefaultContainerCriteria.java b/core/src/main/java/org/springframework/ldap/query/DefaultContainerCriteria.java index 767abcd0c..fae3140ac 100644 --- a/core/src/main/java/org/springframework/ldap/query/DefaultContainerCriteria.java +++ b/core/src/main/java/org/springframework/ldap/query/DefaultContainerCriteria.java @@ -69,8 +69,9 @@ public ConditionCriteria or(String attribute) { @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 @@ public ContainerCriteria and(ContainerCriteria nested) { @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; diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java index 188eef984..37562b4be 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndDataSourceTransactionManager.java @@ -114,7 +114,7 @@ protected void doCleanupAfterCompletion(Object transaction) { protected void doCommit(DefaultTransactionStatus status) { ContextSourceAndDataSourceTransactionObject actualTransactionObject = (ContextSourceAndDataSourceTransactionObject) status - .getTransaction(); + .getTransaction(); try { super.doCommit(new DefaultTransactionStatus(actualTransactionObject.getDataSourceTransactionObject(), @@ -147,7 +147,7 @@ protected void doCommit(DefaultTransactionStatus status) { @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(), diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java index 9ddaa71f2..3d32dc72c 100755 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceAndHibernateTransactionManager.java @@ -115,7 +115,7 @@ protected void doCleanupAfterCompletion(Object transaction) { protected void doCommit(DefaultTransactionStatus status) { ContextSourceAndHibernateTransactionObject actualTransactionObject = (ContextSourceAndHibernateTransactionObject) status - .getTransaction(); + .getTransaction(); try { super.doCommit(new DefaultTransactionStatus(actualTransactionObject.getHibernateTransactionObject(), @@ -147,7 +147,7 @@ protected void doCommit(DefaultTransactionStatus status) { @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(), diff --git a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandler.java b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandler.java index 6f6f101b8..9ce5edb24 100644 --- a/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandler.java +++ b/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandler.java @@ -104,7 +104,7 @@ else if (LdapTransactionUtils.isSupportedWriteTransactionOperation(methodName)) */ 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 diff --git a/core/src/main/java/org/springframework/transaction/compensating/support/AbstractCompensatingTransactionManagerDelegate.java b/core/src/main/java/org/springframework/transaction/compensating/support/AbstractCompensatingTransactionManagerDelegate.java index 3cedad26c..c550f7b74 100644 --- a/core/src/main/java/org/springframework/transaction/compensating/support/AbstractCompensatingTransactionManagerDelegate.java +++ b/core/src/main/java/org/springframework/transaction/compensating/support/AbstractCompensatingTransactionManagerDelegate.java @@ -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); } diff --git a/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionUtils.java b/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionUtils.java index b7aa47eab..65cffb3d0 100644 --- a/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionUtils.java +++ b/core/src/main/java/org/springframework/transaction/compensating/support/CompensatingTransactionUtils.java @@ -50,11 +50,11 @@ private 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); } diff --git a/core/src/test/java/org/springframework/ldap/NamingExceptionTests.java b/core/src/test/java/org/springframework/ldap/NamingExceptionTests.java index a1b66378a..ff231a1b3 100644 --- a/core/src/test/java/org/springframework/ldap/NamingExceptionTests.java +++ b/core/src/test/java/org/springframework/ldap/NamingExceptionTests.java @@ -46,9 +46,11 @@ public void testNamingExceptionWithNonSerializableResolvedObj() throws Exception 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 { diff --git a/core/src/test/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHintsTests.java b/core/src/test/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHintsTests.java index 2618cf590..4ebbf12f2 100644 --- a/core/src/test/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHintsTests.java +++ b/core/src/test/java/org/springframework/ldap/aot/hint/LdapCoreRuntimeHintsTests.java @@ -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); } } diff --git a/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java b/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java index b72a0ea9d..a645098dc 100644 --- a/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java +++ b/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTests.java @@ -73,7 +73,7 @@ public void verifyParseWithDefaultValues() { 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 void verifyParseWithCustomValues() { 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 void supportsSpel() { 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 void supportsSpelMultiUrls() { 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 void supportsMultipleUrls() { 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 void verifyParsePooling2Defaults() { 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 void verifyParsePool2SizeSet() { 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); diff --git a/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTests.java b/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTests.java index f72bef396..d4c6a1b83 100644 --- a/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTests.java +++ b/core/src/test/java/org/springframework/ldap/control/RequestControlDirContextProcessorTests.java @@ -104,7 +104,7 @@ public void testPreProcessWithExistingControlOfSameClassAndPropertyFalseShouldAd this.tested.preProcess(this.ldapContextMock); verify(this.ldapContextMock) - .setRequestControls(new Control[] { this.requestControl2Mock, this.requestControlMock }); + .setRequestControls(new Control[] { this.requestControl2Mock, this.requestControlMock }); } @Test diff --git a/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTests.java b/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTests.java index 79f73d99d..f999df231 100644 --- a/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTests.java +++ b/core/src/test/java/org/springframework/ldap/core/CollectingNameClassPairCallbackHandlerTests.java @@ -41,7 +41,7 @@ public void setUp() throws Exception { this.tested = new CollectingNameClassPairCallbackHandler() { public Object getObjectFromNameClassPair(NameClassPair nameClassPair) { assertThat(nameClassPair) - .isSameAs(CollectingNameClassPairCallbackHandlerTests.this.expectedNameClassPair); + .isSameAs(CollectingNameClassPairCallbackHandlerTests.this.expectedNameClassPair); return CollectingNameClassPairCallbackHandlerTests.this.expectedResult; } }; diff --git a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTests.java b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTests.java index 5b72ec0a0..5d82e7e28 100644 --- a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTests.java +++ b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientListTests.java @@ -144,7 +144,7 @@ public void testList_PartialResultException() throws NamingException { 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 void testList_Stream_PartialResultException() throws NamingException { 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 void testList_NamingException() throws NamingException { 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 void testList_AsStream_NamingException() throws NamingException { 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(); } diff --git a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTests.java b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTests.java index 1e323a7cc..5108dff5d 100644 --- a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTests.java +++ b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientLookupTests.java @@ -101,7 +101,7 @@ public void testLookup_NamingException() throws Exception { 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 void testLookup_AttributesMapper_NamingException() throws Exception { 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 void testLookup_ContextMapper_NamingException() throws Exception { 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(); } diff --git a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTests.java b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTests.java index 2b23e9405..8e572b2ee 100644 --- a/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTests.java +++ b/core/src/test/java/org/springframework/ldap/core/DefaultLdapClientTests.java @@ -146,9 +146,9 @@ public void testSearchContextMapper() throws Exception { 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 void testSearch_StringBase_CallbackHandler() throws Exception { 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 void testSearch_AttributeMapper_Defaults() throws Exception { 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 void testSearch_String_AttributeMapper_Defaults() throws Exception { 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 void testSearch_NameNotFoundException() throws Exception { 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 void testSearch_NamingException() throws Exception { 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 void testSearch_NamingException() throws Exception { public void verifyThatDefaultSearchControlParametersAreAutomaticallyAppliedInSearch() throws Exception { Supplier 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 void testRebind() throws Exception { 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 void testRebind_String() throws Exception { 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 void testSearch_PartialResult_IgnoreNotSet() throws Exception { @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 void testAuthenticateWithSingleUserFoundShouldBeSuccessful() throws Excep 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 void testAuthenticateWhenNoUserWasFoundShouldFail() throws Exception { 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 void testAuthenticateQueryPasswordWhenNoUserWasFoundShouldThrowEmptyResul 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 void testAuthenticateWithFailedAuthenticationShouldFail() throws Exceptio 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 @@ private void singleSearchResult(SearchControls controls, SearchResult searchResu 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 @@ else if (searchResults.length == 2) { 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); diff --git a/core/src/test/java/org/springframework/ldap/core/LdapTemplateTests.java b/core/src/test/java/org/springframework/ldap/core/LdapTemplateTests.java index c77cece04..1f9eee7f5 100644 --- a/core/src/test/java/org/springframework/ldap/core/LdapTemplateTests.java +++ b/core/src/test/java/org/springframework/ldap/core/LdapTemplateTests.java @@ -217,7 +217,8 @@ public void testSearch_NameNotFoundException() throws Exception { 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 void testSearch_NamingException() throws Exception { 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 void testFindOne() throws Exception { 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 void verifyThatFindOneThrowsEmptyResultIfNoResult() throws Exception { 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 void verifyThatFindOneThrowsIncorrectResultSizeDataAccessExceptionWhenMor 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 void testDoSearch_NameNotFoundException() throws Exception { 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 void testSearch_PartialResult_IgnoreSet() throws Exception { 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 void testSearchForObjectWithMultipleResults() throws Exception { 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 void testAuthenticateWithSingleUserFoundShouldBeSuccessful() throws Excep 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 void testAuthenticateQueryPasswordMapperWhenNoUserWasFoundShouldThrowEmpt 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 void testAuthenticateQueryPasswordWhenNoUserWasFoundShouldThrowEmptyResul 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 void testAuthenticateWithFailedAuthenticationShouldFail() throws Exceptio 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 void testAuthenticateWithErrorInCallbackShouldFail() throws Exception { 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 void testAuthenticateWithErrorInCallbackShouldFail() throws Exception { 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 @@ private void singleSearchResult(SearchControls controls, SearchResult searchResu 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 @@ else if (searchResults.length == 2) { 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); diff --git a/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTests.java b/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTests.java index c9d2c4970..6ffc42b9d 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTests.java +++ b/core/src/test/java/org/springframework/ldap/core/support/BaseLdapPathBeanPostProcessorTests.java @@ -123,7 +123,7 @@ BaseLdapPathSource getBaseLdapPathSourceFromApplicationContext() { @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 expectedBeans = new HashMap() { diff --git a/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTests.java b/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTests.java index dc17f7813..51382623a 100644 --- a/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTests.java +++ b/core/src/test/java/org/springframework/ldap/core/support/LdapContextSourceTests.java @@ -73,7 +73,7 @@ public void testGetAnonymousEnv() throws Exception { // 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 void testGetAnonymousEnv() throws Exception { 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 void testGetAuthenticatedEnv() throws Exception { // 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 diff --git a/core/src/test/java/org/springframework/ldap/filter/AndFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/AndFilterTests.java index 2997e8391..357a485b4 100644 --- a/core/src/test/java/org/springframework/ldap/filter/AndFilterTests.java +++ b/core/src/test/java/org/springframework/ldap/filter/AndFilterTests.java @@ -49,8 +49,9 @@ public void testTwo() { @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))"); } diff --git a/core/src/test/java/org/springframework/ldap/filter/OrFilterTests.java b/core/src/test/java/org/springframework/ldap/filter/OrFilterTests.java index 35eb145a4..c5b844219 100644 --- a/core/src/test/java/org/springframework/ldap/filter/OrFilterTests.java +++ b/core/src/test/java/org/springframework/ldap/filter/OrFilterTests.java @@ -50,8 +50,9 @@ public void testTwo() { @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))"); } diff --git a/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java b/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java index 63c58f1e1..79a31a904 100644 --- a/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java +++ b/core/src/test/java/org/springframework/ldap/odm/core/impl/DefaultObjectDirectoryMapperTests.java @@ -68,9 +68,16 @@ public void testMapping() { 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); diff --git a/core/src/test/java/org/springframework/ldap/pool/DelegatingContextTests.java b/core/src/test/java/org/springframework/ldap/pool/DelegatingContextTests.java index 8a682355a..ff22a6f07 100644 --- a/core/src/test/java/org/springframework/ldap/pool/DelegatingContextTests.java +++ b/core/src/test/java/org/springframework/ldap/pool/DelegatingContextTests.java @@ -422,7 +422,7 @@ public void testDoubleClose() throws Exception { @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); diff --git a/core/src/test/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactoryTests.java b/core/src/test/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactoryTests.java index 62f02225b..6ebc9474f 100644 --- a/core/src/test/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactoryTests.java +++ b/core/src/test/java/org/springframework/ldap/pool/factory/DirContextPoolableObjectFactoryTests.java @@ -185,7 +185,7 @@ public void testValidateObject() throws Exception { 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); diff --git a/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTests.java b/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTests.java index 452b6ee42..02979b085 100644 --- a/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTests.java +++ b/core/src/test/java/org/springframework/ldap/pool/validation/DefaultDirContextValidatorTests.java @@ -52,7 +52,7 @@ public void setUp() throws Exception { 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 void testSearchScopeOneLevelScopeSetInConstructorIsUsed() throws Exceptio 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 void testSearchScopeSubTreeScopeSetInConstructorIsUsed() throws Exception 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 void testValidateDirContextException() throws Exception { 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); diff --git a/core/src/test/java/org/springframework/ldap/pool2/DelegatingContextTests.java b/core/src/test/java/org/springframework/ldap/pool2/DelegatingContextTests.java index b63d7c9b9..3833422c9 100644 --- a/core/src/test/java/org/springframework/ldap/pool2/DelegatingContextTests.java +++ b/core/src/test/java/org/springframework/ldap/pool2/DelegatingContextTests.java @@ -422,7 +422,7 @@ public void testDoubleClose() throws Exception { @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); diff --git a/core/src/test/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactoryTests.java b/core/src/test/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactoryTests.java index e029fdda4..072a7a142 100644 --- a/core/src/test/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactoryTests.java +++ b/core/src/test/java/org/springframework/ldap/pool2/factory/DirContextPooledObjectFactoryTests.java @@ -192,7 +192,7 @@ public void testValidateObject() throws Exception { 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); diff --git a/core/src/test/java/org/springframework/ldap/query/LdapQueryBuilderTests.java b/core/src/test/java/org/springframework/ldap/query/LdapQueryBuilderTests.java index f1909914a..0f1c38437 100644 --- a/core/src/test/java/org/springframework/ldap/query/LdapQueryBuilderTests.java +++ b/core/src/test/java/org/springframework/ldap/query/LdapQueryBuilderTests.java @@ -103,8 +103,15 @@ public void buildFilterFormat() { @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 void buildSimpleOr() { @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 void buildOrNegatedSubQueries() { @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)))"); } diff --git a/core/src/test/java/org/springframework/ldap/support/LdapNameBuilderTests.java b/core/src/test/java/org/springframework/ldap/support/LdapNameBuilderTests.java index ed9051bf1..dde503da9 100644 --- a/core/src/test/java/org/springframework/ldap/support/LdapNameBuilderTests.java +++ b/core/src/test/java/org/springframework/ldap/support/LdapNameBuilderTests.java @@ -39,8 +39,8 @@ public void testAddComponentToBaseString() { @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 void testAddStringNameToBaseString() { @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"); } diff --git a/core/src/test/java/org/springframework/ldap/support/LdapUtilsTests.java b/core/src/test/java/org/springframework/ldap/support/LdapUtilsTests.java index 34802a321..0037d70a3 100644 --- a/core/src/test/java/org/springframework/ldap/support/LdapUtilsTests.java +++ b/core/src/test/java/org/springframework/ldap/support/LdapUtilsTests.java @@ -302,138 +302,138 @@ public void testConvertLdapExceptions() { // 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 { diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTests.java index 99b2e5bc7..b42e9c6be 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTests.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/BindOperationRecorderTests.java @@ -48,7 +48,7 @@ public void testRecordOperation_Name() { 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 void testPerformOperation_String() { 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; diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTests.java index df376e36e..7e886309a 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTests.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/ModifyAttributesOperationRecorderTests.java @@ -81,12 +81,12 @@ protected ModificationItem getCompensatingModificationItem(Attributes originalAt 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(); diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTests.java index 0f9ccaebb..6424e5f14 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTests.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/RebindOperationRecorderTests.java @@ -57,7 +57,7 @@ public void testRecordOperation() { // 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); diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTests.java index cb9414b3f..a89abf7bb 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTests.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/RenameOperationRecorderTests.java @@ -40,7 +40,7 @@ public void testRecordOperation() { // 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; diff --git a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java index 28bf805d7..f97710719 100644 --- a/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java +++ b/core/src/test/java/org/springframework/ldap/transaction/compensating/manager/ContextSourceTransactionManagerTests.java @@ -102,7 +102,7 @@ public void testDoBegin() { 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 void testTransactionSuspension_UnconnectableDataSource() throws Exception 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 diff --git a/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTests.java b/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTests.java index 65cb4ce9f..c89f0f93d 100644 --- a/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTests.java +++ b/core/src/test/java/org/springframework/transaction/compensating/support/DefaultCompensatingTransactionOperationManagerTests.java @@ -54,7 +54,7 @@ public void testPerformOperation() { 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( diff --git a/ldif/ldif-core/src/main/java/org/springframework/ldap/ldif/parser/LdifParser.java b/ldif/ldif-core/src/main/java/org/springframework/ldap/ldif/parser/LdifParser.java index 05fe18622..b3ecd7e4d 100644 --- a/ldif/ldif-core/src/main/java/org/springframework/ldap/ldif/parser/LdifParser.java +++ b/ldif/ldif-core/src/main/java/org/springframework/ldap/ldif/parser/LdifParser.java @@ -253,82 +253,83 @@ public LdapAttributes getRecord() throws IOException { 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)"); - - // 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; + 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."); + } } - 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; } } - catch (NamingException ex) { - LOG.error("Error adding attribute to record", ex); - return null; - } - } - default: - // Take no action -- applies to VersionIdentifier, Comments, and voided - // records. + default: + // Take no action -- applies to VersionIdentifier, Comments, and + // voided + // records. } line = this.reader.readLine(); diff --git a/ldif/ldif-core/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTests.java b/ldif/ldif-core/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTests.java index f068290f1..ce42b737b 100644 --- a/ldif/ldif-core/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTests.java +++ b/ldif/ldif-core/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTests.java @@ -68,8 +68,8 @@ private enum AttributeType { private AttributeType type; private List 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 void parseAttribute() { 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 void parseAttribute() { 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 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 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 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 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; } log.info("Success!"); diff --git a/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaReader.java b/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaReader.java index 9eff2b3e8..2a5268912 100755 --- a/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaReader.java +++ b/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaReader.java @@ -166,23 +166,23 @@ private void createObjectClass(Set objectClasses, DirContext schemaConte 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 } } } diff --git a/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java b/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java index f5741fac4..cb6c74c87 100755 --- a/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java +++ b/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java @@ -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; diff --git a/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaViewer.java b/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaViewer.java index c8e9edc57..39f511c6d 100755 --- a/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaViewer.java +++ b/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaViewer.java @@ -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; diff --git a/odm/src/test/java/org/springframework/ldap/odm/test/ConverterFactoryTests.java b/odm/src/test/java/org/springframework/ldap/odm/test/ConverterFactoryTests.java index e4cff176b..33c962fb3 100755 --- a/odm/src/test/java/org/springframework/ldap/odm/test/ConverterFactoryTests.java +++ b/odm/src/test/java/org/springframework/ldap/odm/test/ConverterFactoryTests.java @@ -67,7 +67,7 @@ public void testConverterFactory() throws Exception { new ExecuteRunnable().runTests(new RunnableTests() { 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); } diff --git a/odm/src/test/java/org/springframework/ldap/odm/test/ConverterManagerTests.java b/odm/src/test/java/org/springframework/ldap/odm/test/ConverterManagerTests.java index 1c1b8a8e7..fcce66f39 100755 --- a/odm/src/test/java/org/springframework/ldap/odm/test/ConverterManagerTests.java +++ b/odm/src/test/java/org/springframework/ldap/odm/test/ConverterManagerTests.java @@ -102,7 +102,7 @@ public void basicTypeConverion() throws Exception { new ExecuteRunnable>().runTests(new RunnableTests>() { 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 void syntaxBasedConversion() throws Exception { new ExecuteRunnable>().runTests(new RunnableTests>() { 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); diff --git a/odm/src/test/java/org/springframework/ldap/odm/test/LdapTests.java b/odm/src/test/java/org/springframework/ldap/odm/test/LdapTests.java index 6669fd54d..4f045c07f 100755 --- a/odm/src/test/java/org/springframework/ldap/odm/test/LdapTests.java +++ b/odm/src/test/java/org/springframework/ldap/odm/test/LdapTests.java @@ -312,7 +312,7 @@ public void testSecondOc() { this.searchControls); LOG.debug(String.format("Found - %1$s", allOus)); assertThat(new HashSet(Arrays.asList(ouTestData))) - .isEqualTo(new HashSet(allOus)); + .isEqualTo(new HashSet(allOus)); OrganizationalUnit testOu = ouTestData[OrganizationalName.ASSISTANTS.getIndex()]; LOG.debug(String.format("Reading - %1$s", testOu.getDn())); @@ -337,7 +337,7 @@ public void findAllAsPlainPersons() { 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 diff --git a/odm/src/test/java/org/springframework/ldap/odm/test/SchemaToJavaTests.java b/odm/src/test/java/org/springframework/ldap/odm/test/SchemaToJavaTests.java index 94293fe33..0cd884001 100755 --- a/odm/src/test/java/org/springframework/ldap/odm/test/SchemaToJavaTests.java +++ b/odm/src/test/java/org/springframework/ldap/odm/test/SchemaToJavaTests.java @@ -215,7 +215,7 @@ public void generate() throws Exception { Method telephoneNumberIteratorMethod = clazz.getMethod("getTelephoneNumberIterator"); @SuppressWarnings("unchecked") Iterator telephoneNumberIterator = (Iterator) telephoneNumberIteratorMethod - .invoke(fromDirectory); + .invoke(fromDirectory); int telephoneNumberCount = 0; while (telephoneNumberIterator.hasNext()) { telephoneNumberCount++; diff --git a/odm/src/test/java/org/springframework/ldap/odm/test/utils/CompilerInterface.java b/odm/src/test/java/org/springframework/ldap/odm/test/utils/CompilerInterface.java index 49dadd28e..e8455c957 100755 --- a/odm/src/test/java/org/springframework/ldap/odm/test/utils/CompilerInterface.java +++ b/odm/src/test/java/org/springframework/ldap/odm/test/utils/CompilerInterface.java @@ -33,7 +33,7 @@ public static void compile(String directory, String file) throws Exception { StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); Iterable javaFileObjects = fileManager - .getJavaFileObjectsFromFiles(Arrays.asList(toCompile)); + .getJavaFileObjectsFromFiles(Arrays.asList(toCompile)); compiler.getTask(null, fileManager, null, null, null, javaFileObjects).call(); fileManager.close(); diff --git a/sandbox/src/test/java/org/springframework/ldap/control/VirtualListViewControlDirContextProcessorTests.java b/sandbox/src/test/java/org/springframework/ldap/control/VirtualListViewControlDirContextProcessorTests.java index 8058e9add..d0b481f52 100644 --- a/sandbox/src/test/java/org/springframework/ldap/control/VirtualListViewControlDirContextProcessorTests.java +++ b/sandbox/src/test/java/org/springframework/ldap/control/VirtualListViewControlDirContextProcessorTests.java @@ -164,20 +164,20 @@ private void assertEncodedRequest(byte[] encodedValue, int expectedBeforeCount, 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 1: // greaterThanOrEqual - throw new AssertionFailedError("CHOICE value greaterThanOrEqual not supported"); - - default: - throw new AssertionFailedError("illegal CHOICE value: " + 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 1: // greaterThanOrEqual + throw new AssertionFailedError("CHOICE value greaterThanOrEqual not supported"); + + default: + throw new AssertionFailedError("illegal CHOICE value: " + targetType); } byte[] bs = ber.parseOctetString(Ber.ASN_OCTET_STR, null); assertContextId(expectedContextId, bs); diff --git a/test-support/src/main/java/org/springframework/ldap/test/AbstractEc2InstanceLaunchingFactoryBean.java b/test-support/src/main/java/org/springframework/ldap/test/AbstractEc2InstanceLaunchingFactoryBean.java index 29505fbd1..ef7ff759f 100644 --- a/test-support/src/main/java/org/springframework/ldap/test/AbstractEc2InstanceLaunchingFactoryBean.java +++ b/test-support/src/main/java/org/springframework/ldap/test/AbstractEc2InstanceLaunchingFactoryBean.java @@ -129,7 +129,7 @@ protected final Object createInstance() throws Exception { 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); } diff --git a/test/integration-tests-ad/src/test/java/org/springframework/ldap/itest/ad/IncrementalAttributeMapperITests.java b/test/integration-tests-ad/src/test/java/org/springframework/ldap/itest/ad/IncrementalAttributeMapperITests.java index 35548bea7..ac705bb90 100644 --- a/test/integration-tests-ad/src/test/java/org/springframework/ldap/itest/ad/IncrementalAttributeMapperITests.java +++ b/test/integration-tests-ad/src/test/java/org/springframework/ldap/itest/ad/IncrementalAttributeMapperITests.java @@ -225,7 +225,7 @@ public Object doInTransaction(TransactionStatus status) { // 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); } } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientAuthenticationITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientAuthenticationITests.java index c6af19288..216625c18 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientAuthenticationITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientAuthenticationITests.java @@ -76,7 +76,7 @@ public void testAuthenticateWithInvalidPassword() { 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 void testAuthenticateWithLdapQueryAndInvalidPassword() { 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 void testAuthenticateWithLookupOperationPerformedOnAuthenticatedContext() @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 void testAuthenticateWithLdapQueryAndMapper() { 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 void testAuthenticateWithInvalidPasswordAndCollectedException() { 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 void testAuthenticateWithInvalidPasswordAndCollectedException() { 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 void testAuthenticateWithFilterThatMatchesSeveralEntries() { 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 diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientBindUnbindITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientBindUnbindITests.java index c4091bf9f..daf7a9d8c 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientBindUnbindITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientBindUnbindITests.java @@ -158,7 +158,7 @@ private void verifyReboundCorrectData() { private void verifyCleanup() { assertThatExceptionOfType(NameNotFoundException.class).describedAs("NameNotFoundException expected") - .isThrownBy(() -> this.tested.search().name(DN).toEntry()); + .isThrownBy(() -> this.tested.search().name(DN).toEntry()); } } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientListITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientListITests.java index 858fc70f0..7cec0c215 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientListITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientListITests.java @@ -73,7 +73,7 @@ public void testListBindings_ContextMapper() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List list = this.tested.listBindings("ou=company2,ou=Sweden" + BASE_STRING) - .toList(this.contextMapper); + .toList(this.contextMapper); assertThat(list).hasSize(1); } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientLookupITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientLookupITests.java index 60c9c344a..93bc9e4bf 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientLookupITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientLookupITests.java @@ -82,8 +82,9 @@ public void testLookup_AttributesMapper() { @Test public void testLookup_AttributesMapper_LdapName() { AttributesMapper 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 void testLookup_ReturnAttributes_AttributesMapper() { AttributesMapper 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 void testLookup_ReturnAttributes_AttributesMapper() { @Test public void testLookup_ReturnAttributes_AttributesMapper_LdapName() { AttributesMapper 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 void testLookup_ReturnAttributes_ContextMapper() { ContextMapper 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(); diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientLookupMultiRdnITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientLookupMultiRdnITests.java index ef4b7fb9d..c8cb6eac0 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientLookupMultiRdnITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientLookupMultiRdnITests.java @@ -76,8 +76,9 @@ public void testLookup_MultiValuedRdn_DirContextAdapter() { @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); } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientRecursiveDeleteITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientRecursiveDeleteITests.java index 646b3ea59..179aae66d 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientRecursiveDeleteITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientRecursiveDeleteITests.java @@ -123,8 +123,8 @@ public void testRecursiveUnbindOnLeaf() { 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)); } } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientSearchResultITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientSearchResultITests.java index bf2bf6fa4..8a1e98ba5 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientSearchResultITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/DefaultLdapClientSearchResultITests.java @@ -106,9 +106,9 @@ public void testSearch_LdapQuery_AttributesMapper() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.search().query( - LdapQueryBuilder.query().base(BASE_STRING).where("objectclass").is("person").and("sn").is("Person2")) - .toList(this.attributesMapper); + List 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 void testSearchForStream_LdapQuery_AttributesMapper() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearch_LdapQuery_AttributesMapper_FewerAttributes() { this.attributesMapper.setExpectedAttributes(new String[] { "cn" }); this.attributesMapper.setExpectedValues(new String[] { "Some Person2" }); - List list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn") - .where("objectclass").is("person").and("sn").is("Person2")).toList(this.attributesMapper); + List 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 void testSearchForStream_LdapQuery_AttributesMapper_FewerAttributes() { this.attributesMapper.setExpectedAttributes(new String[] { "cn" }); this.attributesMapper.setExpectedValues(new String[] { "Some Person2" }); - List 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 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 void testSearch_LdapQuery_AttributesMapper_SearchScope() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearchForStream_LdapQuery_AttributesMapper_SearchScope() { this.attributesMapper.setExpectedValues(ALL_VALUES); List 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 void testSearch_LdapQuery_AttributesMapper_SearchScope_CorrectBase() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearchForStream_LdapQuery_AttributesMapper_SearchScope_CorrectBa this.attributesMapper.setExpectedValues(ALL_VALUES); List 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 void testSearch_LdapQuery_AttributesMapper_NoBase() { this.attributesMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForStream_LdapQuery_AttributesMapper_NoBase() { this.attributesMapper.setExpectedValues(ALL_VALUES); List 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 void testSearch_LdapQuery_AttributesMapper_DifferentBase() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.search().query( - LdapQueryBuilder.query().base("ou=Norway").where("objectclass").is("person").and("sn").is("Person2")) - .toList(this.attributesMapper); + List 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 void testSearchForStream_LdapQuery_AttributesMapper_DifferentBase() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearchForStream_LdapQuery_AttributesMapper_DifferentBase() { public void testSearch_SearchScope_AttributesMapper() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.search().query( - LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING)) - .toList(this.attributesMapper); + List 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 void testSearch_SearchScope_LimitedAttrs_AttributesMapper() { this.attributesMapper.setExpectedAttributes(CN_SN_ATTRS); this.attributesMapper.setExpectedValues(CN_SN_VALUES); this.attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES); - List list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING) - .searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING)) - .toList(this.attributesMapper); + List 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 void testSearch_SearchScope_LimitedAttrs_AttributesMapper() { public void testSearch_AttributesMapper_Name() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_NAME).filter(FILTER_STRING)) - .toList(this.attributesMapper); + List 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 void testSearch_SearchScope_AttributesMapper_Name() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); List 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 void testSearch_SearchScope_LimitedAttrs_AttributesMapper_Name() { this.attributesMapper.setExpectedAttributes(CN_SN_ATTRS); this.attributesMapper.setExpectedValues(CN_SN_VALUES); this.attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES); - List list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_NAME) - .searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING)) - .toList(this.attributesMapper); + List 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 void testSearch_ContextMapper() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForObject() { 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 void testSearchForObjectNoHits() { public void testSearch_SearchScope_ContextMapper() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.search().query( - LdapQueryBuilder.query().base(BASE_STRING).searchScope(SearchScope.SUBTREE).filter(FILTER_STRING)) - .toList(this.contextMapper); + List 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 void testSearch_SearchScope_LimitedAttrs_ContextMapper() { this.contextMapper.setExpectedAttributes(CN_SN_ATTRS); this.contextMapper.setExpectedValues(CN_SN_VALUES); this.contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES); - List list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_STRING) - .searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING)) - .toList(this.contextMapper); + List 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 void testSearch_ContextMapper_Name() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearch_ContextMapper_Name() { public void testSearch_ContextMapper_LdapQuery() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.search().query( - LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2")) - .toList(this.contextMapper); + List 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 void testSearch_ContextMapper_LdapQuery() { public void testSearchForStream_ContextMapper_LdapQuery() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearch_ContextMapper_LdapQuery_NoBase() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForStream_ContextMapper_LdapQuery_NoBase() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForStream_ContextMapper_LdapQuery_NoBase() { public void testSearch_ContextMapper_LdapQuery_SearchScope() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearchForStream_ContextMapper_LdapQuery_SearchScope() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForStream_ContextMapper_LdapQuery_SearchScope() { public void testSearch_ContextMapper_LdapQuery_SearchScope_CorrectBase() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearchForStream_ContextMapper_LdapQuery_SearchScope_CorrectBase( this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForStream_ContextMapper_LdapQuery_SearchScope_CorrectBase( public void testSearchForContext_LdapQuery() { ContextMapper 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 void testSearchForContext_LdapQuery_SearchScopeNotFound() { public void testSearchForContext_LdapQuery_SearchScope_CorrectBase() { ContextMapper 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 void testSearch_SearchScope_ContextMapper_Name() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearch_SearchScope_LimitedAttrs_ContextMapper_Name() { this.contextMapper.setExpectedAttributes(CN_SN_ATTRS); this.contextMapper.setExpectedValues(CN_SN_VALUES); this.contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES); - List list = this.tested.search().query(LdapQueryBuilder.query().base(BASE_NAME) - .searchScope(SearchScope.SUBTREE).attributes(CN_SN_ATTRS).filter(FILTER_STRING)) - .toList(this.contextMapper); + List 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 void testSearchWithInvalidSearchBaseCanBeConfiguredToSwallowException() { this.contextMapper.setExpectedValues(CN_SN_VALUES); this.contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES); List 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 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 void verifyThatSearchWithCountLimitReturnsTheEntriesFoundSoFar() { @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); } } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateAuthenticationITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateAuthenticationITests.java index 7ea12c3fd..efde93ab5 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateAuthenticationITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateAuthenticationITests.java @@ -134,9 +134,11 @@ public void testAuthenticateWithInvalidPasswordAndCollectedException() { 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 void testAuthenticateWithInvalidPasswordAndCollectedException() { 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(); } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateLookupMultiRdnITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateLookupMultiRdnITests.java index 42c9554f4..4801c65db 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateLookupMultiRdnITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateLookupMultiRdnITests.java @@ -69,7 +69,7 @@ public void testLookup_MultiValuedRdn() { @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 void testLookup_MultiValuedRdn_DirContextAdapter() { @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); diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateNoBaseSuffixITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateNoBaseSuffixITests.java index 51eb20a9e..3ef778cd7 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateNoBaseSuffixITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateNoBaseSuffixITests.java @@ -87,7 +87,7 @@ public void testBindAndUnbind_Plain() { 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"); diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultITests.java index 7f7dcd551..61cd253fd 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultITests.java @@ -121,7 +121,8 @@ public void testSearchForStream_LdapQuery_AttributesMapper() { List 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 void testSearch_LdapQuery_AttributesMapper_FewerAttributes() { this.attributesMapper.setExpectedAttributes(new String[] { "cn" }); this.attributesMapper.setExpectedValues(new String[] { "Some Person2" }); - List list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn") - .where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper); + List 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 void testSearchForStream_LdapQuery_AttributesMapper_FewerAttributes() { this.attributesMapper.setExpectedAttributes(new String[] { "cn" }); this.attributesMapper.setExpectedValues(new String[] { "Some Person2" }); - List 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 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 void testSearch_LdapQuery_AttributesMapper_SearchScope() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING) - .searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"), - this.attributesMapper); + List 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 void testSearchForStream_LdapQuery_AttributesMapper_SearchScope() { this.attributesMapper.setExpectedValues(ALL_VALUES); List 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 void testSearch_LdapQuery_AttributesMapper_SearchScope_CorrectBase() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearchForStream_LdapQuery_AttributesMapper_SearchScope_CorrectBa this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearchForStream_LdapQuery_AttributesMapper_NoBase() { this.attributesMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForStream_LdapQuery_AttributesMapper_DifferentBase() { List 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 void testSearch_ContextMapper_LdapQuery() { public void testSearchForStream_ContextMapper_LdapQuery() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.searchForStream( - LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"), - this.contextMapper).collect(Collectors.toList()); + List 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 void testSearchForStream_ContextMapper_LdapQuery_NoBase() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForStream_ContextMapper_LdapQuery_NoBase() { public void testSearch_ContextMapper_LdapQuery_SearchScope() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.search(LdapQueryBuilder.query().base(BASE_NAME) - .searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"), - this.contextMapper); + List 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 void testSearchForStream_ContextMapper_LdapQuery_SearchScope() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForStream_ContextMapper_LdapQuery_SearchScope() { public void testSearch_ContextMapper_LdapQuery_SearchScope_CorrectBase() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearchForStream_ContextMapper_LdapQuery_SearchScope_CorrectBase( this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForContext_LdapQuery() { @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"); diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultNamespaceConfigITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultNamespaceConfigITests.java index aef2a5ce1..027965696 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultNamespaceConfigITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/LdapTemplateSearchResultNamespaceConfigITests.java @@ -118,7 +118,8 @@ public void testSearchForStream_LdapQuery_AttributesMapper() { List 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 void testSearch_LdapQuery_AttributesMapper_FewerAttributes() { this.attributesMapper.setExpectedAttributes(new String[] { "cn" }); this.attributesMapper.setExpectedValues(new String[] { "Some Person2" }); - List list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING).attributes("cn") - .where("objectclass").is("person").and("sn").is("Person2"), this.attributesMapper); + List 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 void testSearchForStream_LdapQuery_AttributesMapper_FewerAttributes() { this.attributesMapper.setExpectedAttributes(new String[] { "cn" }); this.attributesMapper.setExpectedValues(new String[] { "Some Person2" }); - List 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 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 void testSearch_LdapQuery_AttributesMapper_SearchScope() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.search(LdapQueryBuilder.query().base(BASE_STRING) - .searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"), - this.attributesMapper); + List 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 void testSearchForStream_LdapQuery_AttributesMapper_SearchScope() { this.attributesMapper.setExpectedValues(ALL_VALUES); List 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 void testSearch_LdapQuery_AttributesMapper_SearchScope_CorrectBase() { this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearchForStream_LdapQuery_AttributesMapper_SearchScope_CorrectBa this.attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.attributesMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearchForStream_LdapQuery_AttributesMapper_NoBase() { this.attributesMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForStream_LdapQuery_AttributesMapper_DifferentBase() { List 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 void testSearch_ContextMapper_LdapQuery() { public void testSearchForStream_ContextMapper_LdapQuery() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.searchForStream( - LdapQueryBuilder.query().base(BASE_NAME).where("objectclass").is("person").and("sn").is("Person2"), - this.contextMapper).collect(Collectors.toList()); + List 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 void testSearchForStream_ContextMapper_LdapQuery_NoBase() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForStream_ContextMapper_LdapQuery_NoBase() { public void testSearch_ContextMapper_LdapQuery_SearchScope() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); - List list = this.tested.search(LdapQueryBuilder.query().base(BASE_NAME) - .searchScope(SearchScope.ONELEVEL).where("objectclass").is("person").and("sn").is("Person2"), - this.contextMapper); + List 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 void testSearchForStream_ContextMapper_LdapQuery_SearchScope() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForStream_ContextMapper_LdapQuery_SearchScope() { public void testSearch_ContextMapper_LdapQuery_SearchScope_CorrectBase() { this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); - List 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 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 void testSearchForStream_ContextMapper_LdapQuery_SearchScope_CorrectBase( this.contextMapper.setExpectedAttributes(ALL_ATTRIBUTES); this.contextMapper.setExpectedValues(ALL_VALUES); List 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 void testSearchForContext_LdapQuery() { @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"); diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/control/SupportedControlsITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/control/SupportedControlsITests.java index 66655371f..080a946b6 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/control/SupportedControlsITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/control/SupportedControlsITests.java @@ -75,7 +75,7 @@ public Object mapFromContext(Object ctx) { HashSet controlsSet = new HashSet(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(); } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/core/simple/SimpleLdapTemplateITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/core/simple/SimpleLdapTemplateITests.java index b9cc00624..aa4a3c061 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/core/simple/SimpleLdapTemplateITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/core/simple/SimpleLdapTemplateITests.java @@ -142,7 +142,7 @@ public Object mapFromContext(Object ctx) { @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"); diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTests.java index 623038475..83b8561d1 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerIntegrationTests.java @@ -55,7 +55,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTests extends AbstractLdapTemplateIntegrationTests { private static Logger log = LoggerFactory - .getLogger(ContextSourceAndDataSourceTransactionManagerIntegrationTests.class); + .getLogger(ContextSourceAndDataSourceTransactionManagerIntegrationTests.class); @Autowired @Qualifier("dummyDao") @@ -75,7 +75,7 @@ public void prepareTestedInstance() throws Exception { 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" }); } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.java index 4aca49ad1..ba76a9146 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.java @@ -47,7 +47,7 @@ public class ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests extends AbstractJUnit4SpringContextTests { private static Logger log = LoggerFactory - .getLogger(ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.class); + .getLogger(ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTests.class); @Autowired @Qualifier("dummyDao") diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerNamespaceITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerNamespaceITests.java index 58ff82707..e83cedbaf 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerNamespaceITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/ContextSourceAndDataSourceTransactionManagerNamespaceITests.java @@ -56,7 +56,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITests extends AbstractLdapTemplateIntegrationTests { private static Logger log = LoggerFactory - .getLogger(ContextSourceAndDataSourceTransactionManagerNamespaceITests.class); + .getLogger(ContextSourceAndDataSourceTransactionManagerNamespaceITests.class); @Autowired @Qualifier("dummyDao") @@ -76,7 +76,7 @@ public void prepareTestedInstance() throws Exception { 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" }); } diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTests.java index b6ef21aad..bb844578b 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerIntegrationTests.java @@ -57,7 +57,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTests extends AbstractLdapTemplateIntegrationTests { private static Logger log = LoggerFactory - .getLogger(ContextSourceAndHibernateTransactionManagerIntegrationTests.class); + .getLogger(ContextSourceAndHibernateTransactionManagerIntegrationTests.class); @Autowired @Qualifier("dummyDao") diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.java index 87ffa84bb..0f73056b8 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.java @@ -44,7 +44,7 @@ public class ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests extends AbstractJUnit4SpringContextTests { private static Logger log = LoggerFactory - .getLogger(ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.class); + .getLogger(ContextSourceAndHibernateTransactionManagerLdap179IntegrationTests.class); @Autowired @Qualifier("dummyDao") diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITests.java index 1e841ddc2..97f4bf254 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/manager/hibernate/ContextSourceAndHibernateTransactionManagerNamespaceITests.java @@ -58,7 +58,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITests extends AbstractLdapTemplateIntegrationTests { private static Logger log = LoggerFactory - .getLogger(ContextSourceAndHibernateTransactionManagerNamespaceITests.class); + .getLogger(ContextSourceAndHibernateTransactionManagerNamespaceITests.class); @Autowired @Qualifier("dummyDao") diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithDnAnnotationsITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithDnAnnotationsITests.java index 70524bb55..b64abe4ce 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithDnAnnotationsITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithDnAnnotationsITests.java @@ -60,8 +60,8 @@ public void testFindOne() { @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 void testFindByDn() { @Test public void testFindInCountry() { - List persons = this.tested.find( - LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(), PersonWithDnAnnotations.class); + List persons = this.tested + .find(LdapQueryBuilder.query().base("ou=Sweden").where("cn").isPresent(), PersonWithDnAnnotations.class); assertThat(persons).hasSize(4); @@ -93,9 +93,9 @@ public void testFindInCountry() { @Test public void testFindForStreamInCountry() { List 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); diff --git a/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithNoDnAnnotationsITests.java b/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithNoDnAnnotationsITests.java index 6a603dbf5..24e05e12f 100644 --- a/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithNoDnAnnotationsITests.java +++ b/test/integration-tests/src/test/java/org/springframework/ldap/itest/odm/LdapTemplateOdmWithNoDnAnnotationsITests.java @@ -97,8 +97,8 @@ public void testFind() { @Test public void testFindForStream() { List 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 void testFindInCountry() { @Test public void testFindForStreamInCountry() { List 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);