You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2008/07/29 08:02:10 UTC

svn commit: r680629 [1/2] - in /directory/apacheds/branches/bigbang: ./ server-integ/ server-integ/.settings/ server-integ/src/ server-integ/src/main/ server-integ/src/main/java/ server-integ/src/main/java/org/ server-integ/src/main/java/org/apache/ se...

Author: akarasulu
Date: Mon Jul 28 23:02:08 2008
New Revision: 680629

URL: http://svn.apache.org/viewvc?rev=680629&view=rev
Log:
initial server-integ module implementation for doing same thing that core integ does

Added:
    directory/apacheds/branches/bigbang/server-integ/   (with props)
    directory/apacheds/branches/bigbang/server-integ/.classpath   (with props)
    directory/apacheds/branches/bigbang/server-integ/.project   (with props)
    directory/apacheds/branches/bigbang/server-integ/.settings/
    directory/apacheds/branches/bigbang/server-integ/.settings/org.eclipse.jdt.core.prefs
    directory/apacheds/branches/bigbang/server-integ/pom.xml   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/
    directory/apacheds/branches/bigbang/server-integ/src/main/
    directory/apacheds/branches/bigbang/server-integ/src/main/java/
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/InheritableServerSettings.java   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiRunner.java   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiSuite.java   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/annotations/
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedNormalState.java   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerState.java   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/main/resources/
    directory/apacheds/branches/bigbang/server-integ/src/main/resources/META-INF/
    directory/apacheds/branches/bigbang/server-integ/src/site/
    directory/apacheds/branches/bigbang/server-integ/src/site/site.xml   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/test/
    directory/apacheds/branches/bigbang/server-integ/src/test/java/
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/
    directory/apacheds/branches/bigbang/server-integ/src/test/java/org/apache/directory/server/
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/log4j.properties   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/apache/
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/apache/directory/
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/apache/directory/server/
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/apache/directory/server/core/
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/apache/directory/server/core/normalization/
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/apache/directory/server/core/normalization/testDireve308Example.ldif
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/apache/directory/server/core/schema/
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/apache/directory/server/core/schema/DummyComparator.bytecode   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/apache/directory/server/core/schema/DummyNormalizer.bytecode   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/apache/directory/server/core/schema/DummySyntaxChecker.bytecode   (with props)
    directory/apacheds/branches/bigbang/server-integ/src/test/resources/org/apache/directory/server/core/schema/nonspecific.ldif
Modified:
    directory/apacheds/branches/bigbang/pom.xml

Modified: directory/apacheds/branches/bigbang/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/pom.xml?rev=680629&r1=680628&r2=680629&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/pom.xml (original)
+++ directory/apacheds/branches/bigbang/pom.xml Mon Jul 28 23:02:08 2008
@@ -362,6 +362,7 @@
     <module>protocol-dhcp</module>
     <module>protocol-dns</module>
     <module>protocol-changepw</module>
+    <module>server-integ</module>
     <module>server-tools</module>
 
     <!-- breaks the build on first try

Propchange: directory/apacheds/branches/bigbang/server-integ/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jul 28 23:02:08 2008
@@ -0,0 +1,14 @@
+*.iml
+*.ipr
+*.iws
+.wtpmodules
+.settings
+.deployables
+junit*.properties
+server-work
+target
+.classpath
+.project
+*.log
+nbproject
+

Added: directory/apacheds/branches/bigbang/server-integ/.classpath
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/.classpath?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/.classpath (added)
+++ directory/apacheds/branches/bigbang/server-integ/.classpath Mon Jul 28 23:02:08 2008
@@ -0,0 +1,61 @@
+<classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
+  <classpathentry kind="src" path="target/maven-shared-archive-resources" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>
+  <classpathentry kind="src" path="/apacheds-bootstrap-extract"/>
+  <classpathentry kind="src" path="/apacheds-bootstrap-partition"/>
+  <classpathentry kind="src" path="/apacheds-btree-base"/>
+  <classpathentry kind="src" path="/apacheds-core"/>
+  <classpathentry kind="src" path="/apacheds-core-avl"/>
+  <classpathentry kind="src" path="/apacheds-core-constants"/>
+  <classpathentry kind="src" path="/apacheds-core-cursor"/>
+  <classpathentry kind="src" path="/apacheds-core-entry"/>
+  <classpathentry kind="src" path="/apacheds-core-integ"/>
+  <classpathentry kind="src" path="/apacheds-core-jndi"/>
+  <classpathentry kind="src" path="/apacheds-core-shared"/>
+  <classpathentry kind="src" path="/apacheds-jdbm"/>
+  <classpathentry kind="src" path="/apacheds-jdbm-store"/>
+  <classpathentry kind="src" path="/apacheds-kerberos-shared"/>
+  <classpathentry kind="src" path="/apacheds-protocol-newldap"/>
+  <classpathentry kind="src" path="/apacheds-protocol-shared"/>
+  <classpathentry kind="src" path="/apacheds-schema-bootstrap"/>
+  <classpathentry kind="src" path="/apacheds-schema-extras"/>
+  <classpathentry kind="src" path="/apacheds-schema-registries"/>
+  <classpathentry kind="src" path="/apacheds-server-jndi"/>
+  <classpathentry kind="src" path="/apacheds-utils"/>
+  <classpathentry kind="src" path="/apacheds-xdbm-search"/>
+  <classpathentry kind="src" path="/apacheds-xdbm-tools"/>
+  <classpathentry kind="var" path="M2_REPO/bouncycastle/bcprov-jdk15/136/bcprov-jdk15-136.jar" sourcepath="M2_REPO/bouncycastle/bcprov-jdk15/136/bcprov-jdk15-136-sources.jar">
+    <attributes>
+      <attribute value="jar:file:/home/akarasulu/ramdisk/.m2/repository/bouncycastle/bcprov-jdk15/136/bcprov-jdk15-136-javadoc.jar!/" name="javadoc_location"/>
+    </attributes>
+  </classpathentry>
+  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2/commons-collections-3.2.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2/commons-collections-3.2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2.jar" sourcepath="M2_REPO/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2-sources.jar">
+    <attributes>
+      <attribute value="jar:file:/home/akarasulu/ramdisk/.m2/repository/org/apache/commons/commons-io/1.3.2/commons-io-1.3.2-javadoc.jar!/" name="javadoc_location"/>
+    </attributes>
+  </classpathentry>
+  <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.3/commons-lang-2.3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/jcl104-over-slf4j/1.4.3/jcl104-over-slf4j-1.4.3.jar" sourcepath="M2_REPO/org/slf4j/jcl104-over-slf4j/1.4.3/jcl104-over-slf4j-1.4.3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar" sourcepath="M2_REPO/junit/junit/4.4/junit-4.4-sources.jar">
+    <attributes>
+      <attribute value="jar:file:/home/akarasulu/ramdisk/.m2/repository/junit/junit/4.4/junit-4.4-javadoc.jar!/" name="javadoc_location"/>
+    </attributes>
+  </classpathentry>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/mina/mina-core/1.1.6/mina-core-1.1.6.jar" sourcepath="M2_REPO/org/apache/mina/mina-core/1.1.6/mina-core-1.1.6-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/mina/mina-filter-ssl/1.1.6/mina-filter-ssl-1.1.6.jar" sourcepath="M2_REPO/org/apache/mina/mina-filter-ssl/1.1.6/mina-filter-ssl-1.1.6-sources.jar"/>
+  <classpathentry kind="src" path="/shared-asn1"/>
+  <classpathentry kind="src" path="/shared-asn1-codec"/>
+  <classpathentry kind="src" path="/shared-bouncycastle-reduced"/>
+  <classpathentry kind="src" path="/shared-ldap"/>
+  <classpathentry kind="src" path="/shared-ldap-constants"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.4.3/slf4j-api-1.4.3.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.4.3/slf4j-api-1.4.3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.4.3/slf4j-log4j12-1.4.3.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.4.3/slf4j-log4j12-1.4.3-sources.jar"/>
+</classpath>
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/server-integ/.classpath
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/server-integ/.project
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/.project?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/.project (added)
+++ directory/apacheds/branches/bigbang/server-integ/.project Mon Jul 28 23:02:08 2008
@@ -0,0 +1,42 @@
+<projectDescription>
+  <name>apacheds-server-integ</name>
+  <comment>Integration testing framework for Apache Directory Server.</comment>
+  <projects>
+    <project>apacheds-bootstrap-extract</project>
+    <project>apacheds-bootstrap-partition</project>
+    <project>apacheds-btree-base</project>
+    <project>apacheds-core</project>
+    <project>apacheds-core-avl</project>
+    <project>apacheds-core-constants</project>
+    <project>apacheds-core-cursor</project>
+    <project>apacheds-core-entry</project>
+    <project>apacheds-core-integ</project>
+    <project>apacheds-core-jndi</project>
+    <project>apacheds-core-shared</project>
+    <project>apacheds-jdbm</project>
+    <project>apacheds-jdbm-store</project>
+    <project>apacheds-kerberos-shared</project>
+    <project>apacheds-protocol-newldap</project>
+    <project>apacheds-protocol-shared</project>
+    <project>apacheds-schema-bootstrap</project>
+    <project>apacheds-schema-extras</project>
+    <project>apacheds-schema-registries</project>
+    <project>apacheds-server-jndi</project>
+    <project>apacheds-utils</project>
+    <project>apacheds-xdbm-search</project>
+    <project>apacheds-xdbm-tools</project>
+    <project>shared-asn1</project>
+    <project>shared-asn1-codec</project>
+    <project>shared-bouncycastle-reduced</project>
+    <project>shared-ldap</project>
+    <project>shared-ldap-constants</project>
+  </projects>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/server-integ/.project
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/server-integ/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/.settings/org.eclipse.jdt.core.prefs?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/.settings/org.eclipse.jdt.core.prefs (added)
+++ directory/apacheds/branches/bigbang/server-integ/.settings/org.eclipse.jdt.core.prefs Mon Jul 28 23:02:08 2008
@@ -0,0 +1,5 @@
+#Mon Jul 28 21:17:20 EDT 2008
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5

