From 82071bddff5fae0935749b4012f2c62c92b11085 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 21 Aug 2014 09:17:57 +0000
Subject: [PATCH] Preparatory work for OPENDJ-1477: Constant re-allocation of DN per-schema caches

---
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSchemaElementTestCase.java         |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/OrderingMatchingRuleTest.java              |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java                       |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java                |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CoreSchemaTest.java                        |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java             |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SyntaxTestCase.java                        |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImplTest.java |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxTest.java                 |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NameFormTestCase.java                      |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSchemaTestCase.java                |   37 ++++++++++++++++++
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ApproximateMatchingRuleTest.java           |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTestCase.java                  |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaTestCase.java                        |   28 +++++++++++---
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImplTest.java  |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java                 |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTest.java                      |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java           |    2 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaCompatTest.java                      |    2 
 19 files changed, 76 insertions(+), 23 deletions(-)

diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSchemaElementTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSchemaElementTestCase.java
index c611d3c..10e4dfe 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSchemaElementTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSchemaElementTestCase.java
@@ -39,7 +39,7 @@
  * Abstract schema element tests.
  */
 @SuppressWarnings("javadoc")
-public abstract class AbstractSchemaElementTestCase extends SchemaTestCase {
+public abstract class AbstractSchemaElementTestCase extends AbstractSchemaTestCase {
     protected static final Map<String, List<String>> EMPTY_PROPS = Collections.emptyMap();
     protected static final List<String> EMPTY_NAMES = Collections.emptyList();
 
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSchemaTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSchemaTestCase.java
new file mode 100644
index 0000000..9f9a833
--- /dev/null
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSchemaTestCase.java
@@ -0,0 +1,37 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
+ * or http://forgerock.org/license/CDDLv1.0.html.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at legal-notices/CDDLv1_0.txt.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2009 Sun Microsystems, Inc.
+ *      Portions copyright 2012 ForgeRock AS.
+ */
+package org.forgerock.opendj.ldap.schema;
+
+import org.forgerock.testng.ForgeRockTestCase;
+import org.testng.annotations.Test;
+
+/**
+ * An abstract class that all schema unit test should extend.
+ */
+@Test(groups = { "precommit", "schema", "sdk" })
+public abstract class AbstractSchemaTestCase extends ForgeRockTestCase {
+}
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImplTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImplTest.java
index a13ec2f..492a3e8 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImplTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImplTest.java
@@ -50,7 +50,7 @@
  * Tests all generic code of AbstractSubstringMatchingRuleImpl.
  */
 @SuppressWarnings("javadoc")
-public class AbstractSubstringMatchingRuleImplTest extends SchemaTestCase {
+public class AbstractSubstringMatchingRuleImplTest extends AbstractSchemaTestCase {
 
     private static class FakeSubstringMatchingRuleImpl extends AbstractSubstringMatchingRuleImpl {
 
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java
index fce95d5..f77cbe8 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java
@@ -38,7 +38,7 @@
  * Syntax tests.
  */
 @SuppressWarnings("javadoc")
-public abstract class AbstractSyntaxTestCase extends SchemaTestCase {
+public abstract class AbstractSyntaxTestCase extends AbstractSchemaTestCase {
     /**
      * Create data for the testAcceptableValues test. This should be a table of
      * tables with 2 elements. The first one should be the value to test, the
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ApproximateMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ApproximateMatchingRuleTest.java
index 1dbb0a3..a58cc0c 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ApproximateMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/ApproximateMatchingRuleTest.java
@@ -37,7 +37,7 @@
  * Approximate matching rule tests.
  */
 @SuppressWarnings("javadoc")
-public class ApproximateMatchingRuleTest extends SchemaTestCase {
+public class ApproximateMatchingRuleTest extends AbstractSchemaTestCase {
     MatchingRule metaphone = Schema.getCoreSchema().getMatchingRule(AMR_DOUBLE_METAPHONE_NAME);
 
     /**
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImplTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImplTest.java
index 790222b..ac49dd8 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImplTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImplTest.java
@@ -39,7 +39,7 @@
  * This class tests the certificateExactMatch matching rule.
  */
 @SuppressWarnings("javadoc")
-public class CertificateExactMatchingRuleImplTest extends SchemaTestCase {
+public class CertificateExactMatchingRuleImplTest extends AbstractSchemaTestCase {
 
     /**
      * Generate data for the certificateExactMatch matching rule test.
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxTest.java
index e89028c..b0b3b72 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateSyntaxTest.java
@@ -38,7 +38,7 @@
 /**
  * Certificate syntax tests.
  */
-public class CertificateSyntaxTest extends SchemaTestCase {
+public class CertificateSyntaxTest extends AbstractSchemaTestCase {
 
     /**
      * Create data for the testAcceptableValues test. This should be a table of
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CoreSchemaTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CoreSchemaTest.java
index 2c84356..93fc95a 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CoreSchemaTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CoreSchemaTest.java
@@ -32,7 +32,7 @@
  * Core schema tests
  */
 @SuppressWarnings("javadoc")
-public class CoreSchemaTest extends SchemaTestCase {
+public class CoreSchemaTest extends AbstractSchemaTestCase {
     @Test
     public final void testCoreSchemaWarnings() {
         // Make sure core schema doesn't have any warnings.
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java
index 159eba8..19743aa 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/EntrySchemaCheckingTestCase.java
@@ -46,7 +46,7 @@
  * Test schema validation using {@link Schema#validateEntry}.
  */
 @Test
-public class EntrySchemaCheckingTestCase extends SchemaTestCase {
+public class EntrySchemaCheckingTestCase extends AbstractSchemaTestCase {
 
     /**
      * Tests schema checking for an entry covered by a DIT content rule to
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTest.java
index 59e1a8b..7b897fb 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTest.java
@@ -38,7 +38,7 @@
  * Test The equality matching rules and the equality matching rule api.
  */
 @SuppressWarnings("javadoc")
-public abstract class MatchingRuleTest extends SchemaTestCase {
+public abstract class MatchingRuleTest extends AbstractSchemaTestCase {
     /**
      * Generate invalid assertion values for the Matching Rule test.
      *
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTestCase.java
index 48cc59e..463be4f 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/MatchingRuleTestCase.java
@@ -43,7 +43,7 @@
  * This class tests the MatchingRule class. The matching rule builder can be only used with the schema builder.
  */
 @SuppressWarnings("javadoc")
-public class MatchingRuleTestCase extends SchemaTestCase {
+public class MatchingRuleTestCase extends AbstractSchemaTestCase {
 
     @Test()
     public final void testCreatesBasicMatchingRule() {
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NameFormTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NameFormTestCase.java
index 19fa12c..e03411c 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NameFormTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NameFormTestCase.java
@@ -42,7 +42,7 @@
  * with the schema builder.
  */
 @SuppressWarnings("javadoc")
-public class NameFormTestCase extends SchemaTestCase {
+public class NameFormTestCase extends AbstractSchemaTestCase {
 
     /**
      * Creates a new form using the required parameters only (oid, structural
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/OrderingMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/OrderingMatchingRuleTest.java
index 4da6427..88ce5c2 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/OrderingMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/OrderingMatchingRuleTest.java
@@ -38,7 +38,7 @@
  * Ordering matching rule tests.
  */
 @SuppressWarnings("javadoc")
-public abstract class OrderingMatchingRuleTest extends SchemaTestCase {
+public abstract class OrderingMatchingRuleTest extends AbstractSchemaTestCase {
     /**
      * Create data for the OrderingMatchingRulesInvalidValues test.
      *
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java
index b50e04c..7cbfaa0 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java
@@ -55,7 +55,7 @@
  * Test SchemaBuilder.
  */
 @SuppressWarnings("javadoc")
-public class SchemaBuilderTestCase extends SchemaTestCase {
+public class SchemaBuilderTestCase extends AbstractSchemaTestCase {
 
     /**
      * Tests that schema validation resolves dependencies between parent/child
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaCompatTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaCompatTest.java
index 040ab84..a483b0c 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaCompatTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaCompatTest.java
@@ -33,7 +33,7 @@
 /**
  * Tests schema compatibility options.
  */
-public class SchemaCompatTest extends SchemaTestCase {
+public class SchemaCompatTest extends AbstractSchemaTestCase {
     /**
      * Returns test data for valid attribute descriptions.
      *
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaTestCase.java
index 6c9fdd7..989aa4b 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaTestCase.java
@@ -21,17 +21,33 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
- *      Portions copyright 2012 ForgeRock AS.
+ *      Copyright 2014 ForgeRock AS.
  */
 package org.forgerock.opendj.ldap.schema;
 
-import org.forgerock.testng.ForgeRockTestCase;
+import static org.fest.assertions.Assertions.assertThat;
+
 import org.testng.annotations.Test;
 
 /**
- * An abstract class that all schema unit test should extend.
+ * Tests the Schema class.
  */
-@Test(groups = { "precommit", "schema", "sdk" })
-public abstract class SchemaTestCase extends ForgeRockTestCase {
+@SuppressWarnings("javadoc")
+public class SchemaTestCase extends AbstractSchemaTestCase {
+    @Test(description = "Unit test for OPENDJ-1477", enabled = false)
+    public void asNonStrictSchemaAlwaysReturnsSameInstance() {
+        final Schema schema = Schema.getCoreSchema();
+        final Schema nonStrictSchema1 = schema.asNonStrictSchema();
+        final Schema nonStrictSchema2 =
+                schema.asNonStrictSchema().asStrictSchema().asNonStrictSchema();
+        assertThat(nonStrictSchema1).isSameAs(nonStrictSchema2);
+    }
+
+    @Test(description = "Unit test for OPENDJ-1477", enabled = false)
+    public void asStrictSchemaAlwaysReturnsSameInstance() {
+        final Schema schema = Schema.getCoreSchema();
+        final Schema strictSchema1 = schema.asStrictSchema();
+        final Schema strictSchema2 = schema.asStrictSchema().asNonStrictSchema().asStrictSchema();
+        assertThat(strictSchema1).isSameAs(strictSchema2);
+    }
 }
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java
index 4da9fed..f5daa5f 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java
@@ -39,7 +39,7 @@
  * Test schema utilities.
  */
 @SuppressWarnings("javadoc")
-public class SchemaUtilsTest extends SchemaTestCase {
+public class SchemaUtilsTest extends AbstractSchemaTestCase {
 
     @DataProvider(name = "invalidOIDs")
     public Object[][] createInvalidOIDs() {
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java
index 62b8e91..85f08f9 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java
@@ -42,7 +42,7 @@
  * is intended to be extended by one class for each substring matching rules.
  */
 @SuppressWarnings("javadoc")
-public abstract class SubstringMatchingRuleTest extends SchemaTestCase {
+public abstract class SubstringMatchingRuleTest extends AbstractSchemaTestCase {
     /**
      * Generate invalid assertion values for the Matching Rule test.
      *
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SyntaxTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SyntaxTestCase.java
index ac0f089..7147fed 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SyntaxTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SyntaxTestCase.java
@@ -36,7 +36,7 @@
  * This class tests the Syntax class.
  */
 @SuppressWarnings("javadoc")
-public class SyntaxTestCase extends SchemaTestCase {
+public class SyntaxTestCase extends AbstractSchemaTestCase {
 
     @Test()
     public final void testCreatesANewSyntax() {

--
Gitblit v1.10.0