1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.directory.server.integ.state; 20 21 22 import java.io.IOException; 23 import javax.naming.NamingException; 24 25 import org.apache.directory.server.integ.InheritableServerSettings; 26 import org.junit.internal.runners.TestClass; 27 import org.junit.internal.runners.TestMethod; 28 import org.junit.runner.notification.RunNotifier; 29 30 31 /** 32 * The interface representing a state in the lifecycle of a service 33 * during integration testing. 34 * 35 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 36 * @version $Rev$, $Date$ 37 */ 38 public interface TestServerState 39 { 40 /** 41 * Action where an attempt is made to create the service. Service 42 * creation in this system is the combined instantiation and 43 * configuration which takes place when the factory is used to get 44 * a new instance of the service. 45 * 46 * @param settings The inherited settings 47 * @throws NamingException if we can't create the service 48 */ 49 void create( InheritableServerSettings settings ) throws NamingException; 50 51 52 /** 53 * Action where an attempt is made to destroy the service. This 54 * entails nulling out reference to it and triggering garbage 55 * collection. 56 */ 57 void destroy(); 58 59 60 /** 61 * Action where an attempt is made to erase the contents of the 62 * working directory used by the service for various files including 63 * partition database files. 64 * 65 * @throws IOException on errors while deleting the working directory 66 */ 67 void cleanup() throws IOException; 68 69 70 /** 71 * Action where an attempt is made to start up the service. 72 * 73 * @throws Exception on failures to start the core directory service 74 */ 75 void startup() throws Exception; 76 77 78 /** 79 * Action where an attempt is made to shutdown the service. 80 * 81 * @throws Exception on failures to stop the core directory service 82 */ 83 void shutdown() throws Exception; 84 85 86 /** 87 * Action where an attempt is made to run a test against the service. 88 * 89 * All annotations should have already been processed for 90 * InheritableServerSettings yet they and others can be processed since we have 91 * access to the method annotations below 92 * 93 * @param testClass the class whose test method is to be run 94 * @param testMethod the test method which is to be run 95 * @param notifier a notifier to report failures to 96 * @param settings the inherited settings and annotations associated with 97 * the test method 98 */ 99 void test( TestClass testClass, TestMethod testMethod, 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 }