From f2711b53bdd5f48eaf312981541b61c6e89bdfa1 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 29 Mar 2013 18:06:19 +0000
Subject: [PATCH] Additional change for OPENDJ-354: Implement a RequestHandler which provides an in-memory backend
---
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/MemoryBackendTestCase.java | 99 ++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 80 insertions(+), 19 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/MemoryBackendTestCase.java b/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/MemoryBackendTestCase.java
index c695030..cdb7204 100644
--- a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/MemoryBackendTestCase.java
+++ b/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/MemoryBackendTestCase.java
@@ -221,20 +221,6 @@
}
@Test
- public void testModifyBindPostRead() throws Exception {
- final Connection connection = getConnection();
- assertThat(
- connection.modify(
- newModifyRequest("dn: dc=example,dc=com", "changetype: modify",
- "add: description", "description: test description").addControl(
- PostReadRequestControl.newControl(true))).getControl(
- PostReadResponseControl.DECODER, new DecodeOptions()).getEntry())
- .isEqualTo(
- valueOfLDIFEntry("dn: dc=example,dc=com", "objectClass: domain",
- "objectClass: top", "dc: example", "description: test description"));
- }
-
- @Test
public void testModifyIncrement() throws Exception {
final Connection connection = getConnection();
connection.modify("dn: dc=example,dc=com", "changetype: modify", "add: integer",
@@ -288,16 +274,45 @@
}
@Test
- public void testModifyPreRead() throws Exception {
+ public void testModifyPostRead() throws Exception {
final Connection connection = getConnection();
assertThat(
connection.modify(
newModifyRequest("dn: dc=example,dc=com", "changetype: modify",
"add: description", "description: test description").addControl(
- PreReadRequestControl.newControl(true))).getControl(
- PreReadResponseControl.DECODER, new DecodeOptions()).getEntry()).isEqualTo(
- valueOfLDIFEntry("dn: dc=example,dc=com", "objectClass: domain",
- "objectClass: top", "dc: example"));
+ PostReadRequestControl.newControl(true))).getControl(
+ PostReadResponseControl.DECODER, new DecodeOptions()).getEntry())
+ .isEqualTo(
+ valueOfLDIFEntry("dn: dc=example,dc=com", "objectClass: domain",
+ "objectClass: top", "dc: example", "description: test description"));
+ }
+
+ @Test
+ public void testModifyPostReadAttributesSelected() throws Exception {
+ final Connection connection = getConnection();
+ assertThat(
+ connection.modify(
+ newModifyRequest("dn: dc=example,dc=com", "changetype: modify",
+ "add: description", "description: test description").addControl(
+ PostReadRequestControl.newControl(true, "dc", "entryDN")))
+ .getControl(PostReadResponseControl.DECODER, new DecodeOptions())
+ .getEntry()).isEqualTo(
+ valueOfLDIFEntry("dn: dc=example,dc=com", "dc: example",
+ "entryDN: dc=example,dc=com"));
+ }
+
+ @Test
+ public void testModifyPreReadAttributesSelected() throws Exception {
+ final Connection connection = getConnection();
+ assertThat(
+ connection.modify(
+ newModifyRequest("dn: dc=example,dc=com", "changetype: modify",
+ "add: description", "description: test description").addControl(
+ PreReadRequestControl.newControl(true, "dc", "entryDN")))
+ .getControl(PreReadResponseControl.DECODER, new DecodeOptions()).getEntry())
+ .isEqualTo(
+ valueOfLDIFEntry("dn: dc=example,dc=com", "dc: example",
+ "entryDN: dc=example,dc=com"));
}
@Test(expectedExceptions = ConstraintViolationException.class)
@@ -313,6 +328,48 @@
}
@Test
+ public void testSearchAttributesOperational() throws Exception {
+ final Connection connection = getConnection();
+ assertThat(connection.readEntry("uid=test1,ou=People,dc=example,dc=com", "+")).isEqualTo(
+ valueOfLDIFEntry("dn: uid=test1,ou=People,dc=example,dc=com",
+ "entryDN: uid=test1,ou=people,dc=example,dc=com",
+ "entryUUID: fc252fd9-b982-3ed6-b42a-c76d2546312c"));
+ }
+
+ @Test
+ public void testSearchAttributesSelected() throws Exception {
+ final Connection connection = getConnection();
+ assertThat(connection.readEntry("uid=test1,ou=People,dc=example,dc=com", "uid", "entryDN"))
+ .isEqualTo(
+ valueOfLDIFEntry("dn: uid=test1,ou=People,dc=example,dc=com", "uid: test1",
+ "entryDN: uid=test1,ou=People,dc=example,dc=com"));
+ }
+
+ @Test
+ public void testSearchAttributesRenamed() throws Exception {
+ final Connection connection = getConnection();
+ final Entry entry =
+ connection.readEntry("uid=test1,ou=People,dc=example,dc=com", "commonName",
+ "ENTRYDN");
+ assertThat(entry)
+ .isEqualTo(
+ valueOfLDIFEntry("dn: uid=test1,ou=People,dc=example,dc=com",
+ "commonName: test user 1",
+ "ENTRYDN: uid=test1,ou=People,dc=example,dc=com"));
+ assertThat(entry.getAttribute("cn").getAttributeDescriptionAsString()).isEqualTo(
+ "commonName");
+ assertThat(entry.getAttribute("entryDN").getAttributeDescriptionAsString()).isEqualTo(
+ "ENTRYDN");
+ }
+
+ @Test
+ public void testSearchAttributesUser() throws Exception {
+ final Connection connection = getConnection();
+ assertThat(connection.readEntry("uid=test1,ou=People,dc=example,dc=com", "*")).isEqualTo(
+ getUser1Entry());
+ }
+
+ @Test
public void testSearchBase() throws Exception {
final Connection connection = getConnection();
assertThat(connection.readEntry("dc=example,dc=com")).isEqualTo(
@@ -410,6 +467,8 @@
"objectClass: domain",
"objectClass: top",
"dc: example",
+ "entryDN: dc=example,dc=com",
+ "entryUUID: fc252fd9-b982-3ed6-b42a-c76d2546312c",
"",
"dn: ou=People,dc=example,dc=com",
"objectClass: organizationalunit",
@@ -423,6 +482,8 @@
"userpassword: password",
"cn: test user 1",
"sn: user 1",
+ "entryDN: uid=test1,ou=people,dc=example,dc=com",
+ "entryUUID: fc252fd9-b982-3ed6-b42a-c76d2546312c",
"",
"dn: uid=test2,ou=People,dc=example,dc=com",
"objectClass: top",
--
Gitblit v1.10.0