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.core.integ.state; 20 21 import java.io.IOException; 22 import javax.naming.NamingException; 23 24 import org.apache.directory.server.core.integ.InheritableSettings; 25 import org.junit.internal.runners.TestClass; 26 import org.junit.internal.runners.TestMethod; 27 import org.junit.runner.notification.RunNotifier; 28 29 30 /** 31 * The interface representing a state in the lifecycle of a service 32 * during integration testing. 33 * 34 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 35 * @version $Rev$, $Date$ 36 */ 37 public interface TestServiceState 38 { 39 /** 40 * Action where an attempt is made to create the service. Service 41 * creation in this system is the combined instantiation and 42 * configuration which takes place when the factory is used to get 43 * a new instance of the service. 44 * 45 * @param settings The inherited settings 46 * @throws NamingException if we can't create the service 47 */ 48 void create( InheritableSettings settings ) throws NamingException; 49 50 51 /** 52 * Action where an attempt is made to destroy the service. This 53 * entails nulling out reference to it and triggering garbage 54 * collection. 55 */ 56 void destroy(); 57 58 59 /** 60 * Action where an attempt is made to erase the contents of the 61 * working directory used by the service for various files including 62 * partition database files. 63 * 64 * @throws IOException on errors while deleting the working directory 65 */ 66 void cleanup() throws IOException; 67 68 69 /** 70 * Action where an attempt is made to start up the service. 71 * 72 * @throws Exception on failures to start the core directory service 73 */ 74 void startup() throws Exception; 75 76 77 /** 78 * Action where an attempt is made to shutdown the service. 79 * 80 * @throws Exception on failures to stop the core directory service 81 */ 82 void shutdown() throws Exception; 83 84 85 /** 86 * Action where an attempt is made to run a test against the service. 87 * 88 * All annotations should have already been processed for 89 * InheritableSettings yet they and others can be processed since we have 90 * access to the method annotations below 91 * 92 * @param testClass the class whose test method is to be run 93 * @param testMethod the test method which is to be run 94 * @param notifier a notifier to report failures to 95 * @param settings the inherited settings and annotations associated with 96 * the test method 97 */ 98 void test( TestClass testClass, TestMethod testMethod, RunNotifier notifier, InheritableSettings settings ); 99 100 101 /** 102 * Action where an attempt is made to revert the service to it's 103 * initial start up state by using a previous snapshot. 104 * 105 * @throws Exception on failures to revert the state of the core 106 * directory service 107 */ 108 void revert() throws Exception; 109 }