Add JavaFormat format Gradle Task

Closes gh-744
This commit is contained in:
Josh Cummings
2023-03-21 16:35:18 -06:00
parent de86a00e8c
commit 08b209fe5c
489 changed files with 10179 additions and 10085 deletions

View File

@@ -23,8 +23,10 @@ import javax.net.ssl.SSLSession;
* @author Mattias Hellborg Arthursson
*/
public class AllMatchHostnameVerifier implements HostnameVerifier {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
}

View File

@@ -24,20 +24,23 @@ import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.ldap.test.ContextSourceEc2InstanceLaunchingFactoryBean;
/**
* FactoryBean for testing LDAP TLS connections on an Amazon EC2 image launched by superclass.
* FactoryBean for testing LDAP TLS connections on an Amazon EC2 image launched by
* superclass.
*/
public class DigestMd5ContextSourceEc2InstanceLaunchingFactoryBean extends ContextSourceEc2InstanceLaunchingFactoryBean {
public class DigestMd5ContextSourceEc2InstanceLaunchingFactoryBean
extends ContextSourceEc2InstanceLaunchingFactoryBean {
protected void setAdditionalContextSourceProperties(LdapContextSource ctx, final String dnsName) {
DigestMd5DirContextAuthenticationStrategy authenticationStrategy = new DigestMd5DirContextAuthenticationStrategy();
// authenticationStrategy.setHostnameVerifier(new HostnameVerifier() {
// public boolean verify(String hostname, SSLSession session) {
// return hostname.equals(dnsName);
// }
// });
// authenticationStrategy.setHostnameVerifier(new HostnameVerifier() {
// public boolean verify(String hostname, SSLSession session) {
// return hostname.equals(dnsName);
// }
// });
ctx.setAuthenticationStrategy(authenticationStrategy);
ctx.setPooled(false);
}
}

View File

@@ -23,13 +23,14 @@ import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.ldap.test.ContextSourceEc2InstanceLaunchingFactoryBean;
/**
* FactoryBean for testing LDAP TLS connections on an Amazon EC2 image launched by superclass.
* FactoryBean for testing LDAP TLS connections on an Amazon EC2 image launched by
* superclass.
*/
public class TlsContextSourceEc2InstanceLaunchingFactoryBean extends ContextSourceEc2InstanceLaunchingFactoryBean {
protected void setAdditionalContextSourceProperties(LdapContextSource ctx, final String dnsName) {
DefaultTlsDirContextAuthenticationStrategy authenticationStrategy = new DefaultTlsDirContextAuthenticationStrategy();
authenticationStrategy.setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return hostname.equals(dnsName);
@@ -39,4 +40,5 @@ public class TlsContextSourceEc2InstanceLaunchingFactoryBean extends ContextSour
ctx.setAuthenticationStrategy(authenticationStrategy);
ctx.setPooled(false);
}
}

View File

@@ -22,83 +22,82 @@ import org.apache.commons.lang.builder.ToStringStyle;
/**
* Simple class representing a single person.
*
*
* @author Mattias Hellborg Arthursson
* @author Ulrik Sandberg
*/
public class Person {
private String fullName;
private String lastName;
private String fullName;
private String description;
private String lastName;
private String country;
private String description;
private String company;
private String country;
private String phone;
private String company;
public String getDescription() {
return description;
}
private String phone;
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
public String getFullName() {
return fullName;
}
public void setDescription(String description) {
this.description = description;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getFullName() {
return fullName;
}
public String getLastName() {
return lastName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getLastName() {
return lastName;
}
public String getCompany() {
return company;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setCompany(String company) {
this.company = company;
}
public String getCompany() {
return company;
}
public String getCountry() {
return country;
}
public void setCompany(String company) {
this.company = company;
}
public void setCountry(String country) {
this.country = country;
}
public String getCountry() {
return country;
}
public String getPhone() {
return phone;
}
public void setCountry(String country) {
this.country = country;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getPhone() {
return phone;
}
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(
this, obj);
}
public void setPhone(String phone) {
this.phone = phone;
}
public int hashCode() {
return HashCodeBuilder
.reflectionHashCode(this);
}
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
public String toString() {
return ToStringBuilder.reflectionToString(
this, ToStringStyle.MULTI_LINE_STYLE);
}
}

View File

@@ -58,9 +58,7 @@ public class PagedSearchITest extends AbstractJUnit4SpringContextTests {
@Before
public void prepareTestedData() throws IOException, NamingException {
LdapTestUtils.cleanAndSetup(
contextSource,
LdapUtils.newLdapName("ou=People"),
LdapTestUtils.cleanAndSetup(contextSource, LdapUtils.newLdapName("ou=People"),
new ClassPathResource("/setup_data.ldif"));
}
@@ -74,41 +72,25 @@ public class PagedSearchITest extends AbstractJUnit4SpringContextTests {
final SearchControls searchControls = new SearchControls();
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
// There should be three pages of three entries, and one final page with one entry
// There should be three pages of three entries, and one final page with one entry
final PagedResultsDirContextProcessor processor = new PagedResultsDirContextProcessor(3);
SingleContextSource.doWithSingleContext(contextSource, new LdapOperationsCallback<Object>() {
@Override
public Object doWithLdapOperations(LdapOperations operations) {
List<String> result = operations.search(
"ou=People",
"(&(objectclass=person))",
searchControls,
CN_ATTRIBUTES_MAPPER,
List<String> result = operations.search("ou=People", "(&(objectclass=person))", searchControls,
CN_ATTRIBUTES_MAPPER, processor);
assertThat(result).hasSize(3);
result = operations.search("ou=People", "(&(objectclass=person))", searchControls, CN_ATTRIBUTES_MAPPER,
processor);
assertThat(result).hasSize(3);
result = operations.search(
"ou=People",
"(&(objectclass=person))",
searchControls,
CN_ATTRIBUTES_MAPPER,
result = operations.search("ou=People", "(&(objectclass=person))", searchControls, CN_ATTRIBUTES_MAPPER,
processor);
assertThat(result).hasSize(3);
result = operations.search(
"ou=People",
"(&(objectclass=person))",
searchControls,
CN_ATTRIBUTES_MAPPER,
processor);
assertThat(result).hasSize(3);
result = operations.search(
"ou=People",
"(&(objectclass=person))",
searchControls,
CN_ATTRIBUTES_MAPPER,
result = operations.search("ou=People", "(&(objectclass=person))", searchControls, CN_ATTRIBUTES_MAPPER,
processor);
assertThat(result).hasSize(1);
@@ -118,4 +100,5 @@ public class PagedSearchITest extends AbstractJUnit4SpringContextTests {
});
}
}

View File

@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* Verifies that LdapTemplate search methods work against OpenLDAP with TLS.
*
*
* @author Mattias Hellborg Arthursson
*/
@ContextConfiguration(locations = { "/conf/ldapTemplateTestContext-tls.xml" })
@@ -74,9 +74,7 @@ public class LdapTemplateSearchResultITest extends AbstractJUnit4SpringContextTe
@Before
public void prepareTestedInstance() throws Exception {
LdapTestUtils.cleanAndSetup(
contextSource,
LdapUtils.newLdapName("ou=People"),
LdapTestUtils.cleanAndSetup(contextSource, LdapUtils.newLdapName("ou=People"),
new ClassPathResource("/setup_data.ldif"));
attributesMapper = new AttributeCheckAttributesMapper();
@@ -137,8 +135,8 @@ public class LdapTemplateSearchResultITest extends AbstractJUnit4SpringContextTe
attributesMapper.setExpectedAttributes(CN_SN_ATTRS);
attributesMapper.setExpectedValues(CN_SN_VALUES);
attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
List<Object> list = tested
.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, attributesMapper);
List<Object> list = tested.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS,
attributesMapper);
assertThat(list).hasSize(1);
}
@@ -154,7 +152,8 @@ public class LdapTemplateSearchResultITest extends AbstractJUnit4SpringContextTe
public void testSearch_SearchScope_ContextMapper() {
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE, contextMapper);
List<DirContextAdapter> list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE,
contextMapper);
assertThat(list).hasSize(1);
}
@@ -163,7 +162,8 @@ public class LdapTemplateSearchResultITest extends AbstractJUnit4SpringContextTe
contextMapper.setExpectedAttributes(CN_SN_ATTRS);
contextMapper.setExpectedValues(CN_SN_VALUES);
contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
List<DirContextAdapter> list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, contextMapper);
List<DirContextAdapter> list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE,
CN_SN_ATTRS, contextMapper);
assertThat(list).hasSize(1);
}
@@ -179,7 +179,8 @@ public class LdapTemplateSearchResultITest extends AbstractJUnit4SpringContextTe
public void testSearch_SearchScope_ContextMapper_Name() {
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
contextMapper.setExpectedValues(ALL_VALUES);
List<DirContextAdapter> list = tested.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, contextMapper);
List<DirContextAdapter> list = tested.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE,
contextMapper);
assertThat(list).hasSize(1);
}
@@ -188,7 +189,9 @@ public class LdapTemplateSearchResultITest extends AbstractJUnit4SpringContextTe
contextMapper.setExpectedAttributes(CN_SN_ATTRS);
contextMapper.setExpectedValues(CN_SN_VALUES);
contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
List<DirContextAdapter> list = tested.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, contextMapper);
List<DirContextAdapter> list = tested.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE,
CN_SN_ATTRS, contextMapper);
assertThat(list).hasSize(1);
}
}

View File

@@ -34,11 +34,12 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration test to verify DIGEST-MD5 authentication support.
*
*
* @author Marvin S. Addison
*/
@ContextConfiguration(locations = { "/conf/ldapTemplateDigestMd5TestContext.xml" })
public class DigestMd5AuthenticationITest extends AbstractJUnit4SpringContextTests {
@Autowired
private LdapTemplate ldapTemplate;
@@ -48,9 +49,7 @@ public class DigestMd5AuthenticationITest extends AbstractJUnit4SpringContextTes
@Before
public void prepareTestedInstance() throws Exception {
LdapTestUtils.cleanAndSetup(
contextSource,
LdapUtils.newLdapName("ou=People"),
LdapTestUtils.cleanAndSetup(contextSource, LdapUtils.newLdapName("ou=People"),
new ClassPathResource("/setup_data.ldif"));
}
@@ -64,4 +63,5 @@ public class DigestMd5AuthenticationITest extends AbstractJUnit4SpringContextTes
DirContext ctxt = ldapTemplate.getContextSource().getContext("some.person1", "password");
assertThat(ctxt).isNotNull();
}
}