Added: directory/apacheds/branches/bigbang/server-integ/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/pom.xml?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/pom.xml (added)
+++ directory/apacheds/branches/bigbang/server-integ/pom.xml Mon Jul 28 23:02:08 2008
@@ -0,0 +1,144 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.directory.server</groupId>
+    <artifactId>apacheds-parent</artifactId>
+    <version>1.5.4-SNAPSHOT</version>
+  </parent>
+  <artifactId>apacheds-server-integ</artifactId>
+  <name>ApacheDS Server Integration</name>
+  <packaging>jar</packaging>  
+
+  <description>
+    Integration testing framework for Apache Directory Server.
+  </description>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-server-jndi</artifactId>
+      <version>${pom.version}</version>
+    </dependency>  
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core-integ</artifactId>
+      <version>${pom.version}</version>
+    </dependency>  
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-schema-extras</artifactId>
+      <version>${pom.version}</version>
+      <scope>test</scope>
+    </dependency>  
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-bootstrap-partition</artifactId>
+      <version>${pom.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <profiles>
+    <profile>
+      <id>integration</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <includes>
+                <include>**/*ISuite.java</include>
+                <include>**/*ITest.java</include>
+                <include>**/*IT.java</include>
+              </includes>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    
+    <profile>
+      <id>quicktest</id>
+      <activation>
+        <property><name>quicktest</name></property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <excludes>
+                <exclude>**/*PTest.java</exclude>
+                <exclude>**/*ITest.java</exclude>
+                <exclude>**/*IT.java</exclude>
+              </excludes>
+            </configuration>
+          </plugin>
+
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <executions>
+              <execution>
+                <phase>validate</phase>
+                <configuration>
+                  <tasks>
+                    <echo>
+=================================================================
+                   Q U I C K   T E S T S
+                   ---------------------
+                  
+WARNING: Long running integration tests have been disabled!
+=================================================================
+                    </echo>
+                  </tasks>
+                </configuration>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
+

Propchange: directory/apacheds/branches/bigbang/server-integ/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/InheritableServerSettings.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/InheritableServerSettings.java?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/InheritableServerSettings.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/InheritableServerSettings.java Mon Jul 28 23:02:08 2008
@@ -0,0 +1,271 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.integ;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.SetupMode;
+import org.apache.directory.server.core.integ.annotations.ApplyLdifFiles;
+import org.apache.directory.server.core.integ.annotations.ApplyLdifs;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.server.core.integ.annotations.Factory;
+import org.apache.directory.server.core.integ.annotations.Mode;
+import org.junit.runner.Description;
+
+
+/**
+ * Inheritable settings of a test suite, test class, or test method.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class InheritableServerSettings
+{
+    /** the default setup mode to use if inheritance leads to null value */
+    public static final SetupMode DEFAULT_MODE = SetupMode.ROLLBACK;
+    
+    /** the default factory to use if inheritance leads to a null value */
+    public static final LdapServerFactory DEFAULT_FACTORY = LdapServerFactory.DEFAULT;
+
+    /** parent settings to inherit from */
+    private final InheritableServerSettings parent;
+    
+    /** JUnit test description containing all annotations queried */
+    private final Description description;
+    
+    /** default level at which a service is cleaned up */
+    private static final Level DEFAULT_CLEANUP_LEVEL = Level.SUITE;
+
+
+    /**
+     * Creates a new InheritableServerSettings instance for test suites description.
+     *
+     * @param description JUnit description for the suite
+     */
+    public InheritableServerSettings( Description description )
+    {
+        this.description = description;
+        this.parent = null;
+    }
+
+
+    /**
+     * Creates a new InheritableServerSettings instance based on a test object's
+     * description and it's parent's settings.
+     *
+     * @param description JUnit description for the test object
+     * @param parent the parent settings or null if the test entity is a suite
+     */
+    public InheritableServerSettings( Description description, InheritableServerSettings parent )
+    {
+        this.description = description;
+        this.parent = parent;
+
+        if ( description.isSuite() && ! isSuiteLevel() )
+        {
+            throw new IllegalStateException( String.format( "The parent must be null for %s suite",
+                    description.getDisplayName() ) );
+        }
+    }
+
+
+    /**
+     * @return the description of the running test
+     */
+    public Description getDescription()
+    {
+        return description;
+    }
+
+
+    /**
+     * @return the settings inherited from the parent
+     */
+    public InheritableServerSettings getParent()
+    {
+        return parent;
+    }
+
+
+    /**
+     * @return <code>true</code> if we are at the suite level
+     */
+    public boolean isSuiteLevel()
+    {
+        return parent == null;
+    }
+
+
+    /**
+     * @return <code>true</code> if we are at the class level
+     */
+    public boolean isClassLevel()
+    {
+        return ( parent != null ) && ( parent.getParent() == null );
+    }
+
+
+    /**
+     * @return <code>true</code> if we are at the method level
+     */
+    public boolean isMethodLevel()
+    {
+        return ( parent != null ) && ( parent.getParent() != null );
+    }
+
+
+    /**
+     * @return the test mode. Default to ROLLBACK
+     */
+    public SetupMode getMode()
+    {
+        SetupMode parentMode = DEFAULT_MODE;
+        
+        if ( parent != null )
+        {
+            parentMode = parent.getMode();
+        }
+
+        // Get the @Mode annotation
+        Mode annotation = description.getAnnotation( Mode.class );
+        
+        if ( annotation == null )
+        {
+            return parentMode;
+        }
+        else
+        {
+            return annotation.value();
+        }
+    }
+
+
+    /**
+     * @return the DirectoryService factory 
+     * @throws IllegalAccessException if we can't access the factory
+     * @throws InstantiationException if the DirectoryService can't be instanciated
+     */
+    public LdapServerFactory getFactory() throws IllegalAccessException, InstantiationException
+    {
+        LdapServerFactory parentFactory = DEFAULT_FACTORY;
+        
+        if ( parent != null )
+        {
+            parentFactory = parent.getFactory();
+        }
+
+        Factory annotation = description.getAnnotation( Factory.class );
+        
+        if ( annotation == null )
+        {
+            return parentFactory;
+        }
+        else
+        {
+            return ( LdapServerFactory ) annotation.value().newInstance();
+        }
+    }
+
+
+    /**
+     * Get a list of entries from a LDIF declared as an annotation
+     *
+     * @param ldifs the list of LDIFs we want to feed  
+     * @return a list of entries described using a LDIF format
+     */
+    public List<String> getLdifs( List<String> ldifs )
+    {
+        if ( ldifs == null )
+        {
+            ldifs = new ArrayList<String>();
+        }
+
+        if ( parent != null )
+        {
+            parent.getLdifs( ldifs );
+        }
+
+        ApplyLdifs annotation = description.getAnnotation( ApplyLdifs.class );
+        
+        if ( ( annotation != null ) && ( annotation.value() != null ) )
+        {
+            ldifs.addAll( Arrays.asList( annotation.value() ) );
+        }
+
+        return ldifs;
+    }
+
+
+    /**
+     * Get a list of files containing entries described using the LDIF format.
+     *
+     * @param ldifFiles the list to feed
+     * @return a list of files containing some LDIF data
+     */
+    public List<String> getLdifFiles( List<String> ldifFiles )
+    {
+        if ( ldifFiles == null )
+        {
+            ldifFiles = new ArrayList<String>();
+        }
+
+        if ( parent != null )
+        {
+            parent.getLdifFiles( ldifFiles );
+        }
+
+        ApplyLdifFiles annotation = description.getAnnotation( ApplyLdifFiles.class );
+        
+        if ( annotation != null && annotation.value() != null )
+        {
+            ldifFiles.addAll( Arrays.asList( annotation.value() ) );
+        }
+
+        return ldifFiles;
+    }
+
+
+    /**
+     * @return teh cleanup level. Defualt to SUITE
+     */
+    public Level getCleanupLevel()
+    {
+        Level parentCleanupLevel = DEFAULT_CLEANUP_LEVEL;
+        
+        if ( parent != null )
+        {
+            parentCleanupLevel = parent.getCleanupLevel();
+        }
+
+        CleanupLevel annotation = description.getAnnotation( CleanupLevel.class );
+        
+        if ( annotation == null )
+        {
+            return parentCleanupLevel;
+        }
+        else
+        {
+            return annotation.value();
+        }
+    }
+}

