1 /* 2 * Copyright 2002-2016 the original author or authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.github.springtestdbunit; 18 19 import java.lang.reflect.Method; 20 21 import org.dbunit.database.IDatabaseConnection; 22 import org.dbunit.dataset.IDataSet; 23 24 import com.github.springtestdbunit.dataset.DataSetLoader; 25 import com.github.springtestdbunit.operation.DatabaseOperationLookup; 26 27 /** 28 * Provides context for the {@link DbUnitRunner}. 29 * 30 * @author Phillip Webb 31 */ 32 public interface DbUnitTestContext { 33 34 /** 35 * Returns the {@link IDatabaseConnection} that should be used when performing database setup and teardown. 36 * @return The connection 37 */ 38 DatabaseConnections getConnections(); 39 40 /** 41 * Returns the {@link DataSetLoader} that should be used to load {@link IDataSet}s. 42 * @return The dataset loader 43 */ 44 DataSetLoader getDataSetLoader(); 45 46 /** 47 * Returns the {@link DatabaseOperationLookup} that should be used to lookup database operations. 48 * @return the database operation lookup 49 */ 50 DatabaseOperationLookup getDatbaseOperationLookup(); 51 52 /** 53 * Returns the class that is under test. 54 * @return The class under test 55 */ 56 Class<?> getTestClass(); 57 58 /** 59 * Returns the instance that is under test. 60 * @return The instance under test 61 */ 62 Object getTestInstance(); 63 64 /** 65 * Returns the method that is under test. 66 * @return The method under test 67 */ 68 Method getTestMethod(); 69 70 /** 71 * Returns any exception that was thrown during the test or <tt>null</tt> if no test exception occurred. 72 * @return the test exception or <tt>null</tt> 73 */ 74 Throwable getTestException(); 75 76 }