| | |
| | | * This class defines a set of tests for the Adapters.class. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test() |
| | | @Test |
| | | public class AdaptersTestCase extends ForgeRockTestCase { |
| | | |
| | | /** |
| | |
| | | * |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSimpleLDAPConnectionFactorySimpleBind() throws LdapException { |
| | | final LDAPConnectionFactory factory = |
| | | new LDAPConnectionFactory("localhost", |
| | |
| | | * @throws GeneralSecurityException |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testLDAPSASLBind() throws NumberFormatException, GeneralSecurityException, LdapException { |
| | | LDAPConnectionFactory factory = |
| | | new LDAPConnectionFactory("localhost", |
| | |
| | | * |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSASLBindRequest() throws LdapException, |
| | | GeneralSecurityException { |
| | | final Connection connection = Adapters.newRootConnection(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSimpleBindAsRoot() throws Exception { |
| | | |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | final BindResult result = connection.bind("cn=Directory Manager", "password".toCharArray()); |
| | | assertThat(connection.isValid()).isTrue(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSimpleBindAsAUser() throws Exception { |
| | | // user |
| | | final Connection connection = |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSimpleBind() throws Exception { |
| | | // Anonymous |
| | | final Connection connection = Adapters.newAnonymousConnection(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterAddRequest() throws Exception { |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterSearchRequest() throws Exception { |
| | | |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | |
| | | final SearchRequest request = |
| | |
| | | * |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterDeleteRequest() throws LdapException { |
| | | |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | // Checks if the entry exists. |
| | | SearchResultEntry sre = |
| | |
| | | * @throws LdapException |
| | | * @throws DecodeException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterModifyRequest() throws LdapException, DecodeException { |
| | | |
| | | final ModifyRequest changeRequest = |
| | | Requests.newModifyRequest("uid=user.2, dc=example,dc=org").addControl( |
| | | PreReadRequestControl.newControl(true, "mail")).addModification( |
| | |
| | | * @throws LdapException |
| | | * @throws SearchResultReferenceIOException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testLDAPConnectionAndAdapterComparison() throws LdapException, SearchResultReferenceIOException { |
| | | // @formatter:off |
| | | final AddRequest addRequest = Requests.newAddRequest( |