Propchange: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/InheritableServerSettings.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java Mon Jul 28 23:02:08 2008
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.integ;
+
+
+import org.apache.directory.server.core.DefaultDirectoryService;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.newldap.LdapServer;
+
+
+/**
+ * A factory used to generate differently configured DirectoryService objects.
+ * Since the DirectoryService itself is what is configured then a factory for
+ * these objects acts as a configurator.  Tests can provide different factory
+ * methods to be used.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface LdapServerFactory
+{
+    /**
+     * The default factory returns stock instances of a directory
+     * service with smart defaults
+     */
+    LdapServerFactory DEFAULT = new LdapServerFactory()
+    {
+        public LdapServer newInstance()
+        {
+            DirectoryService service = new DefaultDirectoryService();
+            service.getChangeLog().setEnabled( true );
+
+            // change the working directory to something that is unique
+            // on the system and somewhere either under target directory
+            // or somewhere in a temp area of the machine.
+
+            LdapServer ldapServer = new LdapServer();
+            ldapServer.setDirectoryService( service );
+            
+            // TODO make sure we properly setup the ldapserver for 
+            // now we just making stuff compile
+            
+            throw new RuntimeException( "NOT implemented !!!! " );
+            
+            // return ldapServer;
+        }
+    };
+
+    LdapServer newInstance() throws Exception;
+}

