001/* 002 * Copyright 2002-2019 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 {@linkplain Ordered ordered} implementation of the 025 * {@link TestExecutionListener} API. 026 * 027 * @author Sam Brannen 028 * @author Juergen Hoeller 029 * @since 2.5 030 * @see #getOrder() 031 */ 032public abstract class AbstractTestExecutionListener implements TestExecutionListener, Ordered { 033 034 /** 035 * The default implementation returns {@link Ordered#LOWEST_PRECEDENCE}, 036 * thereby ensuring that custom listeners are ordered after default 037 * listeners supplied by the framework. Can be overridden by subclasses 038 * as necessary. 039 * @since 4.1 040 */ 041 @Override 042 public int getOrder() { 043 return Ordered.LOWEST_PRECEDENCE; 044 } 045 046 /** 047 * The default implementation is <em>empty</em>. Can be overridden by 048 * subclasses as necessary. 049 * @since 3.0 050 */ 051 @Override 052 public void beforeTestClass(TestContext testContext) throws Exception { 053 /* no-op */ 054 } 055 056 /** 057 * The default implementation is <em>empty</em>. Can be overridden by 058 * subclasses as necessary. 059 */ 060 @Override 061 public void prepareTestInstance(TestContext testContext) throws Exception { 062 /* no-op */ 063 } 064 065 /** 066 * The default implementation is <em>empty</em>. Can be overridden by 067 * subclasses as necessary. 068 */ 069 @Override 070 public void beforeTestMethod(TestContext testContext) throws Exception { 071 /* no-op */ 072 } 073 074 /** 075 * The default implementation is <em>empty</em>. Can be overridden by 076 * subclasses as necessary. 077 * @since 5.2 078 */ 079 @Override 080 public void beforeTestExecution(TestContext testContext) throws Exception { 081 /* no-op */ 082 } 083 084 /** 085 * The default implementation is <em>empty</em>. Can be overridden by 086 * subclasses as necessary. 087 * @since 5.2 088 */ 089 @Override 090 public void afterTestExecution(TestContext testContext) throws Exception { 091 /* no-op */ 092 } 093 094 /** 095 * The default implementation is <em>empty</em>. Can be overridden by 096 * subclasses as necessary. 097 */ 098 @Override 099 public void afterTestMethod(TestContext testContext) throws Exception { 100 /* no-op */ 101 } 102 103 /** 104 * The default implementation is <em>empty</em>. Can be overridden by 105 * subclasses as necessary. 106 * @since 3.0 107 */ 108 @Override 109 public void afterTestClass(TestContext testContext) throws Exception { 110 /* no-op */ 111 } 112 113}