Move test to assertj (#401)
This commit is contained in:
committed by
Rob Winch
parent
2a7e3eba0e
commit
64208a34ed
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,7 +33,7 @@ import javax.naming.ldap.LdapName;
|
||||
import javax.naming.ldap.Rdn;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for verifying that issues LDAP-50 and LDAP-109 are solved.
|
||||
@@ -99,12 +99,12 @@ public class InvalidBackslashITest extends AbstractLdapTemplateIntegrationTest {
|
||||
protected Object doMapFromContext(DirContextOperations ctx) {
|
||||
LdapName dn = (LdapName) ctx.getDn();
|
||||
Rdn rdn = LdapUtils.getRdn(dn, "cn");
|
||||
assertEquals("cn=Some\\\\Person6,ou=company1,ou=Sweden", dn.toString());
|
||||
assertEquals("Some\\Person6", rdn.getValue());
|
||||
assertThat(dn.toString()).isEqualTo("cn=Some\\\\Person6,ou=company1,ou=Sweden");
|
||||
assertThat(rdn.getValue()).isEqualTo("Some\\Person6");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(1, result.size());
|
||||
assertThat(result).hasSize(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,7 @@ import javax.naming.directory.Attributes;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests the attributes mapper search method.
|
||||
@@ -45,11 +45,11 @@ public class LdapTemplateAttributesMapperITest extends AbstractLdapTemplateInteg
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
List result = tested.search("ou=company1,ou=Sweden", "(&(objectclass=person)(sn=Person2))", mapper);
|
||||
|
||||
assertEquals(1, result.size());
|
||||
assertThat(result).hasSize(1);
|
||||
Person person = (Person) result.get(0);
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person2", person.getDescription());
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).isEqualTo("Person2");
|
||||
assertThat(person.getDescription()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,8 +73,8 @@ public class LdapTemplateAttributesMapperITest extends AbstractLdapTemplateInteg
|
||||
};
|
||||
List result = tested.search("ou=groups", "(&(objectclass=groupOfUniqueNames)(cn=ROLE_USER))", mapper);
|
||||
|
||||
assertEquals(1, result.size());
|
||||
assertThat(result).hasSize(1);
|
||||
|
||||
assertEquals(4, ((String[]) result.get(0)).length);
|
||||
assertThat(((String[]) result.get(0)).length).isEqualTo(4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.ldap.itest;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -36,10 +35,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.DirContext;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
|
||||
/**
|
||||
@@ -59,7 +55,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
public void testAuthenticate() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
assertTrue(tested.authenticate("", filter.toString(), "password"));
|
||||
assertThat(tested.authenticate("", filter.toString(), "password")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +74,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
public void testAuthenticateWithInvalidPassword() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
assertFalse(tested.authenticate("", filter.toString(), "invalidpassword"));
|
||||
assertThat(tested.authenticate("", filter.toString(), "invalidpassword")).isFalse();
|
||||
}
|
||||
|
||||
@Test(expected = AuthenticationException.class)
|
||||
@@ -101,14 +97,14 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
public void executeWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) {
|
||||
try {
|
||||
DirContextAdapter adapter = (DirContextAdapter) ctx.lookup(ldapEntryIdentification.getRelativeDn());
|
||||
assertEquals("Some Person3", adapter.getStringAttribute("cn"));
|
||||
assertThat(adapter.getStringAttribute("cn")).isEqualTo("Some Person3");
|
||||
}
|
||||
catch (NamingException e) {
|
||||
throw new RuntimeException("Failed to lookup " + ldapEntryIdentification.getRelativeDn(), e);
|
||||
}
|
||||
}
|
||||
};
|
||||
assertTrue(tested.authenticate("", filter.toString(), "password", contextCallback));
|
||||
assertThat(tested.authenticate("", filter.toString(), "password", contextCallback)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,8 +116,8 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
"password",
|
||||
new LookupAttemptingCallback());
|
||||
|
||||
Assert.assertNotNull(ctx);
|
||||
assertEquals("some.person3", ctx.getStringAttribute("uid"));
|
||||
assertThat(ctx).isNotNull();
|
||||
assertThat(ctx.getStringAttribute("uid")).isEqualTo("some.person3");
|
||||
}
|
||||
|
||||
@Test(expected = AuthenticationException.class)
|
||||
@@ -140,11 +136,11 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
final CollectingAuthenticationErrorCallback errorCallback = new CollectingAuthenticationErrorCallback();
|
||||
assertFalse(tested.authenticate("", filter.toString(), "invalidpassword", errorCallback));
|
||||
assertThat(tested.authenticate("", filter.toString(), "invalidpassword", errorCallback)).isFalse();
|
||||
final Exception error = errorCallback.getError();
|
||||
assertNotNull("collected error should not be null", error);
|
||||
assertTrue("expected org.springframework.ldap.AuthenticationException", error instanceof AuthenticationException);
|
||||
assertTrue("expected javax.naming.AuthenticationException", error.getCause() instanceof javax.naming.AuthenticationException);
|
||||
assertThat(error).as("collected error should not be null").isNotNull();
|
||||
assertThat(error instanceof AuthenticationException).as("expected org.springframework.ldap.AuthenticationException").isTrue();
|
||||
assertThat(error.getCause() instanceof javax.naming.AuthenticationException).as("expected javax.naming.AuthenticationException").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -153,7 +149,7 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(
|
||||
new EqualsFilter("uid", "some.person.that.isnt.there"));
|
||||
assertFalse(tested.authenticate("", filter.toString(), "password"));
|
||||
assertThat(tested.authenticate("", filter.toString(), "password")).isFalse();
|
||||
}
|
||||
|
||||
@Test(expected=IncorrectResultSizeDataAccessException.class)
|
||||
@@ -170,6 +166,6 @@ public class LdapTemplateAuthenticationITest extends AbstractLdapTemplateIntegra
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
LookupAttemptingCallback callback = new LookupAttemptingCallback();
|
||||
assertTrue(tested.authenticate("", filter.encode(), "password", callback));
|
||||
assertThat(tested.authenticate("", filter.encode(), "password", callback)).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,9 +28,8 @@ import javax.naming.directory.Attributes;
|
||||
import javax.naming.directory.BasicAttribute;
|
||||
import javax.naming.directory.BasicAttributes;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Tests the bind and unbind methods of LdapTemplate. The test methods in this
|
||||
@@ -149,14 +148,14 @@ public class LdapTemplateBindUnbindITest extends
|
||||
|
||||
private void verifyBoundCorrectData() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(DN);
|
||||
assertEquals("Some Person4", result.getStringAttribute("cn"));
|
||||
assertEquals("Person4", result.getStringAttribute("sn"));
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person4");
|
||||
}
|
||||
|
||||
private void verifyReboundCorrectData() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(DN);
|
||||
assertEquals("Some Person4", result.getStringAttribute("cn"));
|
||||
assertEquals("Person4.Changed", result.getStringAttribute("sn"));
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person4.Changed");
|
||||
}
|
||||
|
||||
private void verifyCleanup() {
|
||||
@@ -165,7 +164,7 @@ public class LdapTemplateBindUnbindITest extends
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.ldap.itest;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.DirContext;
|
||||
|
||||
@@ -27,6 +25,8 @@ import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for LdapTemplate's context executor methods.
|
||||
*
|
||||
@@ -47,6 +47,6 @@ public class LdapTemplateContextExecutorTest extends AbstractLdapTemplateIntegra
|
||||
};
|
||||
|
||||
Object object = tested.executeReadOnly(executor);
|
||||
assertTrue("Should be a DirContextAdapter", object instanceof DirContextAdapter);
|
||||
assertThat(object instanceof DirContextAdapter).as("Should be a DirContextAdapter").isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests the ContextMapper search method. In its way this method also
|
||||
@@ -48,11 +48,11 @@ public class LdapTemplateContextMapperITest extends AbstractLdapTemplateIntegrat
|
||||
ContextMapper mapper = new PersonContextMapper();
|
||||
List result = tested.search("ou=company1,ou=Sweden", "(&(objectclass=person)(sn=Person2))", mapper);
|
||||
|
||||
assertEquals(1, result.size());
|
||||
assertThat(result).hasSize(1);
|
||||
Person person = (Person) result.get(0);
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person2", person.getDescription());
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).isEqualTo("Person2");
|
||||
assertThat(person.getDescription()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ public class LdapTemplateContextMapperITest extends AbstractLdapTemplateIntegrat
|
||||
};
|
||||
List result = tested.search("ou=groups", "(&(objectclass=groupOfUniqueNames)(cn=ROLE_USER))", mapper);
|
||||
|
||||
assertEquals(1, result.size());
|
||||
assertEquals(4, ((String[]) result.get(0)).length);
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(((String[]) result.get(0)).length).isEqualTo(4);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,8 +29,7 @@ import javax.naming.ldap.LdapName;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for LdapTemplate's list methods.
|
||||
@@ -69,7 +68,7 @@ public class LdapTemplateListITest extends AbstractLdapTemplateIntegrationTest {
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.listBindings("ou=company2,ou=Sweden" + BASE_STRING, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,24 +77,24 @@ public class LdapTemplateListITest extends AbstractLdapTemplateIntegrationTest {
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
LdapName dn = LdapUtils.newLdapName("ou=company2,ou=Sweden");
|
||||
List list = tested.listBindings(dn, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListBindings_ContextMapper_MapToPersons() {
|
||||
LdapName dn = LdapUtils.newLdapName("ou=company1,ou=Sweden");
|
||||
List list = tested.listBindings(dn, new PersonContextMapper());
|
||||
assertEquals(3, list.size());
|
||||
assertThat(list).hasSize(3);
|
||||
String personClass = "org.springframework.ldap.itest.Person";
|
||||
assertEquals(personClass, list.get(0).getClass().getName());
|
||||
assertEquals(personClass, list.get(1).getClass().getName());
|
||||
assertEquals(personClass, list.get(2).getClass().getName());
|
||||
assertThat(list.get(0).getClass().getName()).isEqualTo(personClass);
|
||||
assertThat(list.get(1).getClass().getName()).isEqualTo(personClass);
|
||||
assertThat(list.get(2).getClass().getName()).isEqualTo(personClass);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testList() {
|
||||
List<String> list = tested.list(BASE_STRING);
|
||||
assertEquals(3, list.size());
|
||||
assertThat(list).hasSize(3);
|
||||
verifyBindings(list);
|
||||
}
|
||||
|
||||
@@ -106,15 +105,15 @@ public class LdapTemplateListITest extends AbstractLdapTemplateIntegrationTest {
|
||||
transformed.add(LdapUtils.newLdapName(s));
|
||||
}
|
||||
|
||||
assertTrue(transformed.contains(LdapUtils.newLdapName("ou=groups")));
|
||||
assertTrue(transformed.contains(LdapUtils.newLdapName("ou=Norway")));
|
||||
assertTrue(transformed.contains(LdapUtils.newLdapName("ou=Sweden")));
|
||||
assertThat(transformed.contains(LdapUtils.newLdapName("ou=groups"))).isTrue();
|
||||
assertThat(transformed.contains(LdapUtils.newLdapName("ou=Norway"))).isTrue();
|
||||
assertThat(transformed.contains(LdapUtils.newLdapName("ou=Sweden"))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testList_Name() {
|
||||
List<String> list = tested.list(BASE_NAME);
|
||||
assertEquals(3, list.size());
|
||||
assertThat(list).hasSize(3);
|
||||
verifyBindings(list);
|
||||
}
|
||||
|
||||
@@ -122,40 +121,40 @@ public class LdapTemplateListITest extends AbstractLdapTemplateIntegrationTest {
|
||||
public void testList_Handler() throws Exception {
|
||||
CountNameClassPairCallbackHandler handler = new CountNameClassPairCallbackHandler();
|
||||
tested.list(BASE_STRING, handler);
|
||||
assertEquals(3, handler.getNoOfRows());
|
||||
assertThat(handler.getNoOfRows()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testList_Name_Handler() throws Exception {
|
||||
CountNameClassPairCallbackHandler handler = new CountNameClassPairCallbackHandler();
|
||||
tested.list(BASE_NAME, handler);
|
||||
assertEquals(3, handler.getNoOfRows());
|
||||
assertThat(handler.getNoOfRows()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListBindings() {
|
||||
List<String> list = tested.listBindings(BASE_STRING);
|
||||
assertEquals(3, list.size());
|
||||
assertThat(list).hasSize(3);
|
||||
verifyBindings(list);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListBindings_Name() {
|
||||
List list = tested.listBindings(BASE_NAME);
|
||||
assertEquals(3, list.size());
|
||||
assertThat(list).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListBindings_Handler() throws Exception {
|
||||
CountNameClassPairCallbackHandler handler = new CountNameClassPairCallbackHandler();
|
||||
tested.listBindings(BASE_STRING, handler);
|
||||
assertEquals(3, handler.getNoOfRows());
|
||||
assertThat(handler.getNoOfRows()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListBindings_Name_Handler() throws Exception {
|
||||
CountNameClassPairCallbackHandler handler = new CountNameClassPairCallbackHandler();
|
||||
tested.listBindings(BASE_NAME, handler);
|
||||
assertEquals(3, handler.getNoOfRows());
|
||||
assertThat(handler.getNoOfRows()).isEqualTo(3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,8 +29,7 @@ import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
import javax.naming.ldap.LdapName;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests the lookup methods of LdapTemplate.
|
||||
@@ -53,9 +52,9 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
public void testLookup_Plain() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden");
|
||||
|
||||
assertEquals("Some Person2", result.getStringAttribute("cn"));
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertEquals("Sweden, Company1, Some Person2", result.getStringAttribute("description"));
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person2");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
assertThat(result.getStringAttribute("description")).isEqualTo("Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,8 +66,8 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
public void testLookupContextRoot() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup("");
|
||||
|
||||
assertEquals("", result.getDn().toString());
|
||||
assertEquals(base, result.getNameInNamespace());
|
||||
assertThat(result.getDn().toString()).isEqualTo("");
|
||||
assertThat(result.getNameInNamespace()).isEqualTo(base);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -76,9 +75,9 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden", mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person2", person.getDescription());
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).isEqualTo("Person2");
|
||||
assertThat(person.getDescription()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,9 +85,9 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden"), mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person2", person.getDescription());
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).isEqualTo("Person2");
|
||||
assertThat(person.getDescription()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,8 +107,8 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
Person person = new Person();
|
||||
person.setFullname((String) attributes.get("cn").get());
|
||||
assertNull("sn should be null", attributes.get("sn"));
|
||||
assertNull("description should be null", attributes.get("description"));
|
||||
assertThat(attributes.get("sn")).as("sn should be null").isNull();
|
||||
assertThat(attributes.get("description")).as("description should be null").isNull();
|
||||
return person;
|
||||
}
|
||||
}
|
||||
@@ -124,9 +123,9 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden", new String[] { "cn" }, mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertNull("lastName should not be set", person.getLastname());
|
||||
assertNull("description should not be set", person.getDescription());
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).as("lastName should not be set").isNull();
|
||||
assertThat(person.getDescription()).as("description should not be set").isNull();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,9 +139,9 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
Person person = (Person) tested.lookup(LdapUtils.newLdapName("cn=Some Person2, ou=company1,ou=Sweden"),
|
||||
new String[] { "cn" }, mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertNull("lastName should not be set", person.getLastname());
|
||||
assertNull("description should not be set", person.getDescription());
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).as("lastName should not be set").isNull();
|
||||
assertThat(person.getDescription()).as("description should not be set").isNull();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,9 +154,9 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
ContextMapper mapper = new PersonContextMapper();
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden", mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertEquals("Person2", person.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person2", person.getDescription());
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).isEqualTo("Person2");
|
||||
assertThat(person.getDescription()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,9 +169,9 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
|
||||
Person person = (Person) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden", new String[] { "cn" }, mapper);
|
||||
|
||||
assertEquals("Some Person2", person.getFullname());
|
||||
assertNull("lastName should not be set", person.getLastname());
|
||||
assertNull("description should not be set", person.getDescription());
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person2");
|
||||
assertThat(person.getLastname()).as("lastName should not be set").isNull();
|
||||
assertThat(person.getDescription()).as("description should not be set").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -181,7 +180,7 @@ public class LdapTemplateLookupITest extends AbstractLdapTemplateIntegrationTest
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(expectedDn);
|
||||
|
||||
LdapName expectedName = LdapUtils.newLdapName(expectedDn);
|
||||
assertEquals(expectedName, result.getDn());
|
||||
assertEquals("cn=Some Person2,ou=company1,ou=Sweden," + base, result.getNameInNamespace());
|
||||
assertThat(result.getDn()).isEqualTo(expectedName);
|
||||
assertThat(result.getNameInNamespace()).isEqualTo("cn=Some Person2,ou=company1,ou=Sweden," + base);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests the lookup methods of LdapTemplate.
|
||||
@@ -55,9 +55,9 @@ public class LdapTemplateLookupMultiRdnITest extends AbstractLdapTemplateIntegra
|
||||
AttributesMapper mapper = new PersonAttributesMapper();
|
||||
Person person = (Person) tested.lookup("cn=Some Person+sn=Person, ou=company1,ou=Norway", mapper);
|
||||
|
||||
assertEquals("Some Person", person.getFullname());
|
||||
assertEquals("Person", person.getLastname());
|
||||
assertEquals("Norway, Company1, Some Person+Person", person.getDescription());
|
||||
assertThat(person.getFullname()).isEqualTo("Some Person");
|
||||
assertThat(person.getLastname()).isEqualTo("Person");
|
||||
assertThat(person.getDescription()).isEqualTo("Norway, Company1, Some Person+Person");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,9 +70,9 @@ public class LdapTemplateLookupMultiRdnITest extends AbstractLdapTemplateIntegra
|
||||
public void testLookup_MultiValuedRdn_DirContextAdapter() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup("cn=Some Person+sn=Person, ou=company1,ou=Norway");
|
||||
|
||||
assertEquals("Some Person", result.getStringAttribute("cn"));
|
||||
assertEquals("Person", result.getStringAttribute("sn"));
|
||||
assertEquals("Norway, Company1, Some Person+Person", result.getStringAttribute("description"));
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person");
|
||||
assertThat(result.getStringAttribute("description")).isEqualTo("Norway, Company1, Some Person+Person");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,7 +80,7 @@ public class LdapTemplateLookupMultiRdnITest extends AbstractLdapTemplateIntegra
|
||||
public void testLookup_GetNameInNamespace_MultiRdn() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup("cn=Some Person+sn=Person,ou=company1,ou=Norway");
|
||||
|
||||
assertEquals("cn=Some Person+sn=Person,ou=company1,ou=Norway", result.getDn().toString());
|
||||
assertEquals("cn=Some Person+sn=Person,ou=company1,ou=Norway," + base, result.getNameInNamespace());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,9 +35,8 @@ import javax.naming.directory.ModificationItem;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Tests the modification methods (rebind and modifyAttributes) of LdapTemplate.
|
||||
@@ -117,9 +116,9 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
List<String> attributes = Arrays.asList(result.getStringAttributes("description"));
|
||||
assertEquals(2, attributes.size());
|
||||
assertTrue(attributes.contains("Some other description"));
|
||||
assertTrue(attributes.contains("Another description"));
|
||||
assertThat(attributes).hasSize(2);
|
||||
assertThat(attributes.contains("Some other description")).isTrue();
|
||||
assertThat(attributes.contains("Another description")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,10 +132,10 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
List<String> attributes = Arrays.asList(result.getStringAttributes("description"));
|
||||
assertEquals(3, attributes.size());
|
||||
assertTrue(attributes.contains("Some other description"));
|
||||
assertTrue(attributes.contains("Another description"));
|
||||
assertTrue(attributes.contains("Some description"));
|
||||
assertThat(attributes).hasSize(3);
|
||||
assertThat(attributes.contains("Some other description")).isTrue();
|
||||
assertThat(attributes.contains("Another description")).isTrue();
|
||||
assertThat(attributes.contains("Some description")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -144,7 +143,7 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
DirContextOperations ctx = tested.lookupContext("cn=ROLE_USER,ou=groups");
|
||||
ctx.addAttributeValue("uniqueMember", "cn=Some Person,ou=company1,ou=Norway," + base);
|
||||
tested.modifyAttributes(ctx);
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -180,10 +179,10 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
List<String> attributes = Arrays.asList(result.getStringAttributes("description"));
|
||||
assertEquals(3, attributes.size());
|
||||
assertTrue(attributes.contains("Some other description"));
|
||||
assertTrue(attributes.contains("Another description"));
|
||||
assertTrue(attributes.contains("Some description"));
|
||||
assertThat(attributes).hasSize(3);
|
||||
assertThat(attributes.contains("Some other description")).isTrue();
|
||||
assertThat(attributes.contains("Another description")).isTrue();
|
||||
assertThat(attributes.contains("Some description")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -216,11 +215,11 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
// Verify
|
||||
adapter = (DirContextAdapter) tested.lookup(PERSON5_DN);
|
||||
List<String> attributes = Arrays.asList(adapter.getStringAttributes("description"));
|
||||
assertEquals(4, attributes.size());
|
||||
assertTrue(attributes.contains("qwe"));
|
||||
assertTrue(attributes.contains("123"));
|
||||
assertTrue(attributes.contains("klytt"));
|
||||
assertTrue(attributes.contains("kalle"));
|
||||
assertThat(attributes).hasSize(4);
|
||||
assertThat(attributes.contains("qwe")).isTrue();
|
||||
assertThat(attributes.contains("123")).isTrue();
|
||||
assertThat(attributes.contains("klytt")).isTrue();
|
||||
assertThat(attributes.contains("kalle")).isTrue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,8 +277,8 @@ public class LdapTemplateModifyITest extends AbstractLdapTemplateIntegrationTest
|
||||
|
||||
private void verifyBoundCorrectData() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN);
|
||||
assertEquals("Some Person4", result.getStringAttribute("cn"));
|
||||
assertEquals("Person4", result.getStringAttribute("sn"));
|
||||
assertEquals("Some other description", result.getStringAttribute("description"));
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person4");
|
||||
assertThat(result.getStringAttribute("description")).isEqualTo("Some other description");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,9 +28,8 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.ldap.LdapName;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Tests to verify that not setting a base suffix on the ContextSource (as
|
||||
@@ -60,13 +59,13 @@ public class LdapTemplateNoBaseSuffixITest extends AbstractLdapTemplateIntegrati
|
||||
String expectedDn = "cn=Some Person2, ou=company1, ou=Sweden," + base;
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(expectedDn);
|
||||
|
||||
assertEquals("Some Person2", result.getStringAttribute("cn"));
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertEquals("Sweden, Company1, Some Person2", result.getStringAttribute("description"));
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person2");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
assertThat(result.getStringAttribute("description")).isEqualTo("Sweden, Company1, Some Person2");
|
||||
|
||||
LdapName expectedName = LdapUtils.newLdapName(expectedDn);
|
||||
assertEquals(expectedName, result.getDn());
|
||||
assertEquals(expectedDn, result.getNameInNamespace());
|
||||
assertThat(result.getDn()).isEqualTo(expectedName);
|
||||
assertThat(result.getNameInNamespace()).isEqualTo(expectedDn);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -74,7 +73,7 @@ public class LdapTemplateNoBaseSuffixITest extends AbstractLdapTemplateIntegrati
|
||||
CountNameClassPairCallbackHandler handler = new CountNameClassPairCallbackHandler();
|
||||
|
||||
tested.search(base, "(objectclass=person)", handler);
|
||||
assertEquals(5, handler.getNoOfRows());
|
||||
assertThat(handler.getNoOfRows()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,9 +87,9 @@ public class LdapTemplateNoBaseSuffixITest extends AbstractLdapTemplateIntegrati
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.lookup("cn=Some Person4, ou=company1, ou=Sweden," + base);
|
||||
|
||||
assertEquals("Some Person4", result.getStringAttribute("cn"));
|
||||
assertEquals("Person4", result.getStringAttribute("sn"));
|
||||
assertEquals(LdapUtils.newLdapName("cn=Some Person4,ou=company1,ou=Sweden," + base), result.getDn());
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person4");
|
||||
assertThat(result.getDn()).isEqualTo(LdapUtils.newLdapName("cn=Some Person4,ou=company1,ou=Sweden," + base));
|
||||
|
||||
tested.unbind("cn=Some Person4,ou=company1,ou=Sweden," + base);
|
||||
try {
|
||||
@@ -98,7 +97,7 @@ public class LdapTemplateNoBaseSuffixITest extends AbstractLdapTemplateIntegrati
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,9 +29,8 @@ import org.springframework.ldap.test.LdapTestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* This test only works against in-process Apache DS server, regardless of configured profile.
|
||||
@@ -64,9 +63,9 @@ public class LdapTemplatePooledITest extends AbstractJUnit4SpringContextTests {
|
||||
LdapTestUtils.cleanAndSetup(contextSource, LdapUtils.emptyLdapName(), new ClassPathResource("/setup_data.ldif"));
|
||||
|
||||
DirContextOperations result = tested.lookupContext("cn=Some Person2, ou=company1,ou=Sweden");
|
||||
assertEquals("Some Person2", result.getStringAttribute("cn"));
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertEquals("Sweden, Company1, Some Person2", result.getStringAttribute("description"));
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person2");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
assertThat(result.getStringAttribute("description")).isEqualTo("Sweden, Company1, Some Person2");
|
||||
|
||||
// Shutdown server and kill all existing connections
|
||||
LdapTestUtils.shutdownEmbeddedServer();
|
||||
@@ -77,7 +76,7 @@ public class LdapTemplatePooledITest extends AbstractJUnit4SpringContextTests {
|
||||
fail("Exception expected");
|
||||
} catch (Exception expected) {
|
||||
// This should fail because the target connection was closed
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
LdapTestUtils.cleanAndSetup(contextSource, LdapUtils.emptyLdapName(), new ClassPathResource("/setup_data.ldif"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,8 +28,8 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import javax.naming.Name;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Tests the rename methods of LdapTemplate.
|
||||
@@ -96,8 +96,8 @@ public class LdapTemplateRenameITest extends AbstractLdapTemplateIntegrationTest
|
||||
|
||||
private void verifyBoundCorrectData() {
|
||||
DirContextAdapter result = (DirContextAdapter) tested.lookup(NEWDN);
|
||||
assertEquals("Some Person6", result.getStringAttribute("cn"));
|
||||
assertEquals("Person6", result.getStringAttribute("sn"));
|
||||
assertEquals("Some description", result.getStringAttribute("description"));
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person6");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person6");
|
||||
assertThat(result.getStringAttribute("description")).isEqualTo("Some description");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,10 +41,8 @@ import javax.naming.NamingException;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
|
||||
/**
|
||||
@@ -99,7 +97,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -111,7 +109,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
.base(BASE_STRING)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,7 +122,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
.attributes("cn")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -137,7 +135,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(0, list.size());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -150,7 +148,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,7 +159,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
List<Object> list = tested.search(query()
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -173,7 +171,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
.base("ou=Norway")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(0, list.size());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -181,7 +179,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -191,7 +189,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS,
|
||||
attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -199,7 +197,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -207,7 +205,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -217,7 +215,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested
|
||||
.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -225,7 +223,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -234,7 +232,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.searchForObject(BASE_STRING, FILTER_STRING, contextMapper);
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test(expected = IncorrectResultSizeDataAccessException.class)
|
||||
@@ -262,7 +260,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -271,7 +269,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
contextMapper.setExpectedValues(CN_SN_VALUES);
|
||||
contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -279,7 +277,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -290,7 +288,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
.base(BASE_NAME)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -300,7 +298,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
List<DirContextAdapter> list = tested.search(query()
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -312,7 +310,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper);
|
||||
assertEquals(0, list.size());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -324,7 +322,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -332,8 +330,8 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
DirContextOperations result = tested.searchForContext(query()
|
||||
.where("objectclass").is("person").and("sn").is("Person2"));
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
}
|
||||
|
||||
@Test(expected = EmptyResultDataAccessException.class)
|
||||
@@ -351,8 +349,8 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"));
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -360,7 +358,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -369,7 +367,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
contextMapper.setExpectedValues(CN_SN_VALUES);
|
||||
contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -380,7 +378,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,7 +390,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_NAME + "ou=unknown", FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS,
|
||||
contextMapper);
|
||||
assertEquals(0, list.size());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -406,7 +404,7 @@ public class LdapTemplateSearchResultITest extends AbstractLdapTemplateIntegrati
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(3, result.size());
|
||||
assertThat(result).hasSize(3);
|
||||
}
|
||||
|
||||
@Test(expected = SizeLimitExceededException.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,10 +38,8 @@ import javax.naming.Name;
|
||||
import javax.naming.directory.SearchControls;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
|
||||
/**
|
||||
@@ -96,7 +94,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,7 +106,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
.base(BASE_STRING)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -121,7 +119,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
.attributes("cn")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -134,7 +132,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(0, list.size());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,7 +145,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,7 +156,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
List<Object> list = tested.search(query()
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -170,7 +168,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
.base("ou=Norway")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
attributesMapper);
|
||||
assertEquals(0, list.size());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -178,7 +176,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -188,7 +186,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS,
|
||||
attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -196,7 +194,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -204,7 +202,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
attributesMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
attributesMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -214,7 +212,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
attributesMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested
|
||||
.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, attributesMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -222,7 +220,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -231,7 +229,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
DirContextAdapter result = (DirContextAdapter) tested
|
||||
.searchForObject(BASE_STRING, FILTER_STRING, contextMapper);
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test(expected = IncorrectResultSizeDataAccessException.class)
|
||||
@@ -259,7 +257,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -268,7 +266,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
contextMapper.setExpectedValues(CN_SN_VALUES);
|
||||
contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_STRING, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -276,7 +274,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -287,7 +285,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
.base(BASE_NAME)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -297,7 +295,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
List<DirContextAdapter> list = tested.search(query()
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -309,7 +307,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper);
|
||||
assertEquals(0, list.size());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -321,7 +319,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
.searchScope(SearchScope.ONELEVEL)
|
||||
.where("objectclass").is("person").and("sn").is("Person2"),
|
||||
contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -329,8 +327,8 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
DirContextOperations result = tested.searchForContext(query()
|
||||
.where("objectclass").is("person").and("sn").is("Person2"));
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
}
|
||||
|
||||
@Test(expected = EmptyResultDataAccessException.class)
|
||||
@@ -348,8 +346,8 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
.base("ou=company1,ou=Sweden")
|
||||
.where("objectclass").is("person").and("sn").is("Person2"));
|
||||
|
||||
assertNotNull(result);
|
||||
assertEquals("Person2", result.getStringAttribute("sn"));
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -357,7 +355,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
contextMapper.setExpectedAttributes(ALL_ATTRIBUTES);
|
||||
contextMapper.setExpectedValues(ALL_VALUES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -366,7 +364,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
contextMapper.setExpectedValues(CN_SN_VALUES);
|
||||
contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_NAME, FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS, contextMapper);
|
||||
assertEquals(1, list.size());
|
||||
assertThat(list).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -377,7 +375,7 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,6 +387,6 @@ public class LdapTemplateSearchResultNamespaceConfigITest extends AbstractLdapTe
|
||||
contextMapper.setAbsentAttributes(ABSENT_ATTRIBUTES);
|
||||
List list = tested.search(BASE_NAME + "ou=unknown", FILTER_STRING, SearchControls.SUBTREE_SCOPE, CN_SN_ATTRS,
|
||||
contextMapper);
|
||||
assertEquals(0, list.size());
|
||||
assertThat(list).isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,7 +31,7 @@ import javax.naming.Name;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Provides tests that verify that the server supports certain controls.
|
||||
@@ -71,8 +71,8 @@ public class SupportedControlsITest extends AbstractLdapTemplateIntegrationTest
|
||||
|
||||
HashSet<String> controlsSet = new HashSet<String>(Arrays.asList(controls));
|
||||
|
||||
assertTrue("Entry Change Notification LDAPv3 control,", controlsSet.contains("1.3.6.1.4.1.4203.1.10.1"));
|
||||
assertTrue("Subentries Control,", controlsSet.contains("1.3.6.1.4.1.4203.1.10.1"));
|
||||
assertTrue("Manage DSA IT LDAPv3 control,", controlsSet.contains("2.16.840.1.113730.3.4.2"));
|
||||
assertThat(controlsSet.contains("1.3.6.1.4.1.4203.1.10.1")).as("Entry Change Notification LDAPv3 control,").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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,8 +21,7 @@ import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link org.springframework.ldap.core.DistinguishedNameEditor}.
|
||||
@@ -37,8 +36,8 @@ public class DistinguishedNameEditorITest extends AbstractJUnit4SpringContextTes
|
||||
|
||||
@Test
|
||||
public void testDistinguishedNameEditor() throws Exception {
|
||||
assertNotNull(distinguishedNameConsumer);
|
||||
assertThat(distinguishedNameConsumer).isNotNull();
|
||||
DistinguishedName name = distinguishedNameConsumer.getDistinguishedName();
|
||||
assertEquals(new DistinguishedName("dc=jayway, dc=se"), name);
|
||||
assertThat(name).isEqualTo(new DistinguishedName("dc=jayway, dc=se"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +37,8 @@ import javax.naming.directory.SearchControls;
|
||||
import javax.naming.ldap.LdapName;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
@ContextConfiguration(locations = {"/conf/simpleLdapTemplateTestContext.xml"})
|
||||
public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest {
|
||||
@@ -53,28 +52,28 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
@Test
|
||||
public void testLookup() {
|
||||
String result = ldapTemplate.lookup("cn=Some Person,ou=company1,ou=Sweden", new CnContextMapper());
|
||||
assertEquals("Some Person", result);
|
||||
assertThat(result).isEqualTo("Some Person");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLookupName() {
|
||||
String result = ldapTemplate.lookup(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden"),
|
||||
new CnContextMapper());
|
||||
assertEquals("Some Person", result);
|
||||
assertThat(result).isEqualTo("Some Person");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearch() {
|
||||
List<String> cns = ldapTemplate.search("", "(&(objectclass=person)(sn=Person3))", new CnContextMapper());
|
||||
|
||||
assertEquals(1, cns.size());
|
||||
assertEquals("Some Person3", cns.get(0));
|
||||
assertThat(cns).hasSize(1);
|
||||
assertThat(cns.get(0)).isEqualTo("Some Person3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchForObject() {
|
||||
String cn = ldapTemplate.searchForObject("", "(&(objectclass=person)(sn=Person3))", new CnContextMapper());
|
||||
assertEquals("Some Person3", cn);
|
||||
assertThat(cn).isEqualTo("Some Person3");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,10 +85,10 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
List<String> cns = ldapTemplate.search("", "(&(objectclass=person)(sn=Person3))", searchControls,
|
||||
new CnContextMapper(), processor);
|
||||
|
||||
assertEquals(1, cns.size());
|
||||
assertEquals("Some Person3", cns.get(0));
|
||||
assertTrue(processor.isPreProcessCalled());
|
||||
assertTrue(processor.isPostProcessCalled());
|
||||
assertThat(cns).hasSize(1);
|
||||
assertThat(cns.get(0)).isEqualTo("Some Person3");
|
||||
assertThat(processor.isPreProcessCalled()).isTrue();
|
||||
assertThat(processor.isPostProcessCalled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,10 +100,10 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
List<String> cns = ldapTemplate.search(LdapUtils.emptyLdapName(), "(&(objectclass=person)(sn=Person3))",
|
||||
searchControls, new CnContextMapper(), processor);
|
||||
|
||||
assertEquals(1, cns.size());
|
||||
assertEquals("Some Person3", cns.get(0));
|
||||
assertTrue(processor.isPreProcessCalled());
|
||||
assertTrue(processor.isPostProcessCalled());
|
||||
assertThat(cns).hasSize(1);
|
||||
assertThat(cns.get(0)).isEqualTo("Some Person3");
|
||||
assertThat(processor.isPreProcessCalled()).isTrue();
|
||||
assertThat(processor.isPostProcessCalled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,8 +111,8 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
List<String> cns = ldapTemplate.search(LdapUtils.emptyLdapName(), "(&(objectclass=person)(sn=Person3))",
|
||||
new CnContextMapper());
|
||||
|
||||
assertEquals(1, cns.size());
|
||||
assertEquals("Some Person3", cns.get(0));
|
||||
assertThat(cns).hasSize(1);
|
||||
assertThat(cns.get(0)).isEqualTo("Some Person3");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,8 +128,8 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
ldapTemplate.lookup("cn=Some Person,ou=company1,ou=Sweden", new ParameterizedContextMapper<Object>() {
|
||||
public Object mapFromContext(Object ctx) {
|
||||
DirContextAdapter adapter = (DirContextAdapter) ctx;
|
||||
assertEquals("updated description", adapter.getStringAttribute("description"));
|
||||
assertEquals("0000001", adapter.getStringAttribute("telephoneNumber"));
|
||||
assertThat(adapter.getStringAttribute("description")).isEqualTo("updated description");
|
||||
assertThat(adapter.getStringAttribute("telephoneNumber")).isEqualTo("0000001");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -150,8 +149,8 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
ldapTemplate.lookup("cn=Some Person,ou=company1,ou=Sweden", new ParameterizedContextMapper<Object>() {
|
||||
public Object mapFromContext(Object ctx) {
|
||||
DirContextAdapter adapter = (DirContextAdapter) ctx;
|
||||
assertEquals("updated description", adapter.getStringAttribute("description"));
|
||||
assertEquals("0000001", adapter.getStringAttribute("telephoneNumber"));
|
||||
assertThat(adapter.getStringAttribute("description")).isEqualTo("updated description");
|
||||
assertThat(adapter.getStringAttribute("telephoneNumber")).isEqualTo("0000001");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -201,13 +200,13 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
public void testAuthenticate() {
|
||||
AndFilter filter = new AndFilter();
|
||||
filter.and(new EqualsFilter("objectclass", "person")).and(new EqualsFilter("uid", "some.person3"));
|
||||
assertTrue(ldapTemplate.authenticate("", filter.toString(), "password"));
|
||||
assertThat(ldapTemplate.authenticate("", filter.toString(), "password")).isTrue();
|
||||
}
|
||||
|
||||
private void verifyBoundCorrectData() {
|
||||
DirContextOperations result = ldapTemplate.lookupContext(DN_STRING);
|
||||
assertEquals("Some Person4", result.getStringAttribute("cn"));
|
||||
assertEquals("Person4", result.getStringAttribute("sn"));
|
||||
assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4");
|
||||
assertThat(result.getStringAttribute("sn")).isEqualTo("Person4");
|
||||
}
|
||||
|
||||
private void verifyCleanup() {
|
||||
@@ -216,7 +215,7 @@ public class SimpleLdapTemplateITest extends AbstractLdapTemplateIntegrationTest
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,10 +23,8 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor}.
|
||||
@@ -42,11 +40,11 @@ public class BaseLdapPathBeanPostprocessorITest {
|
||||
DummyBaseLdapPathAware tested = ctx.getBean(DummyBaseLdapPathAware.class);
|
||||
|
||||
DistinguishedName base = tested.getBase();
|
||||
assertNotNull(base);
|
||||
assertEquals(new DistinguishedName("dc=261consulting,dc=com"), base);
|
||||
assertThat(base).isNotNull();
|
||||
assertThat(base).isEqualTo(new DistinguishedName("dc=261consulting,dc=com"));
|
||||
|
||||
DummyBaseLdapNameAware otherTested = ctx.getBean(DummyBaseLdapNameAware.class);
|
||||
assertEquals(LdapUtils.newLdapName("dc=261consulting,dc=com"), otherTested.getBaseLdapPath());
|
||||
assertThat(otherTested.getBaseLdapPath()).isEqualTo(LdapUtils.newLdapName("dc=261consulting,dc=com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,7 +55,7 @@ public class BaseLdapPathBeanPostprocessorITest {
|
||||
}
|
||||
catch (BeanCreationException expected) {
|
||||
Throwable cause = expected.getCause();
|
||||
assertTrue(cause instanceof NoSuchBeanDefinitionException);
|
||||
assertThat(cause instanceof NoSuchBeanDefinitionException).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +66,8 @@ public class BaseLdapPathBeanPostprocessorITest {
|
||||
DummyBaseLdapPathAware tested = (DummyBaseLdapPathAware) ctx.getBean("dummyBaseContextAware");
|
||||
|
||||
DistinguishedName base = tested.getBase();
|
||||
assertNotNull(base);
|
||||
assertEquals(new DistinguishedName("cn=john doe,dc=261consulting,dc=com"), base);
|
||||
assertThat(base).isNotNull();
|
||||
assertThat(base).isEqualTo(new DistinguishedName("cn=john doe,dc=261consulting,dc=com"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,7 +78,7 @@ public class BaseLdapPathBeanPostprocessorITest {
|
||||
}
|
||||
catch (BeanCreationException expected) {
|
||||
Throwable cause = expected.getCause();
|
||||
assertTrue(cause instanceof NoSuchBeanDefinitionException);
|
||||
assertThat(cause instanceof NoSuchBeanDefinitionException).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,8 +89,8 @@ public class BaseLdapPathBeanPostprocessorITest {
|
||||
DummyBaseLdapPathAware tested = (DummyBaseLdapPathAware) ctx.getBean("dummyBaseContextAware");
|
||||
|
||||
DistinguishedName base = tested.getBase();
|
||||
assertNotNull(base);
|
||||
assertEquals(new DistinguishedName("cn=john doe"), base);
|
||||
assertThat(base).isNotNull();
|
||||
assertThat(base).isEqualTo(new DistinguishedName("cn=john doe"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -102,7 +100,7 @@ public class BaseLdapPathBeanPostprocessorITest {
|
||||
DummyBaseLdapPathAware tested = (DummyBaseLdapPathAware) ctx.getBean("dummyBaseContextAware");
|
||||
|
||||
DistinguishedName base = tested.getBase();
|
||||
assertNotNull(base);
|
||||
assertEquals(new DistinguishedName("dc=261consulting,dc=com"), base);
|
||||
assertThat(base).isNotNull();
|
||||
assertThat(base).isEqualTo(new DistinguishedName("dc=261consulting,dc=com"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,8 +21,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link org.springframework.ldap.core.support.BaseLdapPathBeanPostProcessor}.
|
||||
@@ -38,11 +37,11 @@ public class BaseLdapPathBeanPostprocessorNamespaceConfigITest {
|
||||
DummyBaseLdapPathAware tested = ctx.getBean(DummyBaseLdapPathAware.class);
|
||||
|
||||
DistinguishedName base = tested.getBase();
|
||||
assertNotNull(base);
|
||||
assertEquals(new DistinguishedName("dc=jayway,dc=se"), base);
|
||||
assertThat(base).isNotNull();
|
||||
assertThat(base).isEqualTo(new DistinguishedName("dc=jayway,dc=se"));
|
||||
|
||||
DummyBaseLdapNameAware otherTested = ctx.getBean(DummyBaseLdapNameAware.class);
|
||||
assertEquals(LdapUtils.newLdapName("dc=jayway,dc=se"), otherTested.getBaseLdapPath());
|
||||
assertThat(otherTested.getBaseLdapPath()).isEqualTo(LdapUtils.newLdapName("dc=jayway,dc=se"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -52,11 +51,11 @@ public class BaseLdapPathBeanPostprocessorNamespaceConfigITest {
|
||||
DummyBaseLdapPathAware tested = ctx.getBean(DummyBaseLdapPathAware.class);
|
||||
|
||||
DistinguishedName base = tested.getBase();
|
||||
assertNotNull(base);
|
||||
assertEquals(new DistinguishedName("dc=jayway,dc=se"), base);
|
||||
assertThat(base).isNotNull();
|
||||
assertThat(base).isEqualTo(new DistinguishedName("dc=jayway,dc=se"));
|
||||
|
||||
DummyBaseLdapNameAware otherTested = ctx.getBean(DummyBaseLdapNameAware.class);
|
||||
assertEquals(LdapUtils.newLdapName("dc=jayway,dc=se"), otherTested.getBaseLdapPath());
|
||||
assertThat(otherTested.getBaseLdapPath()).isEqualTo(LdapUtils.newLdapName("dc=jayway,dc=se"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,11 +38,8 @@ import javax.naming.directory.DirContext;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for LdapContextSource.
|
||||
@@ -65,11 +62,11 @@ public class LdapContextSourceIntegrationTest extends AbstractLdapTemplateIntegr
|
||||
|
||||
try {
|
||||
ctx = tested.getReadOnlyContext();
|
||||
assertNotNull(ctx);
|
||||
assertThat(ctx).isNotNull();
|
||||
Hashtable environment = ctx.getEnvironment();
|
||||
assertFalse(environment.containsKey(LdapContextSource.SUN_LDAP_POOLING_FLAG));
|
||||
assertTrue(environment.containsKey(Context.SECURITY_PRINCIPAL));
|
||||
assertTrue(environment.containsKey(Context.SECURITY_CREDENTIALS));
|
||||
assertThat(environment.containsKey(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isFalse();
|
||||
assertThat(environment.containsKey(Context.SECURITY_PRINCIPAL)).isTrue();
|
||||
assertThat(environment.containsKey(Context.SECURITY_CREDENTIALS)).isTrue();
|
||||
}
|
||||
finally {
|
||||
// Always clean up.
|
||||
@@ -90,12 +87,12 @@ public class LdapContextSourceIntegrationTest extends AbstractLdapTemplateIntegr
|
||||
|
||||
try {
|
||||
ctx = tested.getReadWriteContext();
|
||||
assertNotNull(ctx);
|
||||
assertThat(ctx).isNotNull();
|
||||
// Double check to see that we are authenticated.
|
||||
Hashtable environment = ctx.getEnvironment();
|
||||
assertFalse(environment.containsKey(LdapContextSource.SUN_LDAP_POOLING_FLAG));
|
||||
assertTrue(environment.containsKey(Context.SECURITY_PRINCIPAL));
|
||||
assertTrue(environment.containsKey(Context.SECURITY_CREDENTIALS));
|
||||
assertThat(environment.containsKey(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isFalse();
|
||||
assertThat(environment.containsKey(Context.SECURITY_PRINCIPAL)).isTrue();
|
||||
assertThat(environment.containsKey(Context.SECURITY_CREDENTIALS)).isTrue();
|
||||
}
|
||||
finally {
|
||||
// Always clean up.
|
||||
@@ -118,13 +115,13 @@ public class LdapContextSourceIntegrationTest extends AbstractLdapTemplateIntegr
|
||||
String expectedPrincipal = "cn=Some Person,ou=company1,ou=Sweden," + base;
|
||||
String expectedCredentials = "password";
|
||||
ctx = tested.getContext(expectedPrincipal, expectedCredentials);
|
||||
assertNotNull(ctx);
|
||||
assertThat(ctx).isNotNull();
|
||||
// Double check to see that we are authenticated, and that we did not receive
|
||||
// a connection eligible for connection pooling.
|
||||
Hashtable environment = ctx.getEnvironment();
|
||||
assertFalse(environment.containsKey(LdapContextSource.SUN_LDAP_POOLING_FLAG));
|
||||
assertEquals(expectedPrincipal, environment.get(Context.SECURITY_PRINCIPAL));
|
||||
assertEquals(expectedCredentials, environment.get(Context.SECURITY_CREDENTIALS));
|
||||
assertThat(environment.containsKey(LdapContextSource.SUN_LDAP_POOLING_FLAG)).isFalse();
|
||||
assertThat(environment.get(Context.SECURITY_PRINCIPAL)).isEqualTo(expectedPrincipal);
|
||||
assertThat(environment.get(Context.SECURITY_CREDENTIALS)).isEqualTo(expectedCredentials);
|
||||
}
|
||||
finally {
|
||||
// Always clean up.
|
||||
@@ -152,7 +149,7 @@ public class LdapContextSourceIntegrationTest extends AbstractLdapTemplateIntegr
|
||||
DirContext ctx = null;
|
||||
try {
|
||||
ctx = tested.getContext(results.get(0), "password");
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
catch (Exception e) {
|
||||
fail("Authentication failed");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,7 +23,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
|
||||
import javax.naming.NamingException;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Advanced integration tests for LdapContextSource.
|
||||
@@ -41,6 +41,6 @@ public class LdapContextSourceMultiServerIntegrationTest extends AbstractJUnit4S
|
||||
String[] urls = tested.getUrls();
|
||||
String string = tested.assembleProviderUrlString(urls);
|
||||
|
||||
assertEquals("ldap://127.0.0.1:389 ldap://127.0.0.2:389", string);
|
||||
assertThat(string).isEqualTo("ldap://127.0.0.1:389 ldap://127.0.0.2:389");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,8 +25,7 @@ import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTest;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Mattias Hellborg Arthursson
|
||||
@@ -43,8 +42,8 @@ public class HardcodedFilterIntegrationTest extends AbstractLdapTemplateIntegrat
|
||||
@Test
|
||||
public void verifyThatFilterEditorWorks() {
|
||||
Filter filter = dummyFilterConsumer.getFilter();
|
||||
assertTrue(filter instanceof HardcodedFilter);
|
||||
assertEquals("(&(objectclass=person)(!(objectclass=computer))", filter.toString());
|
||||
assertThat(filter instanceof HardcodedFilter).isTrue();
|
||||
assertThat(filter.toString()).isEqualTo("(&(objectclass=person)(!(objectclass=computer))");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -53,6 +52,6 @@ public class HardcodedFilterIntegrationTest extends AbstractLdapTemplateIntegrat
|
||||
CountNameClassPairCallbackHandler handler = new CountNameClassPairCallbackHandler();
|
||||
ldapTemplate.search(LdapUtils.emptyLdapName(), filter.encode(), handler);
|
||||
int hits = handler.getNoOfRows();
|
||||
assertTrue("expected more than one hit, got " + hits, hits > 1);
|
||||
assertThat(hits > 1).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,7 @@ import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTest;
|
||||
import org.springframework.ldap.itest.LdapGroupDao;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for https://jira.springsource.org/browse/LDAP-247.
|
||||
@@ -38,12 +38,10 @@ public class JiraLdap247ITest extends AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void verifyThatBasePathIsProperlyPopulated() {
|
||||
assertNotNull(ldapGroupDao);
|
||||
assertThat(ldapGroupDao).isNotNull();
|
||||
|
||||
// The base path should be automatically populated by BaseLdapPathBeanPostProcessor,
|
||||
// but it doesn't unless it implements Ordered, which caused the assertion below to fail.
|
||||
assertNotNull(
|
||||
"Base path has not been populated by BaseLdapPathBeanPostProcessor",
|
||||
ldapGroupDao.getBasePath());
|
||||
assertThat(ldapGroupDao.getBasePath()).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.ldap.itest.ldap321;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Ldap321Test{
|
||||
@Test
|
||||
public void testQueryRoleMap() throws Exception {
|
||||
Map<String,String> roleMap=roleRepo.queryRoleMap();
|
||||
assertNotNull(roleMap);
|
||||
assertThat(roleMap).isNotNull();
|
||||
|
||||
for(String roleName:roleMap.keySet()){
|
||||
System.out.println(roleName+":"+ roleMap.get(roleName));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,10 +39,8 @@ import javax.naming.directory.Attributes;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager}.
|
||||
@@ -88,7 +86,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
@@ -99,7 +97,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -111,7 +109,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
fail("EmptyResultDataAccessException expected");
|
||||
}
|
||||
catch (EmptyResultDataAccessException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,8 +125,8 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(dbResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(dbResult).isNotNull();
|
||||
|
||||
ldapTemplate.unbind("cn=some testperson, ou=company1, ou=Sweden");
|
||||
}
|
||||
@@ -141,15 +139,15 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
@@ -157,14 +155,14 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
Object jdbcResult = jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
assertEquals("Person", rs.getString("lastname"));
|
||||
assertEquals("Sweden, Company1, Some Person", rs.getString("description"));
|
||||
assertThat(rs.getString("lastname")).isEqualTo("Person");
|
||||
assertThat(rs.getString("description")).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(jdbcResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -175,8 +173,8 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated Person", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
@@ -184,14 +182,14 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
Object jdbcResult = jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
assertEquals("Updated Person", rs.getString("lastname"));
|
||||
assertEquals("Updated description", rs.getString("description"));
|
||||
assertThat(rs.getString("lastname")).isEqualTo("Updated Person");
|
||||
assertThat(rs.getString("description")).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(jdbcResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
|
||||
}
|
||||
|
||||
@@ -205,7 +203,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
@@ -214,17 +212,17 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Sweden, Company1, Some Person2", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -237,12 +235,12 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
dummyDao.updateAndRename(newDn, dn, "Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
@@ -255,19 +253,19 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -279,13 +277,13 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated lastname", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
|
||||
}
|
||||
|
||||
@@ -298,7 +296,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
@@ -317,8 +315,8 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(jdbcResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -333,7 +331,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -346,7 +344,7 @@ public class ContextSourceAndDataSourceTransactionManagerIntegrationTest extends
|
||||
fail("EmptyResultDataAccessException expected");
|
||||
}
|
||||
catch (EmptyResultDataAccessException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,9 +32,8 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
import org.springframework.transaction.CannotCreateTransactionException;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager}.
|
||||
@@ -75,17 +74,17 @@ public class ContextSourceAndDataSourceTransactionManagerLdap179IntegrationTest
|
||||
dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
|
||||
fail("CannotCreateTransactionException expected");
|
||||
} catch (CannotCreateTransactionException expected) {
|
||||
assertTrue(expected.getCause() instanceof CommunicationException);
|
||||
assertThat(expected.getCause() instanceof CommunicationException).isTrue();
|
||||
}
|
||||
|
||||
// Make sure there is no transaction synchronization
|
||||
assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
|
||||
|
||||
try {
|
||||
dummyDao.create("Sweden", "company1", "some testperson", "testperson", "some description");
|
||||
fail("CannotCreateTransactionException expected");
|
||||
} catch (CannotCreateTransactionException expected) {
|
||||
assertTrue(expected.getCause() instanceof CommunicationException);
|
||||
assertThat(expected.getCause() instanceof CommunicationException).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,10 +40,8 @@ import javax.naming.directory.Attributes;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager}
|
||||
@@ -90,7 +88,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
@@ -101,7 +99,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -113,7 +111,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
fail("EmptyResultDataAccessException expected");
|
||||
}
|
||||
catch (EmptyResultDataAccessException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,8 +127,8 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(dbResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(dbResult).isNotNull();
|
||||
|
||||
ldapTemplate.unbind("cn=some testperson, ou=company1, ou=Sweden");
|
||||
}
|
||||
@@ -143,15 +141,15 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
@@ -159,14 +157,14 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
Object jdbcResult = jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
assertEquals("Person", rs.getString("lastname"));
|
||||
assertEquals("Sweden, Company1, Some Person", rs.getString("description"));
|
||||
assertThat(rs.getString("lastname")).isEqualTo("Person");
|
||||
assertThat(rs.getString("description")).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(jdbcResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -177,8 +175,8 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated Person", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
@@ -186,14 +184,14 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
Object jdbcResult = jdbcTemplate.queryForObject("select * from PERSON where fullname=?",
|
||||
new Object[] { "Some Person" }, new RowMapper() {
|
||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||
assertEquals("Updated Person", rs.getString("lastname"));
|
||||
assertEquals("Updated description", rs.getString("description"));
|
||||
assertThat(rs.getString("lastname")).isEqualTo("Updated Person");
|
||||
assertThat(rs.getString("description")).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(jdbcResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
|
||||
}
|
||||
|
||||
@@ -207,7 +205,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
@@ -216,17 +214,17 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Sweden, Company1, Some Person2", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -239,12 +237,12 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
dummyDao.updateAndRename(newDn, dn, "Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
@@ -257,19 +255,19 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -281,13 +279,13 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated lastname", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
|
||||
}
|
||||
|
||||
@@ -300,7 +298,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
@@ -319,8 +317,8 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(jdbcResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(jdbcResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -335,7 +333,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -348,7 +346,7 @@ public class ContextSourceAndDataSourceTransactionManagerNamespaceITest extends
|
||||
fail("EmptyResultDataAccessException expected");
|
||||
}
|
||||
catch (EmptyResultDataAccessException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,10 +33,8 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceTransactionManager}.
|
||||
@@ -69,7 +67,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
@@ -80,7 +78,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +89,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
log.debug("Verifying result");
|
||||
String expectedDn = "cn=some testperson, ou=company1, ou=Sweden";
|
||||
Object ldapResult = ldapTemplate.lookup(expectedDn);
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
|
||||
ldapTemplate.unbind(expectedDn);
|
||||
}
|
||||
@@ -104,20 +102,20 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,13 +126,13 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated Person", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
|
||||
dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
|
||||
}
|
||||
@@ -149,7 +147,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
@@ -158,17 +156,17 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Sweden, Company1, Some Person2", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -181,12 +179,12 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
dummyDao.updateAndRename(newDn, dn, "Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
@@ -199,19 +197,19 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -223,13 +221,13 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated lastname", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -241,7 +239,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
@@ -252,7 +250,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -267,7 +265,7 @@ public class ContextSourceTransactionManagerIntegrationTest extends AbstractLdap
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,10 +33,8 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
||||
import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceTransactionManager}
|
||||
@@ -70,7 +68,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
@@ -81,7 +79,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +90,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
log.debug("Verifying result");
|
||||
String expectedDn = "cn=some testperson, ou=company1, ou=Sweden";
|
||||
Object ldapResult = ldapTemplate.lookup(expectedDn);
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
|
||||
ldapTemplate.unbind(expectedDn);
|
||||
}
|
||||
@@ -105,20 +103,20 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -129,13 +127,13 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated Person", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
|
||||
dummyDao.update(dn, "Some Person", "Person", "Sweden, Company1, Some Person");
|
||||
}
|
||||
@@ -150,7 +148,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
@@ -159,17 +157,17 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Sweden, Company1, Some Person2", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -182,12 +180,12 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
dummyDao.updateAndRename(newDn, dn, "Sweden, Company1, Some Person2");
|
||||
}
|
||||
|
||||
@@ -200,19 +198,19 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -224,13 +222,13 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated lastname", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -242,7 +240,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
@@ -253,7 +251,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -268,7 +266,7 @@ public class ContextSourceTransactionManagerNamespaceIntegrationTest extends Abs
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,8 +30,8 @@ import org.springframework.ldap.itest.transaction.compensating.manager.DummyExce
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndDataSourceTransactionManager}
|
||||
@@ -68,7 +68,7 @@ public class ContextSourceTransactionManagerSubtreeIntegrationTest extends Abstr
|
||||
ldapTemplate.lookup("ou=company1,ou=Sweden");
|
||||
fail("NameNotFoundException expected");
|
||||
} catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class ContextSourceTransactionManagerSubtreeIntegrationTest extends Abstr
|
||||
dummyDao.deleteRecursivelyWithException("ou=company1,ou=Sweden");
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Entry should have been restored
|
||||
@@ -96,7 +96,7 @@ public class ContextSourceTransactionManagerSubtreeIntegrationTest extends Abstr
|
||||
dummyDao.createRecursivelyAndUnbindSubnodeWithException();
|
||||
fail("DummyException expected");
|
||||
} catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,11 +42,8 @@ import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ContextSourceAndHibernateTransactionManager}.
|
||||
@@ -123,7 +120,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
@@ -134,12 +131,12 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
List result = hibernateTemplate.findByNamedParam("from OrgPerson person where person.lastname = :lastname",
|
||||
"lastname", person.getLastname());
|
||||
assertTrue(result.size() == 0);
|
||||
assertThat(result.size() == 0).isTrue();
|
||||
|
||||
}
|
||||
|
||||
@@ -161,8 +158,8 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
OrgPerson fromDb = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, new Integer(2));
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(fromDb);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(fromDb).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -175,24 +172,24 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertNotNull("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).as("Person").isNotNull();
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
OrgPerson notUpdatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
assertEquals("Person", notUpdatedPerson.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person", notUpdatedPerson.getDescription());
|
||||
assertThat(notUpdatedPerson.getLastname()).isEqualTo("Person");
|
||||
assertThat(notUpdatedPerson.getDescription()).isEqualTo("Sweden, Company1, Some Person");
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
// no need to assert if notUpdatedPerson exists
|
||||
}
|
||||
|
||||
@@ -208,16 +205,16 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated Person", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
OrgPerson updatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
assertEquals("Updated Person", updatedPerson.getLastname());
|
||||
assertEquals("Updated description", updatedPerson.getDescription());
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(updatedPerson.getLastname()).isEqualTo("Updated Person");
|
||||
assertThat(updatedPerson.getDescription()).isEqualTo("Updated description");
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -234,7 +231,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
@@ -243,17 +240,17 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Sweden, Company1, Some Person2", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -266,12 +263,12 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -283,19 +280,19 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -307,13 +304,13 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated lastname", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -327,7 +324,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
person = null;
|
||||
@@ -348,7 +345,7 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
// not
|
||||
// exist
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -364,10 +361,10 @@ public class ContextSourceAndHibernateTransactionManagerIntegrationTest extends
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
person = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, new Integer(1));
|
||||
assertNull(person);
|
||||
assertThat(person).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,8 +30,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
|
||||
import org.springframework.transaction.CannotCreateTransactionException;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager}.
|
||||
@@ -68,16 +67,16 @@ public class ContextSourceAndHibernateTransactionManagerLdap179IntegrationTest e
|
||||
try {
|
||||
this.dummyDao.create(person);
|
||||
} catch (CannotCreateTransactionException expected) {
|
||||
assertTrue(expected.getCause() instanceof CommunicationException);
|
||||
assertThat(expected.getCause() instanceof CommunicationException).isTrue();
|
||||
}
|
||||
|
||||
// Make sure there is no transaction synchronization
|
||||
assertFalse(TransactionSynchronizationManager.isSynchronizationActive());
|
||||
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
|
||||
|
||||
try {
|
||||
this.dummyDao.create(person);
|
||||
} catch (CannotCreateTransactionException expected) {
|
||||
assertTrue(expected.getCause() instanceof CommunicationException);
|
||||
assertThat(expected.getCause() instanceof CommunicationException).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,11 +41,8 @@ import javax.naming.NamingException;
|
||||
import javax.naming.directory.Attributes;
|
||||
import java.util.List;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager}
|
||||
@@ -123,7 +120,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
@@ -134,12 +131,12 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
List result = hibernateTemplate.findByNamedParam("from OrgPerson person where person.lastname = :lastname",
|
||||
"lastname", person.getLastname());
|
||||
assertTrue(result.size() == 0);
|
||||
assertThat(result.size() == 0).isTrue();
|
||||
|
||||
}
|
||||
|
||||
@@ -161,8 +158,8 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup("cn=some testperson, ou=company1, ou=Sweden");
|
||||
OrgPerson fromDb = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, new Integer(2));
|
||||
assertNotNull(ldapResult);
|
||||
assertNotNull(fromDb);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
assertThat(fromDb).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -175,24 +172,24 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
log.debug("Verifying result");
|
||||
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertNotNull("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).as("Person").isNotNull();
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
OrgPerson notUpdatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
assertEquals("Person", notUpdatedPerson.getLastname());
|
||||
assertEquals("Sweden, Company1, Some Person", notUpdatedPerson.getDescription());
|
||||
assertThat(notUpdatedPerson.getLastname()).isEqualTo("Person");
|
||||
assertThat(notUpdatedPerson.getDescription()).isEqualTo("Sweden, Company1, Some Person");
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
// no need to assert if notUpdatedPerson exists
|
||||
}
|
||||
|
||||
@@ -208,16 +205,16 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
log.debug("Verifying result");
|
||||
Object ldapResult = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated Person", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
OrgPerson updatedPerson = (OrgPerson) this.hibernateTemplate.load(OrgPerson.class, new Integer(1));
|
||||
assertEquals("Updated Person", updatedPerson.getLastname());
|
||||
assertEquals("Updated description", updatedPerson.getDescription());
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(updatedPerson.getLastname()).isEqualTo("Updated Person");
|
||||
assertThat(updatedPerson.getDescription()).isEqualTo("Updated description");
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -234,7 +231,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that entry was not moved.
|
||||
@@ -243,17 +240,17 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify that original entry was not updated.
|
||||
Object object = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Sweden, Company1, Some Person2", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person2");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -266,12 +263,12 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
// Verify that entry was moved and updated.
|
||||
Object object = ldapTemplate.lookup(newDn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(object);
|
||||
assertThat(object).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -283,19 +280,19 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
// Verify result - check that the operation was properly rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Person", attributes.get("sn").get());
|
||||
assertEquals("Sweden, Company1, Some Person", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Person");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Sweden, Company1, Some Person");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -307,13 +304,13 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
// Verify result - check that the operation was not rolled back
|
||||
Object result = ldapTemplate.lookup(dn, new AttributesMapper() {
|
||||
public Object mapFromAttributes(Attributes attributes) throws NamingException {
|
||||
assertEquals("Updated lastname", attributes.get("sn").get());
|
||||
assertEquals("Updated description", attributes.get("description").get());
|
||||
assertThat(attributes.get("sn").get()).isEqualTo("Updated lastname");
|
||||
assertThat(attributes.get("description").get()).isEqualTo("Updated description");
|
||||
return new Object();
|
||||
}
|
||||
});
|
||||
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -327,7 +324,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
fail("DummyException expected");
|
||||
}
|
||||
catch (DummyException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
person = null;
|
||||
@@ -348,7 +345,7 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
// not
|
||||
// exist
|
||||
|
||||
assertNotNull(ldapResult);
|
||||
assertThat(ldapResult).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -364,10 +361,10 @@ public class ContextSourceAndHibernateTransactionManagerNamespaceITest extends A
|
||||
fail("NameNotFoundException expected");
|
||||
}
|
||||
catch (NameNotFoundException expected) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
|
||||
person = (OrgPerson) this.hibernateTemplate.get(OrgPerson.class, new Integer(1));
|
||||
assertNull(person);
|
||||
assertThat(person).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,10 +27,7 @@ import javax.naming.Name;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
|
||||
/**
|
||||
@@ -45,15 +42,15 @@ public class LdapTemplateOdmGroupManipulationITest extends AbstractLdapTemplateI
|
||||
public void testFindOne() {
|
||||
Group group = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
assertNotNull(group);
|
||||
assertEquals("ROLE_USER", group.getName());
|
||||
assertEquals(4, group.getMembers().size());
|
||||
assertThat(group).isNotNull();
|
||||
assertThat(group.getName()).isEqualTo("ROLE_USER");
|
||||
assertThat(group.getMembers()).hasSize(4);
|
||||
|
||||
Set<Name> members = group.getMembers();
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person2,ou=company1,ou=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company2,ou=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden," + base)));
|
||||
assertThat(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base))).isTrue();
|
||||
assertThat(members.contains(LdapUtils.newLdapName("cn=Some Person2,ou=company1,ou=Sweden," + base))).isTrue();
|
||||
assertThat(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company2,ou=Sweden," + base))).isTrue();
|
||||
assertThat(members.contains(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden," + base))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -66,8 +63,8 @@ public class LdapTemplateOdmGroupManipulationITest extends AbstractLdapTemplateI
|
||||
Group verification = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
Set<Name> members = verification.getMembers();
|
||||
assertEquals(3, members.size());
|
||||
assertFalse(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
assertThat(members).hasSize(3);
|
||||
assertThat(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,8 +77,8 @@ public class LdapTemplateOdmGroupManipulationITest extends AbstractLdapTemplateI
|
||||
Group verification = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
Set<Name> members = verification.getMembers();
|
||||
assertEquals(3, members.size());
|
||||
assertFalse(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
assertThat(members).hasSize(3);
|
||||
assertThat(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base))).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,8 +91,8 @@ public class LdapTemplateOdmGroupManipulationITest extends AbstractLdapTemplateI
|
||||
Group verification = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
Set<Name> members = verification.getMembers();
|
||||
assertEquals(5, members.size());
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Norway," + base)));
|
||||
assertThat(members).hasSize(5);
|
||||
assertThat(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Norway," + base))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,8 +105,8 @@ public class LdapTemplateOdmGroupManipulationITest extends AbstractLdapTemplateI
|
||||
Group verification = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
Set<Name> members = verification.getMembers();
|
||||
assertEquals(4, members.size());
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
assertThat(members).hasSize(4);
|
||||
assertThat(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -122,8 +119,8 @@ public class LdapTemplateOdmGroupManipulationITest extends AbstractLdapTemplateI
|
||||
Group verification = tested.findOne(query().where("cn").is("ROLE_USER"), Group.class);
|
||||
|
||||
Set<Name> members = verification.getMembers();
|
||||
assertEquals(4, members.size());
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
assertThat(members).hasSize(4);
|
||||
assertThat(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base))).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -140,8 +137,8 @@ public class LdapTemplateOdmGroupManipulationITest extends AbstractLdapTemplateI
|
||||
|
||||
Set<Name> members = verification.getMembers();
|
||||
|
||||
assertEquals(2, members.size());
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base)));
|
||||
assertTrue(members.contains(LdapUtils.newLdapName("cn=Some Person2,ou=company1,ou=Sweden," + base)));
|
||||
assertThat(members).hasSize(2);
|
||||
assertThat(members.contains(LdapUtils.newLdapName("cn=Some Person,ou=company1,ou=Sweden," + base))).isTrue();
|
||||
assertThat(members.contains(LdapUtils.newLdapName("cn=Some Person2,ou=company1,ou=Sweden," + base))).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,9 +26,8 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
|
||||
/**
|
||||
@@ -44,15 +43,15 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
PersonWithDnAnnotations person = tested.findOne(query()
|
||||
.where("cn").is("Some Person3"), PersonWithDnAnnotations.class);
|
||||
|
||||
assertNotNull(person);
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
|
||||
// Automatically calculated
|
||||
assertEquals("company1", person.getCompany());
|
||||
assertEquals("Sweden", person.getCountry());
|
||||
assertThat(person.getCompany()).isEqualTo("company1");
|
||||
assertThat(person.getCountry()).isEqualTo("Sweden");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -60,15 +59,15 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
PersonWithDnAnnotations person = tested.findByDn(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"),
|
||||
PersonWithDnAnnotations.class);
|
||||
|
||||
assertNotNull(person);
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
|
||||
// Automatically calculated
|
||||
assertEquals("company1", person.getCompany());
|
||||
assertEquals("Sweden", person.getCountry());
|
||||
assertThat(person.getCompany()).isEqualTo("company1");
|
||||
assertThat(person.getCountry()).isEqualTo("Sweden");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,13 +76,13 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
.base("ou=Sweden")
|
||||
.where("cn").isPresent(), PersonWithDnAnnotations.class);
|
||||
|
||||
assertEquals(4, persons.size());
|
||||
assertThat(persons).hasSize(4);
|
||||
|
||||
PersonWithDnAnnotations person = findPerson(persons, "Some Person3");
|
||||
|
||||
// Automatically calculated
|
||||
assertEquals("company1", person.getCompany());
|
||||
assertEquals("Sweden", person.getCountry());
|
||||
assertThat(person.getCompany()).isEqualTo("company1");
|
||||
assertThat(person.getCountry()).isEqualTo("Sweden");
|
||||
}
|
||||
|
||||
private PersonWithDnAnnotations findPerson(List<PersonWithDnAnnotations> persons, String cn) {
|
||||
@@ -112,19 +111,19 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
|
||||
tested.create(person);
|
||||
|
||||
assertEquals(6, tested.findAll(PersonWithDnAnnotations.class).size());
|
||||
assertThat(tested.findAll(PersonWithDnAnnotations.class)).hasSize(6);
|
||||
|
||||
person = tested.findByDn(LdapUtils.newLdapName("cn=New Person,ou=company1,ou=Sweden"),
|
||||
PersonWithDnAnnotations.class);
|
||||
|
||||
assertEquals("New Person", person.getCommonName());
|
||||
assertEquals("Person", person.getSurname());
|
||||
assertEquals("This is the description", person.getDesc().get(0));
|
||||
assertEquals("0123456", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("New Person");
|
||||
assertThat(person.getSurname()).isEqualTo("Person");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("This is the description");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("0123456");
|
||||
|
||||
// Automatically calculated
|
||||
assertEquals("company1", person.getCompany());
|
||||
assertEquals("Sweden", person.getCountry());
|
||||
assertThat(person.getCompany()).isEqualTo("company1");
|
||||
assertThat(person.getCountry()).isEqualTo("Sweden");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,10 +138,10 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
LdapUtils.newLdapName("cn=Some Person3, ou=company1, ou=Sweden"),
|
||||
PersonWithDnAnnotations.class);
|
||||
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("New Description", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("New Description");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,10 +157,10 @@ public class LdapTemplateOdmWithDnAnnotationsITest extends AbstractLdapTemplateI
|
||||
LdapUtils.newLdapName("cn=Some Person3, ou=company1, ou=Norway"),
|
||||
PersonWithDnAnnotations.class);
|
||||
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Norway", person.getCountry());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getCountry()).isEqualTo("Norway");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,11 +29,8 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
|
||||
/**
|
||||
@@ -49,22 +46,22 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
Person person = tested.findOne(query()
|
||||
.where("cn").is("Some Person3"), Person.class);
|
||||
|
||||
assertNotNull(person);
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindByDn() {
|
||||
Person person = tested.findByDn(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"), Person.class);
|
||||
|
||||
assertNotNull(person);
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test(expected = OdmException.class)
|
||||
@@ -83,14 +80,14 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
List<Person> persons = tested.find(query()
|
||||
.where("cn").is("Some Person3"), Person.class);
|
||||
|
||||
assertEquals(1, persons.size());
|
||||
assertThat(persons).hasSize(1);
|
||||
Person person = persons.get(0);
|
||||
|
||||
assertNotNull(person);
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,16 +96,16 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
.base("ou=Sweden")
|
||||
.where("cn").isPresent(), Person.class);
|
||||
|
||||
assertEquals(4, persons.size());
|
||||
assertThat(persons).hasSize(4);
|
||||
Person person = persons.get(0);
|
||||
|
||||
assertNotNull(person);
|
||||
assertThat(person).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindAll() {
|
||||
List<Person> result = tested.findAll(Person.class);
|
||||
assertEquals(5, result.size());
|
||||
assertThat(result).hasSize(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -123,15 +120,15 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
|
||||
tested.create(person);
|
||||
|
||||
assertEquals(6, tested.findAll(Person.class).size());
|
||||
assertThat(tested.findAll(Person.class)).hasSize(6);
|
||||
|
||||
person = tested.findOne(query()
|
||||
.where("cn").is("New Person"), Person.class);
|
||||
|
||||
assertEquals("New Person", person.getCommonName());
|
||||
assertEquals("Person", person.getSurname());
|
||||
assertEquals("This is the description", person.getDesc().get(0));
|
||||
assertEquals("0123456", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("New Person");
|
||||
assertThat(person.getSurname()).isEqualTo("Person");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("This is the description");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("0123456");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -145,10 +142,10 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
person = tested.findOne(query()
|
||||
.where("cn").is("Some Person3"), Person.class);
|
||||
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("New Description", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("New Description");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,7 +159,7 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
tested.findOne(query().where("cn").is("Some Person3"), Person.class);
|
||||
fail("EmptyResultDataAccessException e");
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
assertTrue(true);
|
||||
assertThat(true).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +177,6 @@ public class LdapTemplateOdmWithNoDnAnnotationsITest extends AbstractLdapTemplat
|
||||
|
||||
person = tested.findOne(query()
|
||||
.where("cn").is("Some Person3"), Person.class);
|
||||
assertNull("TelephoneNumber should be null", person.getTelephoneNumber());
|
||||
assertThat(person.getTelephoneNumber()).as("TelephoneNumber should be null").isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,8 +26,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Mattias Hellborg Arthursson
|
||||
@@ -49,11 +48,11 @@ public class LdapTemplateQueryDslLdapQueryITest extends AbstractLdapTemplateInte
|
||||
public void testUniqueResult() {
|
||||
Person person = query.where(qperson.commonName.eq("Some Person3")).uniqueResult();
|
||||
|
||||
assertNotNull(person);
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -61,9 +60,9 @@ public class LdapTemplateQueryDslLdapQueryITest extends AbstractLdapTemplateInte
|
||||
List<Person> persons = query.where(qperson.commonName.eq("Some Person3")).list();
|
||||
|
||||
Person person = persons.get(0);
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,9 +26,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import javax.naming.Name;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for Spring LDAP automatic repository scan functionality enabled with
|
||||
@@ -45,17 +43,17 @@ public class RepositoryScanAnnotationConfiguredITest extends AbstractLdapTemplat
|
||||
|
||||
@Test
|
||||
public void testExists() {
|
||||
assertTrue(tested.exists(PERSON3_DN));
|
||||
assertThat(tested.exists(PERSON3_DN)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindOneWithDn() {
|
||||
Person person = tested.findOne(PERSON3_DN);
|
||||
|
||||
assertNotNull(person);
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,12 +31,8 @@ import javax.naming.ldap.LdapName;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
|
||||
/**
|
||||
@@ -54,48 +50,48 @@ public class RepositoryScanITest extends AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void testExists() {
|
||||
assertTrue(tested.exists(PERSON3_DN));
|
||||
assertThat(tested.exists(PERSON3_DN)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindOneWithDn() {
|
||||
Person person = tested.findOne(PERSON3_DN);
|
||||
|
||||
assertNotNull(person);
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyThatFindOneWithNonexistingDnReturnsNull() {
|
||||
Person person = tested.findOne(LdapUtils.newLdapName("cn=unknown"));
|
||||
assertNull(person);
|
||||
assertThat(person).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindOneWithQuery() {
|
||||
Person person = tested.findOne(query().where("cn").is("Some Person3"));
|
||||
|
||||
assertNotNull(person);
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindAll() {
|
||||
Iterable<Person> result = tested.findAll();
|
||||
assertEquals(5, countIterable(result));
|
||||
assertThat(countIterable(result)).isEqualTo(5);
|
||||
|
||||
for (Person person : result) {
|
||||
if(StringUtils.equals(person.getCommonName(), "Some Person3")) {
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
|
||||
// Done
|
||||
return;
|
||||
@@ -109,16 +105,16 @@ public class RepositoryScanITest extends AbstractLdapTemplateIntegrationTest {
|
||||
public void testFindAllWithQuery() {
|
||||
Iterable<Person> persons = tested.findAll(query().where("cn").is("Some Person3"));
|
||||
|
||||
assertNotNull(persons);
|
||||
assertThat(persons).isNotNull();
|
||||
Iterator<Person> iterator = persons.iterator();
|
||||
Person person = iterator.next();
|
||||
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
|
||||
assertFalse(iterator.hasNext());
|
||||
assertThat(iterator.hasNext()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,19 +123,19 @@ public class RepositoryScanITest extends AbstractLdapTemplateIntegrationTest {
|
||||
Iterator<Person> iterator = persons.iterator();
|
||||
Person person = iterator.next();
|
||||
|
||||
assertEquals("Some Person", person.getCommonName());
|
||||
assertEquals("Person", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123456", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person");
|
||||
assertThat(person.getSurname()).isEqualTo("Person");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123456");
|
||||
|
||||
person = iterator.next();
|
||||
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
|
||||
assertFalse(iterator.hasNext());
|
||||
assertThat(iterator.hasNext()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -148,17 +144,17 @@ public class RepositoryScanITest extends AbstractLdapTemplateIntegrationTest {
|
||||
Iterator<Person> iterator = persons.iterator();
|
||||
Person person = iterator.next();
|
||||
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
|
||||
assertFalse(iterator.hasNext());
|
||||
assertThat(iterator.hasNext()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCount() {
|
||||
assertEquals(5, tested.count());
|
||||
assertThat(tested.count()).isEqualTo(5);
|
||||
}
|
||||
|
||||
private int countIterable(Iterable<?> iterable) {
|
||||
@@ -183,14 +179,14 @@ public class RepositoryScanITest extends AbstractLdapTemplateIntegrationTest {
|
||||
person.setNew();
|
||||
tested.save(person);
|
||||
|
||||
assertEquals(6, tested.count());
|
||||
assertThat(tested.count()).isEqualTo(6);
|
||||
|
||||
person = tested.findOne(dn);
|
||||
|
||||
assertEquals("New Person", person.getCommonName());
|
||||
assertEquals("Person", person.getSurname());
|
||||
assertEquals("This is the description", person.getDesc().get(0));
|
||||
assertEquals("0123456", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("New Person");
|
||||
assertThat(person.getSurname()).isEqualTo("Person");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("This is the description");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("0123456");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -213,10 +209,10 @@ public class RepositoryScanITest extends AbstractLdapTemplateIntegrationTest {
|
||||
|
||||
person = tested.findOne(query().where("cn").is("Some Person3"));
|
||||
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("New Description", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("New Description");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -225,7 +221,7 @@ public class RepositoryScanITest extends AbstractLdapTemplateIntegrationTest {
|
||||
tested.delete(person);
|
||||
|
||||
Person found = tested.findOne(query().where("cn").is("Some Person3"));
|
||||
assertNull(found);
|
||||
assertThat(found).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -233,33 +229,33 @@ public class RepositoryScanITest extends AbstractLdapTemplateIntegrationTest {
|
||||
Iterable<Person> found = tested.findAll(Arrays.asList(PERSON1_DN, PERSON3_DN));
|
||||
tested.delete(found);
|
||||
|
||||
assertEquals(3, tested.count());
|
||||
assertThat(tested.count()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindByLastName() {
|
||||
Iterable<Person> found = tested.findByLastName("Person3");
|
||||
assertEquals(1, countIterable(found));
|
||||
assertThat(countIterable(found)).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindByUid() {
|
||||
Person person = tested.findByUid("some.person3");
|
||||
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindByPhoneNumber() {
|
||||
Person person = tested.findByTelephoneNumber("+46 555-123654");
|
||||
|
||||
assertEquals("Some Person3", person.getCommonName());
|
||||
assertEquals("Person3", person.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", person.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(person.getSurname()).isEqualTo("Person3");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,14 +22,9 @@ import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTest;
|
||||
import org.springframework.ldap.itest.odm.Person;
|
||||
import org.springframework.ldap.itest.odm.QPerson;
|
||||
import org.springframework.ldap.itest.repositories.PersonQueryDslRepository;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import javax.naming.Name;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for Spring LDAP automatic repository scan functionality.
|
||||
@@ -48,11 +43,11 @@ public class RepositoryScanQueryDslITest extends AbstractLdapTemplateIntegration
|
||||
|
||||
Person found = tested.findOne(person.commonName.eq("Some Person3"));
|
||||
|
||||
assertNotNull(found);
|
||||
assertEquals("Some Person3", found.getCommonName());
|
||||
assertEquals("Person3", found.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", found.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", found.getTelephoneNumber());
|
||||
assertThat(found).isNotNull();
|
||||
assertThat(found.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(found.getSurname()).isEqualTo("Person3");
|
||||
assertThat(found.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(found.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,10 +57,10 @@ public class RepositoryScanQueryDslITest extends AbstractLdapTemplateIntegration
|
||||
Iterable<Person> foundPersons = tested.findAll(person.commonName.eq("Some Person3"));
|
||||
|
||||
Person found = foundPersons.iterator().next();
|
||||
assertEquals("Some Person3", found.getCommonName());
|
||||
assertEquals("Person3", found.getSurname());
|
||||
assertEquals("Sweden, Company1, Some Person3", found.getDesc().get(0));
|
||||
assertEquals("+46 555-123654", found.getTelephoneNumber());
|
||||
assertThat(found.getCommonName()).isEqualTo("Some Person3");
|
||||
assertThat(found.getSurname()).isEqualTo("Person3");
|
||||
assertThat(found.getDesc().get(0)).isEqualTo("Sweden, Company1, Some Person3");
|
||||
assertThat(found.getTelephoneNumber()).isEqualTo("+46 555-123654");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,6 +68,6 @@ public class RepositoryScanQueryDslITest extends AbstractLdapTemplateIntegration
|
||||
QPerson person = QPerson.person;
|
||||
|
||||
long count = tested.count(person.commonName.eq("Some Person3"));
|
||||
assertEquals(1, count);
|
||||
assertThat(count).isEqualTo(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2013 the original author or authors.
|
||||
* Copyright 2005-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,15 +21,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTest;
|
||||
import org.springframework.ldap.itest.odm.PersonWithDnAnnotations;
|
||||
import org.springframework.ldap.itest.repositories.PersonWithDnAnnotationsRepository;
|
||||
import org.springframework.ldap.query.LdapQueryBuilder;
|
||||
import org.springframework.ldap.support.LdapUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.ldap.query.LdapQueryBuilder.query;
|
||||
|
||||
/**
|
||||
@@ -52,33 +49,33 @@ public class RepositoryScanWithDnAnnotationsITest extends AbstractLdapTemplateIn
|
||||
person.setCountry("Sweden");
|
||||
person.setCompany("company1");
|
||||
|
||||
assertNull(person.getDn());
|
||||
assertThat(person.getDn()).isNull();
|
||||
|
||||
tested.save(person);
|
||||
|
||||
assertNotNull(person.getDn());
|
||||
assertThat(person.getDn()).isNotNull();
|
||||
|
||||
assertEquals(6, tested.count());
|
||||
assertThat(tested.count()).isEqualTo(6);
|
||||
|
||||
person = tested.findOne(query().where("cn").is("New Person"));
|
||||
|
||||
assertEquals("New Person", person.getCommonName());
|
||||
assertEquals("Person", person.getSurname());
|
||||
assertEquals("This is the description", person.getDesc().get(0));
|
||||
assertEquals("0123456", person.getTelephoneNumber());
|
||||
assertThat(person.getCommonName()).isEqualTo("New Person");
|
||||
assertThat(person.getSurname()).isEqualTo("Person");
|
||||
assertThat(person.getDesc().get(0)).isEqualTo("This is the description");
|
||||
assertThat(person.getTelephoneNumber()).isEqualTo("0123456");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyThatMovedEntryGetsUpdatedId() {
|
||||
PersonWithDnAnnotations found = tested.findOne(query().where("cn").is("Some Person3"));
|
||||
assertNotNull(found);
|
||||
assertThat(found).isNotNull();
|
||||
|
||||
assertEquals(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"), found.getDn());
|
||||
assertThat(found.getDn()).isEqualTo(LdapUtils.newLdapName("cn=Some Person3,ou=company1,ou=Sweden"));
|
||||
|
||||
found.setCompany("company2");
|
||||
|
||||
tested.save(found);
|
||||
|
||||
assertEquals(LdapUtils.newLdapName("cn=Some Person3,ou=company2,ou=Sweden"), found.getDn());
|
||||
assertThat(found.getDn()).isEqualTo(LdapUtils.newLdapName("cn=Some Person3,ou=company2,ou=Sweden"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user