use of com.unboundid.ldap.sdk.examples.LDAPSearch in project ldapsdk by pingidentity.
the class LDAPCommandLineToolTestCase method testPropertiesFilePathWithNoPropertiesFile.
/**
* Tests the behavior when both the propertiesFilePath and noPropertiesFile
* arguments are specified.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testPropertiesFilePathWithNoPropertiesFile() throws Exception {
final InMemoryDirectoryServer ds = getTestDS();
final LDAPSearch ldapSearch = new LDAPSearch(null, null);
final File propertiesFile = createTempFile();
final ResultCode rc = ldapSearch.runTool("--propertiesFilePath", propertiesFile.getAbsolutePath(), "--noPropertiesFile", "-h", "127.0.0.1", "-p", String.valueOf(ds.getListenPort()), "-D", "cn=Directory Manager", "-w", "password", "--baseDN", "", "--scope", "base", "(objectClass=*)");
assertFalse(rc == ResultCode.SUCCESS);
}
use of com.unboundid.ldap.sdk.examples.LDAPSearch in project ldapsdk by pingidentity.
the class LDAPCommandLineToolTestCase method testPropertiesFilePathWithGeneratePropertiesFile.
/**
* Tests the behavior when both the propertiesFilePath and
* generatePropertiesFile arguments are specified.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testPropertiesFilePathWithGeneratePropertiesFile() throws Exception {
final InMemoryDirectoryServer ds = getTestDS();
final LDAPSearch ldapSearch = new LDAPSearch(null, null);
final File f1 = createTempFile();
final File f2 = createTempFile();
assertTrue(f2.delete());
final ResultCode rc = ldapSearch.runTool("--propertiesFilePath", f1.getAbsolutePath(), "--generatePropertiesFile", f2.getAbsolutePath(), "-h", "127.0.0.1", "-p", String.valueOf(ds.getListenPort()), "-D", "cn=Directory Manager", "-w", "password", "--baseDN", "", "--scope", "base", "(objectClass=*)");
assertFalse(rc == ResultCode.SUCCESS);
}
use of com.unboundid.ldap.sdk.examples.LDAPSearch in project ldapsdk by pingidentity.
the class LDAPCommandLineToolTestCase method testUseSASLExternalFailure.
/**
* Provides a test that uses the useSASLExternal argument in a manner that
* cannot succeed.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testUseSASLExternalFailure() throws Exception {
LDAPSearch ldapSearch = new LDAPSearch(null, null);
ResultCode rc = ldapSearch.runTool("-h", getTestHost(), "-p", String.valueOf(getTestPort()), "--useSASLExternal", "-b", "", "-s", "base", "(objectClass=*)");
assertFalse(rc == ResultCode.SUCCESS);
}
use of com.unboundid.ldap.sdk.examples.LDAPSearch in project ldapsdk by pingidentity.
the class LDAPCommandLineToolTestCase method testPropertiesFileUnexpectedInitialWhitespace.
/**
* Tests the behavior with a properties file that has a line that starts with
* whitespace when no continuation was expected.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testPropertiesFileUnexpectedInitialWhitespace() throws Exception {
final InMemoryDirectoryServer ds = getTestDS();
final File propertiesFile = createTempFile("# The hostname", "hostname=127.0.0.1", "", "# The port", " port=" + ds.getListenPort());
final LDAPSearch ldapSearch = new LDAPSearch(null, null);
final ResultCode rc = ldapSearch.runTool("--propertiesFilePath", propertiesFile.getAbsolutePath(), "--baseDN", "", "(objectClass=*)");
assertFalse(rc == ResultCode.SUCCESS);
}
use of com.unboundid.ldap.sdk.examples.LDAPSearch in project ldapsdk by pingidentity.
the class LDAPCommandLineToolTestCase method testPropertiesFileSpecifiedByJavaProperty.
/**
* Tests the behavior when trying to generate a properties file when values
* are provided for a number of arguments, and then verify the ability to use
* that properties file to actually run the tool when the properties file is
* inferred via a system property rather than a command-line argument.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testPropertiesFileSpecifiedByJavaProperty() throws Exception {
final InMemoryDirectoryServer ds = getTestDSWithSSL();
LDAPSearch ldapSearch = new LDAPSearch(null, null);
final File propertiesFile = createTempFile();
assertTrue(propertiesFile.exists());
assertTrue(propertiesFile.delete());
assertFalse(propertiesFile.exists());
ResultCode rc = ldapSearch.runTool("--generatePropertiesFile", propertiesFile.getAbsolutePath(), "-h", "127.0.0.1", "-p", String.valueOf(ds.getListenPort()), "-Z", "-X", "-D", "cn=Directory Manager", "-w", "password");
assertEquals(rc, ResultCode.SUCCESS);
assertTrue(propertiesFile.exists());
assertTrue(propertiesFile.length() > 0);
assertFileHasLine(propertiesFile, "# ldapsearch.hostname={host}");
assertFileHasLine(propertiesFile, "# ldapsearch.port={port}");
assertFileHasLine(propertiesFile, "# ldapsearch.bindDN={dn}");
assertFileHasLine(propertiesFile, "# ldapsearch.bindPassword={password}");
assertFileHasLine(propertiesFile, "ldapsearch.hostname=127.0.0.1");
assertFileHasLine(propertiesFile, "ldapsearch.port=" + ds.getListenPort());
assertFileHasLine(propertiesFile, "ldapsearch.bindDN=cn=Directory Manager");
assertFileHasLine(propertiesFile, "ldapsearch.bindPassword=password");
System.setProperty(ArgumentParser.PROPERTY_DEFAULT_PROPERTIES_FILE_PATH, propertiesFile.getAbsolutePath());
ldapSearch = new LDAPSearch(null, null);
rc = ldapSearch.runTool("--baseDN", "", "--scope", "base", "(objectClass=*)");
assertEquals(rc, ResultCode.SUCCESS);
System.clearProperty(ArgumentParser.PROPERTY_DEFAULT_PROPERTIES_FILE_PATH);
}
Aggregations