From 1daf5cb96fa1ba13d2d7517ef15f9ebd44cf071f Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Fri, 09 Sep 2016 09:45:25 +0000
Subject: [PATCH] OPENDJ-3089 Fix failing tests in SchemaBackendTestCase and TestEntry
---
opendj-server-legacy/src/main/java/org/opends/server/core/SchemaHandler.java | 2 --
opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java | 13 +++----------
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java | 4 ++--
opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java | 17 ++++++++++-------
4 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
index 355a008..ab751bb 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -17,7 +17,6 @@
package org.opends.server.backends;
import static org.forgerock.opendj.ldap.schema.SchemaOptions.STRIP_UPPER_BOUND_FOR_ATTRIBUTE_TYPE;
-
import static org.forgerock.opendj.ldap.schema.CoreSchema.*;
import static org.forgerock.util.Reject.*;
import static org.opends.messages.BackendMessages.*;
@@ -69,6 +68,7 @@
import org.forgerock.opendj.ldap.schema.SchemaElement;
import org.forgerock.opendj.ldap.schema.Syntax;
import org.forgerock.opendj.server.config.server.SchemaBackendCfg;
+import org.forgerock.util.Reject;
import org.opends.server.api.AlertGenerator;
import org.opends.server.api.Backend;
import org.opends.server.api.Backupable;
@@ -168,6 +168,7 @@
@Override
public void configureBackend(SchemaBackendCfg cfg, ServerContext serverContext) throws ConfigException
{
+ Reject.ifNull(serverContext);
this.serverContext = serverContext;
this.schemaHandler = serverContext.getSchemaHandler();
@@ -177,7 +178,6 @@
{
throw new ConfigException(ERR_SCHEMA_CONFIG_ENTRY_NULL.get());
}
-
Entry configEntry = DirectoryServer.getConfigEntry(cfg.dn());
configEntryDN = configEntry.getName();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaHandler.java
index b6cce94..a4058f8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/SchemaHandler.java
@@ -87,7 +87,6 @@
import org.opends.server.types.InitializationException;
import org.opends.server.types.Modification;
import org.opends.server.types.SchemaWriter;
-import org.opends.server.util.ActivateOnceSDKSchemaIsUsed;
import org.opends.server.util.SchemaUtils;
import org.opends.server.util.StaticUtils;
@@ -103,7 +102,6 @@
* <li>Load all schema files located in the schema directory.</li>
* </ul>
*/
-@ActivateOnceSDKSchemaIsUsed
public final class SchemaHandler
{
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
index aa971b1..7ab9666 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaBackendTestCase.java
@@ -49,6 +49,7 @@
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.server.config.server.SchemaBackendCfg;
import org.forgerock.util.Utils;
+import org.opends.server.ServerContextBuilder;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperationBasis;
@@ -64,7 +65,6 @@
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
-import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.LDIFImportResult;
@@ -117,13 +117,16 @@
*
* @throws Exception If an unexpected problem occurs.
*/
- @Test(expectedExceptions = { ConfigException.class,
- InitializationException.class })
- public void testInitializeWithNullEntry()
- throws Exception
+ @Test(expectedExceptions = { ConfigException.class})
+ public void testInitializeWithNullConfigEntry() throws Exception
{
- SchemaBackend schemaBackend = new SchemaBackend();
- schemaBackend.configureBackend(null, null);
+ new SchemaBackend().configureBackend(null, ServerContextBuilder.aServerContext().build());
+ }
+
+ @Test(expectedExceptions = { NullPointerException.class })
+ public void testInitializeWithNullParams() throws Exception
+ {
+ new SchemaBackend().configureBackend(null, null);
}
/**
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java b/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java
index caf5f3b..f98441a 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/types/TestEntry.java
@@ -38,10 +38,9 @@
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.ObjectClass;
-import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+import org.forgerock.opendj.ldap.schema.Schema;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.SchemaHandler;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -205,14 +204,8 @@
@Test
public void testParseAttributesSubtreeSpecification()
throws Exception {
- // Define a dummy attribute type, in case there is not one already
- // in the core schema.
- String string = "( 2.5.18.6 NAME 'subtreeSpecification' "
- + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 )";
-
- SchemaHandler schemaHandler = DirectoryServer.getInstance().getServerContext().getSchemaHandler();
- SchemaBuilder builder = new SchemaBuilder(schemaHandler.getSchema());
- AttributeType type = builder.addAttributeType(string, false).toSchema().getAttributeType("2.5.18.6");
+ Schema schema = DirectoryServer.getInstance().getServerContext().getSchema();
+ AttributeType type = schema.getAttributeType("2.5.18.6");
// Test values.
String[] values = new String[] { "{ }",
--
Gitblit v1.10.0