From b9af8f181b7495cb343c280db4ce8979a04bfc91 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Tue, 12 Sep 2006 23:12:27 +0000
Subject: [PATCH] This commit changes several aspects of the unit test infrastructure:
---
opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxConnectTest.java | 6 +
opends/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualityMatchingRuleTest.java | 14 ----
opends/tests/unit-tests-testng/src/server/org/opends/server/ConfigurationFixture.java | 7 ++
opends/tests/unit-tests-testng/src/server/org/opends/server/SingletonFixtureFactory.java | 4 +
opends/tests/unit-tests-testng/src/server/org/opends/server/InitialDirectoryServerFixture.java | 5 +
opends/tests/unit-tests-testng/src/server/org/opends/server/SchemaFixture.java | 6 ++
opends/tests/unit-tests-testng/src/server/org/opends/server/FixtureFactory.java | 3 +
opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java | 43 ++++++++++++++
opends/tests/unit-tests-testng/src/server/org/opends/server/schema/ApproximatematchingRule.java | 15 ----
opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SynchronizationTestCase.java | 19 -----
10 files changed, 77 insertions(+), 45 deletions(-)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/ConfigurationFixture.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/ConfigurationFixture.java
index 6d166cf..22ca2ab 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/ConfigurationFixture.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/ConfigurationFixture.java
@@ -37,6 +37,7 @@
import org.opends.server.core.DirectoryServer;
/**
+ *
* This fixture makes sure that a directory server instance is available
* with a configuration environment loaded from the source tree's
* resource directory.
@@ -49,6 +50,7 @@
/**
* A factory used to obtain the configuration fixture instance.
*/
+ @Deprecated
public static final FixtureFactory<ConfigurationFixture> FACTORY;
static {
@@ -62,6 +64,7 @@
/**
* Internal factory implementation.
*/
+ @Deprecated
private static final class Factory implements
FixtureFactory<ConfigurationFixture> {
@@ -71,6 +74,7 @@
/**
* {@inheritDoc}
*/
+ @Deprecated
public ConfigurationFixture setUp() throws Exception {
// This fixture requires the initial directory server fixture.
InitialDirectoryServerFixture.FACTORY.setUp();
@@ -100,6 +104,7 @@
/**
* {@inheritDoc}
*/
+ @Deprecated
public void tearDown() throws Exception {
// Clean up configuration directories.
try {
@@ -123,6 +128,7 @@
* @param instanceRoot
* The name of the temporary instance root.
*/
+ @Deprecated
private ConfigurationFixture(File instanceRoot) {
this.instanceRoot = instanceRoot;
}
@@ -132,6 +138,7 @@
*
* @return The temporary instance root.
*/
+ @Deprecated
public File getInstanceRoot() {
return instanceRoot;
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/FixtureFactory.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/FixtureFactory.java
index 84a5961..65b29c4 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/FixtureFactory.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/FixtureFactory.java
@@ -28,6 +28,7 @@
package org.opends.server;
/**
+ *
* A factory interface for controlling construction and finalization of
* fixtures.
*
@@ -43,6 +44,7 @@
* If the fixture instance could not be initialized
* successfully.
*/
+ @Deprecated
public T setUp() throws Exception;
/**
@@ -52,5 +54,6 @@
* @throws Exception
* If the fixture instance could not be finalized.
*/
+ @Deprecated
public void tearDown() throws Exception;
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/InitialDirectoryServerFixture.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/InitialDirectoryServerFixture.java
index ee2e256..e810982 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/InitialDirectoryServerFixture.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/InitialDirectoryServerFixture.java
@@ -32,6 +32,7 @@
import org.opends.server.core.DirectoryServer;
/**
+ *
* This fixture makes sure that a minimal directory server instance is
* available. Only one initialization task is performed: the directory
* server instance is created and has its
@@ -44,6 +45,7 @@
* A factory used to obtain the initial directory server fixture
* instance.
*/
+ @Deprecated
public static final FixtureFactory<InitialDirectoryServerFixture> FACTORY;
static {
@@ -54,11 +56,13 @@
/**
* Internal factory implementation.
*/
+ @Deprecated
private static final class Factory implements
FixtureFactory<InitialDirectoryServerFixture> {
/**
* {@inheritDoc}
*/
+ @Deprecated
public InitialDirectoryServerFixture setUp() throws Exception {
// Make sure a new instance is created.
//
@@ -83,6 +87,7 @@
/**
* {@inheritDoc}
*/
+ @Deprecated
public void tearDown() throws Exception {
// No implementation required - no way to finalize the directory
// server instance.
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/SchemaFixture.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/SchemaFixture.java
index 2be135b..9aac779 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/SchemaFixture.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/SchemaFixture.java
@@ -33,6 +33,7 @@
import org.opends.server.core.DirectoryServer;
/**
+ *
* This fixture makes sure that a directory server instance is available
* with the core schema files loaded from the source tree's resource
* directory.
@@ -45,6 +46,7 @@
/**
* A factory used to obtain the schema fixture instance.
*/
+ @Deprecated
public static final FixtureFactory<SchemaFixture> FACTORY;
static {
@@ -54,12 +56,14 @@
/**
* Internal factory implementation.
*/
+ @Deprecated
private static final class Factory implements
FixtureFactory<SchemaFixture> {
/**
* {@inheritDoc}
*/
+ @Deprecated
public SchemaFixture setUp() throws Exception {
// This fixture requires the configuration fixture.
ConfigurationFixture fixture = ConfigurationFixture.FACTORY.setUp();
@@ -80,6 +84,7 @@
/**
* {@inheritDoc}
*/
+ @Deprecated
public void tearDown() throws Exception {
// TODO: clean up the schema?
@@ -93,6 +98,7 @@
/**
* Create a schema fixture.
*/
+ @Deprecated
private SchemaFixture() {
// No implementation required.
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/SingletonFixtureFactory.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/SingletonFixtureFactory.java
index 068d6f1..4127ce3 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/SingletonFixtureFactory.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/SingletonFixtureFactory.java
@@ -28,6 +28,7 @@
package org.opends.server;
/**
+ *
* A fixture factory that guarantees that at most only one instance of a
* fixture is instantiated. The singleton factory uses reference
* counting to guarantee that the fixture instance is torn down at the
@@ -51,6 +52,7 @@
* @param pimpl
* The underlying fixture factory.
*/
+ //@Deprecated
public SingletonFixtureFactory(FixtureFactory<T> pimpl) {
this.pimpl = pimpl;
this.instance = null;
@@ -60,6 +62,7 @@
/**
* {@inheritDoc}
*/
+ @Deprecated
public T setUp() throws Exception {
if (refCount == 0) {
instance = pimpl.setUp();
@@ -72,6 +75,7 @@
/**
* {@inheritDoc}
*/
+ @Deprecated
public void tearDown() throws Exception {
if (refCount <= 0) {
throw new IllegalStateException("SingletonFixtureFactory tearDown "
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
index e71b669..de5af8e 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -86,6 +86,8 @@
File testRoot = new File(buildRoot + File.separator + "build" +
File.separator + "unit-tests" + File.separator +
"package");
+ File testSrcRoot = new File(buildRoot + File.separator + "tests" +
+ File.separator + "unit-tests-testng");
if (testRoot.exists())
{
@@ -104,6 +106,7 @@
// Copy the configuration, schema, and MakeLDIF resources into the
// appropriate place under the test package.
File resourceDir = new File(buildRoot, "resource");
+ File testResourceDir = new File(testSrcRoot, "resource");
File testConfigDir = new File(testRoot, "config");
copyDirectory(new File(resourceDir, "config"), testConfigDir);
@@ -111,7 +114,8 @@
new File(testConfigDir, "schema"));
copyDirectory(new File(resourceDir, "MakeLDIF"),
new File(testConfigDir, "MakeLDIF"));
- // FIXME -- Copy the config-changes.ldif file into place when we have one.
+ copyFile (new File(testResourceDir, "config-changes.ldif"),
+ new File(testConfigDir, "config-changes.ldif"));
// Actually start the server and set a variable that will prevent us from
@@ -228,6 +232,43 @@
}
/**
+ * Get the LDAP port the test environment Directory Server instance is
+ * running on.
+ *
+ * @return The port number.
+ */
+ public static long getServerLdapPort()
+ {
+ return 32389;
+ }
+
+ /**
+ * Get the JMX port the test environment Directory Server instance is
+ * running on.
+ *
+ * @return The port number.
+ */
+ public static long getServerJmxPort()
+ {
+ return 33689;
+ }
+
+ /**
+ * Method for getting a file from the test resources directory.
+ *
+ * @return The directory as a File
+ */
+ public static File getTestResource(String filename)
+ {
+ String buildRoot = System.getProperty(PROPERTY_BUILD_ROOT);
+ File testResourceDir = new File(buildRoot + File.separator + "tests" +
+ File.separator + "unit-tests-testng" +
+ File.separator + "resource");
+
+ return new File(testResourceDir, filename);
+ }
+
+ /**
* Prevent instantiation.
*/
private TestCaseUtils() {
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxConnectTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxConnectTest.java
index 9a95fce..d2431b6 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxConnectTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxConnectTest.java
@@ -108,7 +108,7 @@
{
return new Object[][] {
{"cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
- "ds-cfg-listen-port", new Long(1689)},
+ "ds-cfg-listen-port", TestCaseUtils.getServerJmxPort()},
{"cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
"objectclass", null},
{"cn=JMX Connection Handler,cn=Connection Handlers,cn=config",
@@ -178,6 +178,7 @@
throws MalformedURLException, IOException
{
HashMap<String, String[]> env = new HashMap<String, String[]>();
+ long jmxPort = TestCaseUtils.getServerJmxPort();
// Provide the credentials required by the server to successfully
// perform user authentication
@@ -196,7 +197,8 @@
//
JMXServiceURL url = new JMXServiceURL(
- "service:jmx:rmi:///jndi/rmi://localhost:1689/org.opends.server.protocols.jmx.client-unknown");
+ "service:jmx:rmi:///jndi/rmi://localhost:"+ jmxPort +
+ "/org.opends.server.protocols.jmx.client-unknown");
JMXConnector jmxc = null;
try
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/schema/ApproximatematchingRule.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/schema/ApproximatematchingRule.java
index bfbf86d..ab5296c 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/schema/ApproximatematchingRule.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/schema/ApproximatematchingRule.java
@@ -28,7 +28,7 @@
import static org.testng.Assert.assertEquals;
-import org.opends.server.SchemaFixture;
+import org.opends.server.TestCaseUtils;
import org.opends.server.api.ApproximateMatchingRule;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.types.ByteString;
@@ -166,17 +166,6 @@
@BeforeClass
public void setUp() throws Exception {
// This test suite depends on having the schema available.
- SchemaFixture.FACTORY.setUp();
- }
-
- /**
- * Tears down the environment for performing the tests in this suite.
- *
- * @throws Exception
- * If the environment could not be finalized.
- */
- @AfterClass
- public void tearDown() throws Exception {
- SchemaFixture.FACTORY.tearDown();
+ TestCaseUtils.startServer();
}
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualityMatchingRuleTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualityMatchingRuleTest.java
index a32bfcd..57a8fc4 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualityMatchingRuleTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/schema/EqualityMatchingRuleTest.java
@@ -26,7 +26,7 @@
*/
package org.opends.server.schema;
-import org.opends.server.SchemaFixture;
+import org.opends.server.TestCaseUtils;
import org.opends.server.api.EqualityMatchingRule;
import org.opends.server.core.DirectoryException;
import org.opends.server.protocols.asn1.ASN1OctetString;
@@ -216,17 +216,7 @@
@BeforeClass
public void setUp() throws Exception {
// This test suite depends on having the schema available.
- SchemaFixture.FACTORY.setUp();
+ TestCaseUtils.startServer();
}
- /**
- * Tears down the environment for performing the tests in this suite.
- *
- * @throws Exception
- * If the environment could not be finalized.
- */
- @AfterClass
- public void tearDown() throws Exception {
- SchemaFixture.FACTORY.tearDown();
- }
}
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SynchronizationTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SynchronizationTestCase.java
index 5ac1eb8..4346d6d 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SynchronizationTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/synchronization/SynchronizationTestCase.java
@@ -27,10 +27,9 @@
package org.opends.server.synchronization;
import org.opends.server.DirectoryServerTestCase;
-import org.opends.server.SchemaFixture;
+import org.opends.server.TestCaseUtils;
import org.testng.annotations.Test;
-import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
/**
@@ -39,20 +38,6 @@
@Test(groups = { "precommit", "synchronization" })
public abstract class SynchronizationTestCase extends DirectoryServerTestCase
{
-
-
- /**
- * Tears down the environment for performing the tests in this suite.
- *
- * @throws Exception
- * If the environment could not be finalized.
- */
- @AfterClass
- public void tearDown() throws Exception
- {
- SchemaFixture.FACTORY.tearDown();
- }
-
/**
* Set up the environment for performing the tests in this suite.
@@ -64,7 +49,7 @@
public void setUp() throws Exception
{
// This test suite depends on having the schema available.
- SchemaFixture.FACTORY.setUp();
+ TestCaseUtils.startServer();
}
}
--
Gitblit v1.10.0