001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019 package org.apache.directory.server.integ.state;
020
021
022 import java.io.IOException;
023 import javax.naming.NamingException;
024
025 import org.apache.directory.server.integ.InheritableServerSettings;
026 import org.junit.runner.notification.RunNotifier;
027 import org.junit.runners.model.Statement;
028 import org.junit.runners.model.TestClass;
029
030
031 /**
032 * The interface representing a state in the lifecycle of a service
033 * during integration testing.
034 *
035 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
036 * @version $Rev$, $Date$
037 */
038 public interface TestServerState
039 {
040 /**
041 * Action where an attempt is made to create the service. Service
042 * creation in this system is the combined instantiation and
043 * configuration which takes place when the factory is used to get
044 * a new instance of the service.
045 *
046 * @param settings The inherited settings
047 * @throws NamingException if we can't create the service
048 */
049 void create( InheritableServerSettings settings ) throws NamingException;
050
051
052 /**
053 * Action where an attempt is made to destroy the service. This
054 * entails nulling out reference to it and triggering garbage
055 * collection.
056 */
057 void destroy();
058
059
060 /**
061 * Action where an attempt is made to erase the contents of the
062 * working directory used by the service for various files including
063 * partition database files.
064 *
065 * @throws IOException on errors while deleting the working directory
066 */
067 void cleanup() throws IOException;
068
069
070 /**
071 * Action where an attempt is made to start up the service.
072 *
073 * @throws Exception on failures to start the core directory service
074 */
075 void startup() throws Exception;
076
077
078 /**
079 * Action where an attempt is made to shutdown the service.
080 *
081 * @throws Exception on failures to stop the core directory service
082 */
083 void shutdown() throws Exception;
084
085
086 /**
087 * Action where an attempt is made to run a test against the service.
088 *
089 * All annotations should have already been processed for
090 * InheritableServerSettings yet they and others can be processed since we have
091 * access to the method annotations below
092 *
093 * @param testClass the class whose test method is to be run
094 * @param statement the test method which is to be run
095 * @param notifier a notifier to report failures to
096 * @param settings the inherited settings and annotations associated with
097 * the test method
098 */
099 void test( TestClass testClass, Statement statement, RunNotifier notifier, InheritableServerSettings settings );
100
101
102 /**
103 * Action where an attempt is made to revert the service to it's
104 * initial start up state by using a previous snapshot.
105 *
106 * @throws Exception on failures to revert the state of the core
107 * directory service
108 */
109 void revert() throws Exception;
110 }