Propchange: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiRunner.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiRunner.java?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiRunner.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiRunner.java Mon Jul 28 23:02:08 2008
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.integ;
+
+
+import java.lang.reflect.Method;
+
+import static org.apache.directory.server.integ.state.TestServerContext.cleanup;
+import static org.apache.directory.server.integ.state.TestServerContext.destroy;
+import static org.apache.directory.server.integ.state.TestServerContext.shutdown;
+import static org.apache.directory.server.integ.state.TestServerContext.test;
+
+import org.apache.directory.server.core.integ.Level;
+import org.junit.internal.runners.InitializationError;
+import org.junit.internal.runners.JUnit4ClassRunner;
+import org.junit.runner.Description;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunNotifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A test runner for ApacheDS Core integration tests.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SiRunner extends JUnit4ClassRunner
+{
+    private static final Logger LOG = LoggerFactory.getLogger( SiRunner.class );
+    private SiSuite suite;
+    private InheritableServerSettings settings;
+
+
+    public SiRunner( Class<?> clazz ) throws InitializationError
+    {
+        super( clazz );
+    }
+
+
+    protected InheritableServerSettings getSettings()
+    {
+        if ( settings != null )
+        {
+            return settings;
+        }
+
+        if ( suite == null )
+        {
+            settings = new InheritableServerSettings( getDescription(), null );
+        }
+
+        return settings;
+    }
+
+
+    @Override
+    public void run( final RunNotifier notifier )
+    {
+        super.run( notifier );
+        Level cleanupLevel = getSettings().getCleanupLevel();
+        
+        if ( cleanupLevel == Level.CLASS )
+        {
+            try
+            {
+                shutdown();
+                cleanup();
+                destroy();
+            }
+            catch ( Exception e )
+            {
+                LOG.error( "Encountered exception while trying to cleanup after test class: "
+                        + this.getDescription().getDisplayName(), e );
+                notifier.fireTestFailure( new Failure( getDescription(), e ) );
+            }
+        }
+    }
+
+
+    @Override
+    protected void invokeTestMethod( Method method, final RunNotifier notifier )
+    {
+        LOG.debug( "About to invoke test method {}", method.getName() );
+        Description description = methodDescription( method );
+        test( getTestClass(), wrapMethod( method ), notifier, new InheritableServerSettings( description, getSettings() ) );
+
+        Level cleanupLevel = getSettings().getCleanupLevel();
+        
+        if ( cleanupLevel == Level.METHOD )
+        {
+            try
+            {
+                shutdown();
+                cleanup();
+                destroy();
+            }
+            catch ( Exception e )
+            {
+                LOG.error( "Encountered exception while trying to cleanup after test class: "
+                        + this.getDescription().getDisplayName(), e );
+                notifier.fireTestFailure( new Failure( getDescription(), e ) );
+            }
+        }
+    }
+
+
+    public void setSuite( SiSuite suite )
+    {
+        this.suite = suite;
+        this.settings = new InheritableServerSettings( getDescription(), suite.getSettings() );
+    }
+
+
+    public SiSuite getSuite()
+    {
+        return suite;
+    }
+}

Propchange: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiRunner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiSuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiSuite.java?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiSuite.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiSuite.java Mon Jul 28 23:02:08 2008
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.integ;
+
+
+import java.util.List;
+
+import static org.apache.directory.server.integ.state.TestServerContext.cleanup;
+import static org.apache.directory.server.integ.state.TestServerContext.destroy;
+import static org.apache.directory.server.integ.state.TestServerContext.shutdown;
+
+import org.apache.directory.server.core.integ.Level;
+import org.junit.internal.requests.IgnoredClassRunner;
+import org.junit.internal.runners.InitializationError;
+import org.junit.runner.Runner;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunNotifier;
+import org.junit.runners.Suite;
+
+
+/**
+ * A replacement for standard JUnit 4 suites. Note that this test suite
+ * will not startup an DirectoryService instance but will clean it up if
+ * one remains.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SiSuite extends Suite
+{
+    private InheritableServerSettings settings;
+
+
+    public SiSuite( Class<?> clazz ) throws InitializationError
+    {
+        super( clazz );
+        settings = new InheritableServerSettings( getDescription() );
+    }
+
+
+    public void addAll( List<? extends Runner> runners )
+    {
+        for ( Runner runner : getRunners() )
+        {
+            if ( runner instanceof SiRunner )
+            {
+                SiRunner cir = ( SiRunner) runner;
+                cir.setSuite( this );
+            }
+            else if ( runner instanceof IgnoredClassRunner )
+            {
+                // allow this one
+            }
+            else
+            {
+                throw new IllegalArgumentException( String.format( "Unexpected runner type \"%s\".  " +
+                        "Test classes within CiSuites must use CiRunners.", runner ) );
+            }
+        }
+
+        super.addAll( runners );
+    }
+
+
+    public void add( Runner runner )
+    {
+        if ( runner instanceof SiRunner )
+        {
+            SiRunner cir = ( SiRunner) runner;
+            cir.setSuite( this );
+            super.add( runner );
+        }
+        else if ( runner instanceof IgnoredClassRunner )
+        {
+            // allow this one
+        }
+        else
+        {
+            throw new IllegalArgumentException( String.format( "Unexpected runner type \"%s\".  " +
+                    "Test classes within CiSuites must use CiRunners.", runner ) );
+        }
+    }
+
+
+    @Override
+    public void run( final RunNotifier notifier )
+    {
+        super.run( notifier );
+
+        /*
+         * For any service scope other than test system scope, we must have to
+         * shutdown the sevice and cleanup the working directory.  Failures to
+         * do this without exception shows that something is wrong with the
+         * server and so the entire test should be marked as failed.  So we
+         * presume that tests have failed in the suite if the fixture is in an
+         * inconsistent state.  Who knows if this inconsistent state of the
+         * service could have made it so false results were acquired while
+         * running tests.
+         */
+
+        if ( settings.getCleanupLevel() != Level.SYSTEM )
+        {
+            try
+            {
+                shutdown();
+                cleanup();
+                destroy();
+            }
+            catch ( Exception e )
+            {
+                notifier.fireTestFailure( new Failure( getDescription(), e ) );
+            }
+        }
+    }
+
+
+    public InheritableServerSettings getSettings()
+    {
+        return settings;
+    }
+}

