Use this. Prefix in Integration Tests Ad

Issue gh-743
This commit is contained in:
Josh Cummings
2023-05-09 16:07:58 -06:00
parent 47e7e194c9
commit 2b3c181a14
2 changed files with 41 additions and 41 deletions

View File

@@ -89,7 +89,7 @@ public class IncrementalAttributeMapperITests extends AbstractJUnit4SpringContex
ctx.addAttributeValue("member", buildUserRefDn("test" + i));
}
ldapTemplate.bind(ctx);
this.ldapTemplate.bind(ctx);
}
private String buildUserRefDn(String username) {
@@ -118,7 +118,7 @@ public class IncrementalAttributeMapperITests extends AbstractJUnit4SpringContex
String newQuotedPassword = "\"" + DEFAULT_PASSWORD + "\"";
ctx.setAttributeValue("unicodePwd", newQuotedPassword.getBytes("UTF-16LE"));
ldapTemplate.bind(ctx);
this.ldapTemplate.bind(ctx);
}
private void createOu() {
@@ -130,13 +130,13 @@ public class IncrementalAttributeMapperITests extends AbstractJUnit4SpringContex
ctx.setAttributeValue("ou", "dummy");
ctx.setAttributeValue("description", "dummy description");
ldapTemplate.bind(ctx);
this.ldapTemplate.bind(ctx);
}
@After
public void cleanup() {
try {
ldapTemplate.lookup(OU_DN);
this.ldapTemplate.lookup(OU_DN);
}
catch (NameNotFoundException e) {
// Nothing to cleanup
@@ -145,7 +145,7 @@ public class IncrementalAttributeMapperITests extends AbstractJUnit4SpringContex
while (true) {
try {
ldapTemplate.unbind(OU_DN, true);
this.ldapTemplate.unbind(OU_DN, true);
// Everything is deleted
return;
}
@@ -161,7 +161,7 @@ public class IncrementalAttributeMapperITests extends AbstractJUnit4SpringContex
// The 'member' attribute consists of > 1500 entries and will not be returned
// without range specifier.
DirContextOperations ctx = ldapTemplate.lookupContext(testgroupDn);
DirContextOperations ctx = this.ldapTemplate.lookupContext(testgroupDn);
assertThat(ctx.getStringAttribute("member")).isNull();
DefaultIncrementalAttributesMapper attributeMapper = new DefaultIncrementalAttributesMapper(
@@ -175,7 +175,7 @@ public class IncrementalAttributeMapperITests extends AbstractJUnit4SpringContex
// First iteration - there should now be more members left, but all cn values
// should have been collected.
ldapTemplate.lookup(testgroupDn, attributesArray, attributeMapper);
this.ldapTemplate.lookup(testgroupDn, attributesArray, attributeMapper);
assertThat(attributeMapper.hasMore()).as("There should be more results to get").isTrue();
// Only member attribute should be requested in this query.
@@ -184,7 +184,7 @@ public class IncrementalAttributeMapperITests extends AbstractJUnit4SpringContex
assertThat(attributesArray[0]).isEqualTo("member;Range=1500-*");
// Second iteration - all data should now have been collected.
ldapTemplate.lookup(testgroupDn, attributeMapper.getAttributesForLookup(), attributeMapper);
this.ldapTemplate.lookup(testgroupDn, attributeMapper.getAttributesForLookup(), attributeMapper);
assertThat(attributeMapper.hasMore()).as("There should be no more results to get").isFalse();
List memberValues = attributeMapper.getValues("member");
@@ -198,7 +198,7 @@ public class IncrementalAttributeMapperITests extends AbstractJUnit4SpringContex
@Test
public void jiraLdap234ITest() {
TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
TransactionTemplate transactionTemplate = new TransactionTemplate(this.transactionManager);
try {
transactionTemplate.execute(new TransactionCallback<Object>() {
@@ -206,7 +206,8 @@ public class IncrementalAttributeMapperITests extends AbstractJUnit4SpringContex
public Object doInTransaction(TransactionStatus status) {
ModificationItem modificationItem = new ModificationItem(DirContext.ADD_ATTRIBUTE,
new BasicAttribute("member", buildUserRefDn("test" + 1501)));
ldapTemplate.modifyAttributes(GROUP_DN, new ModificationItem[] { modificationItem });
IncrementalAttributeMapperITests.this.ldapTemplate.modifyAttributes(GROUP_DN,
new ModificationItem[] { modificationItem });
// The below should cause a rollback
throw new RuntimeException("Simulate some failure");
@@ -219,13 +220,12 @@ public class IncrementalAttributeMapperITests extends AbstractJUnit4SpringContex
DefaultIncrementalAttributesMapper attributeMapper = new DefaultIncrementalAttributesMapper(
new String[] { "member" });
while (attributeMapper.hasMore()) {
ldapTemplate.lookup(GROUP_DN, attributeMapper.getAttributesForLookup(), attributeMapper);
this.ldapTemplate.lookup(GROUP_DN, attributeMapper.getAttributesForLookup(), attributeMapper);
}
// LDAP-234: After rollback the attribute values were cleared after rollback
assertThat(
DefaultIncrementalAttributesMapper.lookupAttributeValues(ldapTemplate, GROUP_DN, "member").size())
.isEqualTo(1501);
assertThat(DefaultIncrementalAttributesMapper.lookupAttributeValues(this.ldapTemplate, GROUP_DN, "member")
.size()).isEqualTo(1501);
}
}

View File

@@ -70,43 +70,43 @@ public final class SchemaToJavaAdITests {
@Before
public void setUp() throws Exception {
// Create some basic converters and a converter manager
converterManager = new ConverterManagerImpl();
this.converterManager = new ConverterManagerImpl();
Converter ptc = new FromStringConverter();
converterManager.addConverter(String.class, "", Byte.class, ptc);
converterManager.addConverter(String.class, "", Short.class, ptc);
converterManager.addConverter(String.class, "", Integer.class, ptc);
converterManager.addConverter(String.class, "", Long.class, ptc);
converterManager.addConverter(String.class, "", Double.class, ptc);
converterManager.addConverter(String.class, "", Float.class, ptc);
converterManager.addConverter(String.class, "", Boolean.class, ptc);
this.converterManager.addConverter(String.class, "", Byte.class, ptc);
this.converterManager.addConverter(String.class, "", Short.class, ptc);
this.converterManager.addConverter(String.class, "", Integer.class, ptc);
this.converterManager.addConverter(String.class, "", Long.class, ptc);
this.converterManager.addConverter(String.class, "", Double.class, ptc);
this.converterManager.addConverter(String.class, "", Float.class, ptc);
this.converterManager.addConverter(String.class, "", Boolean.class, ptc);
Converter tsc = new ToStringConverter();
converterManager.addConverter(Byte.class, "", String.class, tsc);
converterManager.addConverter(Short.class, "", String.class, tsc);
converterManager.addConverter(Integer.class, "", String.class, tsc);
converterManager.addConverter(Long.class, "", String.class, tsc);
converterManager.addConverter(Double.class, "", String.class, tsc);
converterManager.addConverter(Float.class, "", String.class, tsc);
converterManager.addConverter(Boolean.class, "", String.class, tsc);
this.converterManager.addConverter(Byte.class, "", String.class, tsc);
this.converterManager.addConverter(Short.class, "", String.class, tsc);
this.converterManager.addConverter(Integer.class, "", String.class, tsc);
this.converterManager.addConverter(Long.class, "", String.class, tsc);
this.converterManager.addConverter(Double.class, "", String.class, tsc);
this.converterManager.addConverter(Float.class, "", String.class, tsc);
this.converterManager.addConverter(Boolean.class, "", String.class, tsc);
// Bind to the directory
contextSource = new LdapContextSource();
contextSource.setUrl("ldaps://127.0.0.1:" + port);
contextSource.setUserDn(USER_DN);
contextSource.setPassword(PASSWORD);
contextSource.setPooled(false);
contextSource.setBase("dc=261consulting,dc=local");
this.contextSource = new LdapContextSource();
this.contextSource.setUrl("ldaps://127.0.0.1:" + port);
this.contextSource.setUserDn(USER_DN);
this.contextSource.setPassword(PASSWORD);
this.contextSource.setPooled(false);
this.contextSource.setBase("dc=261consulting,dc=local");
HashMap<String, Object> baseEnvironment = new HashMap<String, Object>() {
{
put("java.naming.ldap.attributes.binary",
"thumbnailLogo replPropertyMetaData partialAttributeSet registeredAddress userPassword telexNumber partialAttributeDeletionList mS-DS-ConsistencyGuid attributeCertificateAttribute thumbnailPhoto teletexTerminalIdentifier replUpToDateVector dSASignature objectGUID");
}
};
contextSource.setBaseEnvironmentProperties(baseEnvironment);
contextSource.afterPropertiesSet();
this.contextSource.setBaseEnvironmentProperties(baseEnvironment);
this.contextSource.afterPropertiesSet();
ldapTemplate = new LdapTemplate(contextSource);
this.ldapTemplate = new LdapTemplate(this.contextSource);
cleanup();
@@ -119,12 +119,12 @@ public final class SchemaToJavaAdITests {
ctx.addAttributeValue("sn", "Hartnell");
ctx.addAttributeValue("telephonenumber", "1");
ldapTemplate.bind(ctx);
this.ldapTemplate.bind(ctx);
}
@After
public void cleanup() {
ldapTemplate.unbind("cn=William Hartnell,cn=Users");
this.ldapTemplate.unbind("cn=William Hartnell,cn=Users");
}
// Figure out the path of the created Java file
@@ -183,7 +183,7 @@ public final class SchemaToJavaAdITests {
Class<?> clazz = ucl.loadClass(packageName + "." + className);
// Create our OdmManager using our new class
OdmManagerImpl odmManager = new OdmManagerImpl(converterManager, contextSource);
OdmManagerImpl odmManager = new OdmManagerImpl(this.converterManager, this.contextSource);
odmManager.addManagedClass(clazz);
// And try reading from the directory using it