Java Code Examples for org.springframework.ldap.test.LdapTestUtils#startEmbeddedServer()

The following examples show how to use org.springframework.ldap.test.LdapTestUtils#startEmbeddedServer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseDAOTest.java    From geofence with GNU General Public License v2.0 5 votes vote down vote up
@BeforeClass
    public static void setUpClass() throws Exception
    {
        // Start an LDAP server and import test data
//        LdapTestUtils.startEmbeddedServer(10389, "", "test");
//        LdapTestUtils.startEmbeddedServer(10389, "dc=example,dc=com", "test");
        LdapTestUtils.startEmbeddedServer(10389, "dc=com", "test");
        loadData();
    }
 
Example 2
Source File: TestSchemaViewer.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpClass() throws Exception {
    // Added because the close down of Apache DS on Linux does
    // not seem to free up its port.
    port=GetFreePort.getFreePort();
    
    commonFlags=new String[] { 
            "--url", "ldap://127.0.0.1:"+port,
            "--username", "",
            "--password", "",
            "--error"};
    
    // Start an in process LDAP server
    LdapTestUtils.startEmbeddedServer(port, baseName.toString(), "odm-test");
}
 
Example 3
Source File: TestSchemaToJava.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpClass() throws Exception {
    // Added because the close down of Apache DS on Linux does
    // not seem to free up its port.
    port=GetFreePort.getFreePort();

    // Start an in process LDAP server
    LdapTestUtils.startEmbeddedServer(port, baseName.toString(), "odm-test");
}
 
Example 4
Source File: TestLdap.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpClass() throws Exception {
    // Added because the close down of Apache DS on Linux does
    // not seem to free up its port.
    port=GetFreePort.getFreePort();

    // Start an LDAP server and import test data
    LdapTestUtils.startEmbeddedServer(port, baseName.toString(), "odm-test");
}
 
Example 5
Source File: LdapTemplatePooledITest.java    From spring-ldap with Apache License 2.0 5 votes vote down vote up
/**
 * 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");
   }