Propchange: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/SiSuite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java Mon Jul 28 23:02:08 2008
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.integ.state;
+
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.integ.IntegrationUtils;
+import org.apache.directory.server.integ.InheritableServerSettings;
+import org.apache.directory.shared.ldap.ldif.LdifEntry;
+import org.apache.directory.shared.ldap.ldif.LdifReader;
+import org.junit.internal.runners.TestClass;
+import org.junit.internal.runners.TestMethod;
+import org.junit.runner.notification.RunNotifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The abstract state of a test service, containing the default state 
+ * transitions
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractState implements TestServerState
+{
+    /** The class logger */
+    private static final Logger LOG = LoggerFactory.getLogger( AbstractState.class );
+
+    /** The context for this test */
+    protected final TestServerContext context;
+
+    /** Error message when we can't destroy the service */
+    private static final String DESTROY_ERR = "Cannot destroy when service is in NonExistant state";
+    private static final String CLEANUP_ERROR = "Cannot cleanup when service is in NonExistant state";
+    private static final String STARTUP_ERR = "Cannot startup when service is in NonExistant state";
+    private static final String SHUTDOWN_ERR = "Cannot shutdown service in NonExistant state.";
+    private static final String REVERT_ERROR = "Cannot revert when service is in NonExistant state";
+
+    /**
+     * 
+     * Creates a new instance of AbstractState.
+     *
+     * @param context The associated context
+     */
+    protected AbstractState( TestServerContext context )
+    {
+        this.context = context;
+    }
+
+
+    /**
+     * Action where an attempt is made to create the service.  Service
+     * creation in this system is the combined instantiation and
+     * configuration which takes place when the factory is used to get
+     * a new instance of the service.
+     *
+     * @param settings The inherited settings
+     * @throws NamingException if we can't create the service
+     */
+    public void create( InheritableServerSettings settings ) throws NamingException
+    {
+    }
+
+
+    /**
+     * Action where an attempt is made to destroy the service. This
+     * entails nulling out reference to it and triggering garbage
+     * collection.
+     */
+    public void destroy()
+    {
+        LOG.error( DESTROY_ERR );
+        throw new IllegalStateException( DESTROY_ERR );
+    }
+
+
+    /**
+     * Action where an attempt is made to erase the contents of the
+     * working directory used by the service for various files including
+     * partition database files.
+     *
+     * @throws IOException on errors while deleting the working directory
+     */
+    public void cleanup() throws  IOException
+    {
+        LOG.error( CLEANUP_ERROR );
+        throw new IllegalStateException( CLEANUP_ERROR );
+    }
+
+
+    /**
+     * Action where an attempt is made to start up the service.
+     *
+     * @throws Exception on failures to start the core directory service
+     */
+    public void startup() throws Exception
+    {
+        LOG.error( STARTUP_ERR );
+        throw new IllegalStateException( STARTUP_ERR );
+    }
+
+
+    /**
+     * Action where an attempt is made to shutdown the service.
+     *
+     * @throws Exception on failures to stop the core directory service
+     */
+    public void shutdown() throws Exception
+    {
+        LOG.error( SHUTDOWN_ERR );
+        throw new IllegalStateException( SHUTDOWN_ERR );
+    }
+
+
+    /**
+     * Action where an attempt is made to run a test against the service.
+     *
+     * All annotations should have already been processed for
+     * InheritableServerSettings yet they and others can be processed since we have
+     * access to the method annotations below
+     *
+     * @param testClass the class whose test method is to be run
+     * @param testMethod the test method which is to be run
+     * @param notifier a notifier to report failures to
+     * @param settings the inherited settings and annotations associated with
+     * the test method
+     */
+    public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableServerSettings settings )
+    {
+    }
+
+
+    /**
+     * Action where an attempt is made to revert the service to it's
+     * initial start up state by using a previous snapshot.
+     *
+     * @throws Exception on failures to revert the state of the core
+     * directory service
+     */
+    public void revert() throws Exception
+    {
+        LOG.error( REVERT_ERROR );
+        throw new IllegalStateException( REVERT_ERROR );
+    }
+
+    
+    /**
+     * Inject the Ldifs if any
+     *
+     * @param service the instantiated directory service
+     * @param settings the settings containing the ldif
+     */
+    protected void injectLdifs( DirectoryService service, InheritableServerSettings settings )
+    {
+        List<String> ldifs = new ArrayList<String>();
+
+        ldifs =  settings.getLdifs( ldifs );
+        
+        if ( ldifs.size() != 0 )
+        {
+            for ( String ldif:ldifs )
+            {
+                try
+                {
+                    StringReader in = new StringReader( ldif );
+                    LdifReader ldifReader = new LdifReader( in );
+                    LdifEntry entry = ldifReader.next();
+                    
+                    LdapContext root = IntegrationUtils.getRootContext( service );
+                    root.createSubcontext( entry.getDn(), entry.getAttributes() );
+                }
+                catch ( Exception e )
+                {
+                    LOG.error( "Cannot inject the following entry : {}. Error : {}.", ldif, e.getMessage() );
+                }
+            }
+        }
+    }
+}

Propchange: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/AbstractState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java Mon Jul 28 23:02:08 2008
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.integ.state;
+
+
+import java.io.IOException;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.server.integ.LdapServerFactory;
+import org.apache.directory.server.integ.InheritableServerSettings;
+import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
+import org.junit.internal.runners.TestClass;
+import org.junit.internal.runners.TestMethod;
+import org.junit.runner.notification.RunNotifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The state of a test service when it has not yet been created.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NonExistentState extends AbstractState
+{
+    private static final Logger LOG = LoggerFactory.getLogger( NonExistentState.class );
+
+
+    /**
+     * Creates a new instance of NonExistentState.
+     *
+     * @param context the test context
+     */
+    public NonExistentState( TestServerContext context )
+    {
+        super( context );
+    }
+
+
+    /**
+     * Action where an attempt is made to create the service.  Service
+     * creation in this system is the combined instantiation and
+     * configuration which takes place when the factory is used to get
+     * a new instance of the service.
+     *
+     * @param settings The inherited settings
+     * @throws NamingException if we can't create the service
+     */
+    public void create( InheritableServerSettings settings ) throws NamingException
+    {
+        LOG.debug( "calling create()" );
+
+        try
+        {
+            LdapServerFactory factory = settings.getFactory();
+            context.setLdapServer( factory.newInstance() );
+        }
+        catch ( InstantiationException ie )
+        {
+            throw new NamingException( ie.getMessage() );
+        }
+        catch ( IllegalAccessException iae )
+        {
+            throw new NamingException( iae.getMessage() );
+        }
+        catch ( Exception e )
+        {
+            throw new NamingException( e.getMessage() );
+        }
+    }
+
+
+    /**
+     * Action where an attempt is made to erase the contents of the
+     * working directory used by the service for various files including
+     * partition database files.
+     *
+     * @throws IOException on errors while deleting the working directory
+     */
+    public void cleanup() throws IOException
+    {
+        LOG.debug( "calling cleanup()" );
+        doDelete( context.getLdapServer().getDirectoryService().getWorkingDirectory() );
+    }
+
+
+    /**
+     * Action where an attempt is made to start up the service.
+     *
+     * @throws Exception on failures to start the core directory service
+     */
+    public void startup() throws Exception
+    {
+        LOG.debug( "calling startup()" );
+        context.getLdapServer().getDirectoryService().startup();
+        context.getLdapServer().start();
+    }
+
+
+    /**
+     * This method is a bit different.  Consider this method to hold the logic
+     * which is needed to shift the context state from the present state to a
+     * started state so we can call test on the current state of the context.
+     *
+     * Basically if the service is not needed or the test is ignored, then we
+     * just invoke the test: if ignored the test is not dealt with by the
+     * MethodRoadie run method.
+     *
+     * In tests not ignored requiring setup modes RESTART and CUMULATIVE we
+     * simply create the service and start it up without a cleanup.  In the
+     * PRISTINE and ROLLBACK modes we do the same but cleanup() before a
+     * restart.
+     *
+     * @see TestServerState#test(TestClass, TestMethod, RunNotifier, InheritableServerSettings) 
+     */
+    public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableServerSettings settings )
+    {
+        LOG.debug( "calling test(): {}, mode {}", settings.getDescription().getDisplayName(), settings.getMode() );
+
+        if ( testMethod.isIgnored() )
+        {
+            // The test is ignored
+            return;
+        }
+
+        switch ( settings.getMode() )
+        {
+            case CUMULATIVE:
+            case RESTART:
+                try
+                {
+                    create( settings );
+                }
+                catch ( NamingException ne )
+                {
+                    LOG.error( "Failed to create and start new server instance: " + ne );
+                    notifier.testAborted( settings.getDescription(), ne );
+                    return;
+                }
+
+                try
+                {
+                    startup();
+                }
+                catch ( Exception e )
+                {
+                    LOG.error( "Failed to create and start new server instance: " + e );
+                    notifier.testAborted( settings.getDescription(), e );
+                    return;
+                }
+
+                
+                context.setState( context.getStartedNormalState() );
+                context.getState().test( testClass, testMethod, notifier, settings );
+                return;
+
+
+            case PRISTINE:
+            case ROLLBACK:
+                try
+                {
+                    create( settings );
+                }
+                catch ( NamingException ne )
+                {
+                    LOG.error( "Failed to create and start new server instance: " + ne );
+                    notifier.testAborted( settings.getDescription(), ne );
+                    return;
+                }
+
+                try
+                {
+                    cleanup();
+                }
+                catch ( IOException ioe )
+                {
+                    LOG.error( "Failed to create and start new server instance: " + ioe );
+                    notifier.testAborted( settings.getDescription(), ioe );
+                    return;
+                }
+
+                try
+                {
+                    startup();
+                }
+                catch ( Exception e )
+                {
+                    LOG.error( "Failed to create and start new server instance: " + e );
+                    notifier.testAborted( settings.getDescription(), e );
+                    return;
+                }
+
+                context.setState( context.getStartedPristineState() );
+                context.getState().test( testClass, testMethod, notifier, settings );
+                return;
+
+            default:
+                return;
+        }
+    }
+}

