From af4bf0bf69dcc623887694cf13371b2341f4bb1b Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jn.rouvignac@gmail.com>
Date: Mon, 31 Aug 2015 15:58:53 +0000
Subject: [PATCH] OPENDJ-1192 Modify request replay failures
---
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalMultipleTest.java | 21 +++++++++++++++++++++
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java | 27 ++++++++++++++++++++++++---
2 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalMultipleTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalMultipleTest.java
index 8d503c4..d1b04f3 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalMultipleTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalMultipleTest.java
@@ -37,8 +37,10 @@
import java.util.List;
import java.util.Set;
+import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
+import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.CSN;
@@ -75,6 +77,17 @@
attrHist = new AttrHistoricalMultiple();
csn = csnGen.newCSN();
entry = new Entry(null, null, null, null);
+ entry = TestCaseUtils.makeEntry(
+ "dn: uid=test.user",
+ "objectClass: top",
+ "objectClass: person",
+ "objectClass: organizationalPerson",
+ "objectClass: inetOrgPerson",
+ "uid: test.user",
+ "givenName: Test",
+ "sn: User",
+ "cn: Test User",
+ "userPassword: password");
}
@AfterMethod
@@ -387,6 +400,7 @@
{
entry.applyModification(mod);
assertAttributeValues(entry, mod);
+ conformsToSchema(entry);
}
}
@@ -445,6 +459,13 @@
return results;
}
+ private void conformsToSchema(Entry entry)
+ {
+ LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
+ final boolean isValid = entry.conformsToSchema(null, false, false, false, invalidReason);
+ assertThat(isValid).as(invalidReason.toString()).isTrue();
+ }
+
private void assertNoAttributeValue(Entry entry)
{
assertAttributeValues(entry);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java
index 31d8fba..60d0279 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java
@@ -27,13 +27,16 @@
import static org.assertj.core.api.Assertions.*;
import static org.forgerock.opendj.ldap.ModificationType.*;
import static org.mockito.Mockito.*;
+import static org.opends.server.util.StaticUtils.*;
import static org.testng.Assert.*;
import java.util.Iterator;
import java.util.List;
+import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
+import org.opends.server.TestCaseUtils;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.CSN;
import org.opends.server.replication.common.CSNGenerator;
@@ -48,7 +51,7 @@
@SuppressWarnings("javadoc")
public class AttrHistoricalSingleTest extends ReplicationTestCase
{
- private static final String ATTRIBUTE_NAME = "display";
+ private static final String ATTRIBUTE_NAME = "displayName";
private static final boolean CONFLICT = true;
private static final boolean SUCCESS = false;
@@ -64,7 +67,17 @@
{
attrHist = new AttrHistoricalSingle();
csn = csnGen.newCSN();
- entry = new Entry(null, null, null, null);
+ entry = TestCaseUtils.makeEntry(
+ "dn: uid=test.user",
+ "objectClass: top",
+ "objectClass: person",
+ "objectClass: organizationalPerson",
+ "objectClass: inetOrgPerson",
+ "uid: test.user",
+ "givenName: Test",
+ "sn: User",
+ "cn: Test User",
+ "userPassword: password");
}
@AfterMethod
@@ -309,6 +322,7 @@
{
entry.applyModification(mod);
assertAttributeValue(entry, mod);
+ conformsToSchema(entry);
}
}
@@ -364,6 +378,13 @@
return null;
}
+ private void conformsToSchema(Entry entry)
+ {
+ LocalizableMessageBuilder invalidReason = new LocalizableMessageBuilder();
+ final boolean isValid = entry.conformsToSchema(null, false, false, false, invalidReason);
+ assertThat(isValid).as(invalidReason.toString()).isTrue();
+ }
+
private void assertNoAttributeValue(Entry entry)
{
assertAttributeValue(entry, (String) null);
@@ -371,7 +392,7 @@
private void assertAttributeValue(Entry entry, String expectedValue)
{
- ByteString actualValue = getActualValue(entry.getAttribute(ATTRIBUTE_NAME));
+ ByteString actualValue = getActualValue(entry.getAttribute(toLowerCase(ATTRIBUTE_NAME)));
assertEquals(actualValue, expectedValue != null ? ByteString.valueOf(expectedValue) : null);
}
--
Gitblit v1.10.0