本文整理汇总了Java中org.springframework.ldap.test.LdapTestUtils.cleanAndSetup方法的典型用法代码示例。如果您正苦于以下问题:Java LdapTestUtils.cleanAndSetup方法的具体用法?Java LdapTestUtils.cleanAndSetup怎么用?Java LdapTestUtils.cleanAndSetup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.ldap.test.LdapTestUtils
的用法示例。
在下文中一共展示了LdapTestUtils.cleanAndSetup方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startLDAPServer
import org.springframework.ldap.test.LdapTestUtils; //导入方法依赖的package包/类
@BeforeClass
public static void startLDAPServer() throws Exception {
LdapTestUtils.startApacheDirectoryServer(PORT, baseName.toString(), "test", PRINCIPAL, CREDENTIALS, null);
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://127.0.0.1:" + PORT);
contextSource.setUserDn("");
contextSource.setPassword("");
contextSource.setPooled(false);
contextSource.afterPropertiesSet();
// Create the Sprint LDAP template
LdapTemplate template = new LdapTemplate(contextSource);
// Clear out any old data - and load the test data
LdapTestUtils.cleanAndSetup(template.getContextSource(), baseName, new ClassPathResource("ldap/testdata.ldif"));
System.out.println("____________Started LDAP_________");
}
示例2: buildDB
import org.springframework.ldap.test.LdapTestUtils; //导入方法依赖的package包/类
@Before @Override
public void buildDB() throws Exception {
super.buildDB ();
// Bind to the LDAP directory:
final LdapContextSource contextSource = new LdapContextSource ();
contextSource.setUrl ("ldap://127.0.0.1:" + PORT + "/dc=inspire,dc=idgis,dc=eu");
contextSource.setUserDn (PRINCIPAL);
contextSource.setPassword (CREDENTIALS);
contextSource.setPooled (false);
contextSource.afterPropertiesSet ();
// Create an LDAP template:
ldapTemplate = new LdapTemplate (contextSource);
LdapTestUtils.cleanAndSetup (ldapTemplate.getContextSource (), new DistinguishedName (), new ClassPathResource ("nl/ipo/cds/dao/testdata.ldif"));
((ManagerDaoImpl)managerDao).setLdapTemplate (ldapTemplate);
entityManager.flush ();
}
示例3: cleanAndSetup
import org.springframework.ldap.test.LdapTestUtils; //导入方法依赖的package包/类
@Before
public void cleanAndSetup() throws NamingException, IOException {
Resource ldifResource = getLdifFileResource();
if(!LdapUtils.newLdapName(base).equals(LdapUtils.newLdapName(DEFAULT_BASE))) {
List<String> lines = IOUtils.readLines(ldifResource.getInputStream());
StringWriter sw = new StringWriter();
PrintWriter writer = new PrintWriter(sw);
for (String line : lines) {
writer.println(StringUtils.replace(line, DEFAULT_BASE, base));
}
writer.flush();
ldifResource = new ByteArrayResource(sw.toString().getBytes("UTF8"));
}
LdapTestUtils.cleanAndSetup(contextSource, getRoot(), ldifResource);
}
示例4: setUp
import org.springframework.ldap.test.LdapTestUtils; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
// Create some basic converters and a converter manager
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);
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);
// Bind to the directory
contextSource = new LdapContextSource();
contextSource.setUrl("ldap://127.0.0.1:" + port);
contextSource.setUserDn("");
contextSource.setPassword("");
contextSource.setPooled(false);
contextSource.afterPropertiesSet();
// Clear out any old data - and load the test data
LdapTestUtils.cleanAndSetup(contextSource, baseName, new ClassPathResource("testdata.ldif"));
}
示例5: setUp
import org.springframework.ldap.test.LdapTestUtils; //导入方法依赖的package包/类
public void setUp(String url, String username, String password) throws Exception {
// Create some basic converters and a converter manager
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);
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);
// Bind to the directory
contextSource = getContextSource(url, username, password);
// Clear out any old data - and load the test data
LdapTestUtils.cleanAndSetup(contextSource, baseName, new ClassPathResource("testdata.ldif"));
// Create our OdmManager
Set<Class<?>> managedClasses=new HashSet<Class<?>>();
managedClasses.add(Person.class);
managedClasses.add(PlainPerson.class);
managedClasses.add(OrganizationalUnit.class);
odmManager = new OdmManagerImpl(converterManager, contextSource, managedClasses);
}
示例6: verifyThatInvalidConnectionIsAutomaticallyPurged
import org.springframework.ldap.test.LdapTestUtils; //导入方法依赖的package包/类
/**
* This method depends on a DirObjectFactory (
* {@link org.springframework.ldap.core.support.DefaultDirObjectFactory})
* being set in the ContextSource.
*/
@Test
public void verifyThatInvalidConnectionIsAutomaticallyPurged() throws Exception {
LdapTestUtils.startEmbeddedServer(1888, "dc=261consulting,dc=com", "jayway");
LdapTestUtils.cleanAndSetup(contextSource, LdapUtils.emptyLdapName(), new ClassPathResource("/setup_data.ldif"));
DirContextOperations result = tested.lookupContext("cn=Some Person2, ou=company1,ou=Sweden");
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();
LdapTestUtils.startEmbeddedServer(1888, "dc=261consulting,dc=com", "jayway");
try {
tested.lookup("cn=Some Person2, ou=company1,ou=Sweden");
fail("Exception expected");
} catch (Exception expected) {
// This should fail because the target connection was closed
assertThat(true).isTrue();
}
LdapTestUtils.cleanAndSetup(contextSource, LdapUtils.emptyLdapName(), new ClassPathResource("/setup_data.ldif"));
// But this should be OK, because the dirty connection should have been automatically purged.
tested.lookup("cn=Some Person2, ou=company1,ou=Sweden");
}
示例7: prepareTestedData
import org.springframework.ldap.test.LdapTestUtils; //导入方法依赖的package包/类
@Before
public void prepareTestedData() throws IOException, NamingException {
LdapTestUtils.cleanAndSetup(
contextSource,
LdapUtils.newLdapName("ou=People"),
new ClassPathResource("/setup_data.ldif"));
}
示例8: prepareTestedInstance
import org.springframework.ldap.test.LdapTestUtils; //导入方法依赖的package包/类
@Before
public void prepareTestedInstance() throws Exception {
LdapTestUtils.cleanAndSetup(
contextSource,
LdapUtils.newLdapName("ou=People"),
new ClassPathResource("/setup_data.ldif"));
}
示例9: prepareTestedInstance
import org.springframework.ldap.test.LdapTestUtils; //导入方法依赖的package包/类
@Before
public void prepareTestedInstance() throws Exception {
LdapTestUtils.cleanAndSetup(
contextSource,
LdapUtils.newLdapName("ou=People"),
new ClassPathResource("/setup_data.ldif"));
attributesMapper = new AttributeCheckAttributesMapper();
contextMapper = new AttributeCheckContextMapper();
}