Propchange: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/NonExistentState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedNormalState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedNormalState.java?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedNormalState.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedNormalState.java Mon Jul 28 23:02:08 2008
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.integ.state;
+
+
+import java.io.IOException;
+
+import org.apache.directory.server.integ.InheritableServerSettings;
+import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
+import org.junit.internal.runners.TestClass;
+import org.junit.internal.runners.TestMethod;
+import org.junit.runner.notification.RunNotifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * The state of a running test service which has been used for running
+ * integration tests and has been reverted to contain the same content as it
+ * did when created and started.  It is not really pristine however for all
+ * practical purposes of integration testing it appears to be the same as
+ * when first started.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class StartedNormalState extends AbstractState
+{
+    private static final Logger LOG = LoggerFactory.getLogger( StartedNormalState.class );
+
+
+    /**
+     * 
+     * Creates a new instance of StartedNormalState.
+     *
+     * @param context the test's context
+     */
+    public StartedNormalState( TestServerContext context )
+    {
+        super( context );
+    }
+
+
+    /**
+     * Action where an attempt is made to destroy the service. This
+     * entails nulling out reference to it and triggering garbage
+     * collection.
+     */
+    public void destroy()
+    {
+        LOG.debug( "calling destroy()" );
+        context.getLdapServer().setDirectoryService( null );
+        context.setLdapServer( null );
+        context.setState( context.getNonExistentState() );
+        System.gc();
+    }
+
+
+    /**
+     * Action where an attempt is made to erase the contents of the
+     * working directory used by the service for various files including
+     * partition database files.
+     *
+     * @throws IOException on errors while deleting the working directory
+     */
+    public void cleanup() throws IOException
+    {
+        LOG.debug( "calling cleanup()" );
+        doDelete( context.getLdapServer().getDirectoryService().getWorkingDirectory() );
+    }
+
+
+    /**
+     * Action where an attempt is made to start up the service.
+     *
+     * @throws Exception on failures to start the core directory service
+     */
+    public void startup() throws Exception
+    {
+        LOG.debug( "calling start()" );
+        context.getLdapServer().getDirectoryService().startup();
+        context.getLdapServer().start();
+    }
+
+
+    /**
+     * Action where an attempt is made to shutdown the service.
+     *
+     * @throws Exception on failures to stop the core directory service
+     */
+    public void shutdown() throws Exception
+    {
+        LOG.debug( "calling shutdown()" );
+        context.getLdapServer().stop();
+        context.getLdapServer().getDirectoryService().shutdown();
+    }
+
+
+    /**
+     * Action where an attempt is made to revert the service to it's
+     * initial start up state by using a previous snapshot.
+     *
+     * @throws Exception on failures to revert the state of the core
+     * directory service
+     */
+    public void revert() throws Exception
+    {
+        LOG.debug( "calling revert()" );
+        context.getLdapServer().getDirectoryService().revert();
+    }
+
+
+    /**
+     * Action where an attempt is made to run a test against the service.
+     *
+     * All annotations should have already been processed for
+     * InheritableServerSettings yet they and others can be processed since we have
+     * access to the method annotations below
+     *
+     * @param testClass the class whose test method is to be run
+     * @param testMethod the test method which is to be run
+     * @param notifier a notifier to report failures to
+     * @param settings the inherited settings and annotations associated with
+     * the test method
+     */
+    public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableServerSettings settings )
+    {
+        LOG.debug( "calling test(): {}, mode {}", settings.getDescription().getDisplayName(), settings.getMode() );
+
+        if ( testMethod.isIgnored() )
+        {
+            // The test is ignored
+            return;
+        }
+
+        switch ( settings.getMode() )
+        {
+            case ROLLBACK:
+                try
+                {
+                    context.getLdapServer().getDirectoryService().getChangeLog().tag();
+                }
+                catch ( Exception e )
+                {
+                    // @TODO - we might want to check the revision of the service before
+                    // we presume that it has been soiled.  Some tests may simply perform
+                    // some read operations or checks on the service and may not alter it
+                    notifier.testAborted( settings.getDescription(), e );
+                    return;
+                }
+
+                // Inject the LDIFs, if any 
+                injectLdifs( context.getLdapServer().getDirectoryService(), settings );
+                
+                TestServerContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+                
+                try
+                {
+                    revert();
+                }
+                catch ( Exception e )
+                {
+                    // @TODO - we might want to check the revision of the service before
+                    // we presume that it has been soiled.  Some tests may simply perform
+                    // some read operations or checks on the service and may not alter it
+                    notifier.testAborted( settings.getDescription(), e );
+                    return;
+                }
+                
+                return;
+                
+            case RESTART :
+                // Inject the LDIFs, if any 
+                injectLdifs( context.getLdapServer().getDirectoryService(), settings );
+                
+
+                TestServerContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+
+                try
+                {
+                    shutdown();
+                }
+                catch ( Exception e )
+                {
+                    // @TODO - we might want to check the revision of the service before
+                    // we presume that it has been soiled.  Some tests may simply perform
+                    // some read operations or checks on the service and may not alter it
+                    notifier.testAborted( settings.getDescription(), e );
+                    return;
+                }
+                
+                try
+                {
+                    startup();
+                }
+                catch ( Exception e )
+                {
+                    LOG.error( "Failed to create and start new server instance: " + e );
+                    notifier.testAborted( settings.getDescription(), e );
+                    return;
+                }
+                
+                return;
+                
+            default:
+                return;
+        }
+    }
+}

