001/* 002 * Copyright 2002-2014 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.test.context.support; 018 019import org.springframework.core.Ordered; 020import org.springframework.test.context.TestContext; 021import org.springframework.test.context.TestExecutionListener; 022 023/** 024 * Abstract implementation of the {@link TestExecutionListener} interface which 025 * provides empty method stubs. Subclasses can extend this class and override 026 * only those methods suitable for the task at hand. 027 * 028 * @author Sam Brannen 029 * @author Juergen Hoeller 030 * @since 2.5 031 */ 032public abstract class AbstractTestExecutionListener implements TestExecutionListener, Ordered { 033 034 /** 035 * The default implementation is <em>empty</em>. Can be overridden by 036 * subclasses as necessary. 037 */ 038 @Override 039 public void beforeTestClass(TestContext testContext) throws Exception { 040 /* no-op */ 041 } 042 043 /** 044 * The default implementation is <em>empty</em>. Can be overridden by 045 * subclasses as necessary. 046 */ 047 @Override 048 public void prepareTestInstance(TestContext testContext) throws Exception { 049 /* no-op */ 050 } 051 052 /** 053 * The default implementation is <em>empty</em>. Can be overridden by 054 * subclasses as necessary. 055 */ 056 @Override 057 public void beforeTestMethod(TestContext testContext) throws Exception { 058 /* no-op */ 059 } 060 061 /** 062 * The default implementation is <em>empty</em>. Can be overridden by 063 * subclasses as necessary. 064 */ 065 @Override 066 public void afterTestMethod(TestContext testContext) throws Exception { 067 /* no-op */ 068 } 069 070 /** 071 * The default implementation is <em>empty</em>. Can be overridden by 072 * subclasses as necessary. 073 */ 074 @Override 075 public void afterTestClass(TestContext testContext) throws Exception { 076 /* no-op */ 077 } 078 079 /** 080 * The default implementation returns {@link Ordered#LOWEST_PRECEDENCE}, 081 * thereby ensuring that custom listeners are ordered after default 082 * listeners supplied by the framework. Can be overridden by subclasses 083 * as necessary. 084 * @since 4.1 085 */ 086 @Override 087 public int getOrder() { 088 return Ordered.LOWEST_PRECEDENCE; 089 } 090 091}