Propchange: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedNormalState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java Mon Jul 28 23:02:08 2008
@@ -0,0 +1,213 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.integ.state;
+
+
+import java.io.IOException;
+
+import org.apache.directory.server.integ.InheritableServerSettings;
+import org.apache.directory.server.newldap.LdapServer;
+
+import static org.apache.directory.server.core.integ.IntegrationUtils.doDelete;
+import org.junit.internal.runners.TestClass;
+import org.junit.internal.runners.TestMethod;
+import org.junit.runner.notification.RunNotifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A test service state where the server is running and has not been used for
+ * any integration test since it was created.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class StartedPristineState extends AbstractState
+{
+    private static final Logger LOG = LoggerFactory.getLogger( StartedPristineState.class );
+
+
+    /**
+     * 
+     * Creates a new instance of StartedPristineState.
+     *
+     * @param context the test's context
+     */
+    public StartedPristineState( TestServerContext context )
+    {
+        super( context );
+    }
+
+
+    /**
+     * Action where an attempt is made to erase the contents of the
+     * working directory used by the ldap server for various files including
+     * partition database files.
+     *
+     * @throws IOException on errors while deleting the working directory
+     */
+    public void cleanup() throws IOException
+    {
+        LOG.debug( "calling cleanup()" );
+        doDelete( context.getLdapServer().getDirectoryService().getWorkingDirectory() );
+    }
+
+
+    /**
+     * Action where an attempt is made to start up the service.
+     *
+     * @throws Exception on failures to start the core directory service
+     */
+    public void startup() throws Exception
+    {
+        LOG.debug( "calling start()" );
+        LdapServer server = context.getLdapServer();
+        server.getDirectoryService().startup();
+        server.start();
+    }
+
+
+    /**
+     * Action where an attempt is made to stop the server.
+     *
+     * @throws Exception on failures to stop the ldap server
+     */
+    public void shutdown() throws Exception
+    {
+        LOG.debug( "calling stop()" );
+        LdapServer server = context.getLdapServer();
+        server.stop();
+        server.getDirectoryService().shutdown();
+    }
+
+
+    /**
+     * Action where an attempt is made to destroy the service. This
+     * entails nulling out reference to it and triggering garbage
+     * collection.
+     */
+    public void destroy()
+    {
+        LOG.debug( "calling destroy()" );
+        context.getLdapServer().setDirectoryService( null );
+        context.setLdapServer( null );
+        context.setState( context.getNonExistentState() );
+        System.gc();
+    }
+
+
+    /**
+     * Action where an attempt is made to run a test against the service.
+     *
+     * All annotations should have already been processed for
+     * InheritableServerSettings yet they and others can be processed since we have
+     * access to the method annotations below
+     *
+     * @param testClass the class whose test method is to be run
+     * @param testMethod the test method which is to be run
+     * @param notifier a notifier to report failures to
+     * @param settings the inherited settings and annotations associated with
+     * the test method
+     */
+    public void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableServerSettings settings )
+    {
+        LOG.debug( "calling test(): {}, mode {}", settings.getDescription().getDisplayName(), settings.getMode() );
+
+        if ( testMethod.isIgnored() )
+        {
+            // The test is ignored
+            return;
+        }
+
+        switch ( settings.getMode() )
+        {
+            case PRISTINE:
+                // Inject the LDIFs, if any 
+                injectLdifs( context.getLdapServer().getDirectoryService(), settings );
+                
+                TestServerContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+                
+                try
+                {
+                    shutdown();
+                }
+                catch ( Exception e )
+                {
+                    // @TODO - we might want to check the revision of the service before
+                    // we presume that it has been soiled.  Some tests may simply perform
+                    // some read operations or checks on the service and may not alter it
+                    notifier.testAborted( settings.getDescription(), e );
+                    return;
+                }
+                
+                try
+                {
+                    cleanup();
+                }
+                catch ( IOException ioe )
+                {
+                    LOG.error( "Failed to cleanup new server instance: " + ioe );
+                    notifier.testAborted( settings.getDescription(), ioe );
+                    return;
+                }
+
+                destroy();
+                context.setState( context.getNonExistentState() );
+                return;
+                
+            case ROLLBACK:
+                try
+                {
+                    context.getLdapServer().getDirectoryService().getChangeLog().tag();
+                }
+                catch ( Exception e )
+                {
+                    // @TODO - we might want to check the revision of the service before
+                    // we presume that it has been soiled.  Some tests may simply perform
+                    // some read operations or checks on the service and may not alter it
+                    notifier.testAborted( settings.getDescription(), e );
+                    return;
+                }
+
+                // Inject the LDIFs, if any 
+                injectLdifs( context.getLdapServer().getDirectoryService(), settings );
+                
+                TestServerContext.invokeTest( testClass, testMethod, notifier, settings.getDescription() );
+                context.setState( context.getStartedNormalState() );
+
+                try
+                {
+                    context.getState().revert();
+                }
+                catch ( Exception e )
+                {
+                    // @TODO - we might want to check the revision of the service before
+                    // we presume that it has been soiled.  Some tests may simply perform
+                    // some read operations or checks on the service and may not alter it
+                    notifier.testAborted( settings.getDescription(), e );
+                    return;
+                }
+                return;
+
+            default:
+                return;
+        }
+    }
+}

Propchange: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/StartedPristineState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java?rev=680629&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java (added)
+++ directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java Mon Jul 28 23:02:08 2008
@@ -0,0 +1,294 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.integ.state;
+
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import javax.naming.NamingException;
+
+import org.apache.directory.server.integ.InheritableServerSettings;
+import org.apache.directory.server.newldap.LdapServer;
+import org.junit.internal.runners.MethodRoadie;
+import org.junit.internal.runners.TestClass;
+import org.junit.internal.runners.TestMethod;
+import org.junit.runner.Description;
+import org.junit.runner.notification.RunNotifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The context for managing the state of an integration test service.
+ * Each thread of execution driving tests manages it's own service context.
+ * Hence parallelism can be achieved while running integration tests.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class TestServerContext
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( TestServerContext.class );
+    
+    /** The ThreadLocal containing the contexts */
+    private static final ThreadLocal<TestServerContext> CONTEXTS = new ThreadLocal<TestServerContext>();
+
+    /** The NonExistant state instance */
+    private final TestServerState nonExistentState = new NonExistentState( this );
+
+    /** The StartedPristine state instance */
+    private final TestServerState startedPristineState = new StartedPristineState( this );
+    
+    /** The StartedNormal state instance */
+    private final TestServerState startedNormalState = new StartedNormalState( this );
+
+
+    /** current service state with respect to the testing life cycle */
+    private TestServerState state = nonExistentState;
+
+    /** the ldap server managed by this context */
+    private LdapServer ldapServer;
+
+
+    /**
+     * A private constructor, the clas contains only static methods, 
+     * no need to construct an instance.
+     */
+    private TestServerContext()
+    {
+        
+    }
+
+
+    /**
+     * Gets the TestServerContext associated with the current thread of
+     * execution.  If one does not yet exist it will be created.
+     *
+     * @return the context associated with the calling thread
+     */
+    public static TestServerContext get()
+    {
+        TestServerContext context = CONTEXTS.get();
+
+        if ( context == null )
+        {
+            context = new TestServerContext();
+            CONTEXTS.set( context );
+        }
+
+        return context;
+    }
+    
+
+    /**
+     * Sets the TestServerContext for this current thread
+     *
+     * @param context the context associated with the calling thread
+     */
+    public static void set( TestServerContext context )
+    {
+        CONTEXTS.set( context );
+    }
+
+
+    /**
+     * Action where an attempt is made to create the service.  Service
+     * creation in this system is the combined instantiation and
+     * configuration which takes place when the factory is used to get
+     * a new instance of the service.
+     *
+     * @param settings the settings for this test
+     * @throws NamingException if we can't create the service
+     */
+    public static void create( InheritableServerSettings settings ) throws NamingException
+    {
+        get().state.create( settings );
+    }
+
+
+    /**
+     * Action where an attempt is made to destroy the service.  This
+     * entails nulling out reference to it and triggering garbage
+     * collection.
+     */
+    public static void destroy()
+    {
+        get().state.destroy();
+    }
+
+
+    /**
+     * Action where an attempt is made to erase the contents of the
+     * working directory used by the service for various files including
+     * partition database files.
+     *
+     * @throws IOException on errors while deleting the working directory
+     */
+    public static void cleanup() throws IOException
+    {
+        get().state.cleanup();
+    }
+
+
+    /**
+     * Action where an attempt is made to start up the service.
+     *
+     * @throws Exception on failures to start the core directory service
+     */
+    public static void startup() throws Exception
+    {
+        get().state.startup();
+    }
+
+
+    /**
+     * Action where an attempt is made to shutdown the service.
+     *
+     * @throws Exception on failures to stop the core directory service
+     */
+    public static void shutdown() throws Exception
+    {
+        get().state.shutdown();
+    }
+
+
+    /**
+     * Action where an attempt is made to run a test against the service.
+     *
+     * @param testClass the class whose test method is to be run
+     * @param testMethod the test method which is to be run
+     * @param notifier a notifier to report failures to
+     * @param settings the inherited settings and annotations associated with
+     * the test method
+     */
+    public static void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier,
+                             InheritableServerSettings settings )
+    {
+        LOG.debug( "calling test(): {}", settings.getDescription().getDisplayName() );
+        get().getState().test( testClass, testMethod, notifier, settings );
+    }
+
+
+    /**
+     * Action where an attempt is made to revert the service to it's
+     * initial start up state by using a previous snapshot.
+     *
+     * @throws Exception on failures to revert the state of the core
+     * directory service
+     */
+    public static void revert() throws Exception
+    {
+        get().state.revert();
+    }
+
+
+    static void invokeTest( TestClass testClass, TestMethod testMethod, RunNotifier notifier, Description description )
+    {
+        try
+        {
+            Object test = testClass.getConstructor().newInstance();
+            Field field = testClass.getJavaClass().getDeclaredField( "ldapServer" );
+            field.set( testClass.getJavaClass(), get().getLdapServer() );
+            
+            // also check and add ctx member with access to server over the wire
+            // TODO add here and make sure we cleanup
+            
+            new MethodRoadie( test, testMethod, notifier, description ).run();
+        }
+        catch ( InvocationTargetException e )
+        {
+            LOG.error( "Failed to invoke test method: " + description.getDisplayName(), e.getCause() );
+            notifier.testAborted( description, e.getCause() );
+            return;
+        }
+        catch ( InstantiationException ie )
+        {
+            LOG.error( "Failed to invoke test method: " + description.getDisplayName(), ie );
+            notifier.testAborted( description, ie );
+            return;
+        }
+        catch ( IllegalAccessException iae )
+        {
+            LOG.error( "Failed to invoke test method: " + description.getDisplayName(), iae );
+            notifier.testAborted( description, iae );
+            return;
+        }
+        catch ( NoSuchMethodException nsme )
+        {
+            LOG.error( "Failed to invoke test method: " + description.getDisplayName(), nsme );
+            notifier.testAborted( description, nsme );
+            return;
+        }
+        catch ( NoSuchFieldException nsfe )
+        {
+            LOG.error( "Failed to invoke test method: " + description.getDisplayName(), nsfe );
+            notifier.testAborted( description, nsfe );
+            return;
+        }
+    }
+
+
+    // -----------------------------------------------------------------------
+    // Package Friendly Instance Methods
+    // -----------------------------------------------------------------------
+
+
+    void setState( TestServerState state )
+    {
+        this.state = state;
+    }
+
+
+    TestServerState getState()
+    {
+        return state;
+    }
+
+
+    TestServerState getNonExistentState()
+    {
+        return nonExistentState;
+    }
+
+
+    TestServerState getStartedPristineState()
+    {
+        return startedPristineState;
+    }
+
+
+    TestServerState getStartedNormalState()
+    {
+        return startedNormalState;
+    }
+
+
+    LdapServer getLdapServer()
+    {
+        return ldapServer;
+    }
+
+
+    void setLdapServer( LdapServer ldapServer )
+    {
+        this.ldapServer = ldapServer;
+    }
+}

Propchange: directory/apacheds/branches/bigbang/server-integ/src/main/java/org/apache/directory/server/integ/state/TestServerContext.java
------------------------------------------------------------------------------
    svn:eol-style = native