001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.test.rule.callback;
016    
017    import java.lang.reflect.Method;
018    
019    import org.junit.runner.Description;
020    
021    /**
022     * @author Shuyang Zhou
023     */
024    public class BaseTestCallback<C, M> implements TestCallback<C, M> {
025    
026            @Override
027            public void afterClass(Class<?> clazz, C c) throws Throwable {
028                    doAfterClass(Description.createSuiteDescription(clazz), c);
029            }
030    
031            @Override
032            public void afterMethod(Class<?> clazz, Method method, M m, Object target)
033                    throws Throwable {
034    
035                    doAfterMethod(
036                            Description.createTestDescription(clazz, method.getName()), m,
037                            target);
038            }
039    
040            @Override
041            public C beforeClass(Class<?> clazz) throws Throwable {
042                    return doBeforeClass(Description.createSuiteDescription(clazz));
043            }
044    
045            @Override
046            public M beforeMethod(Class<?> clazz, Method method, Object target)
047                    throws Throwable {
048    
049                    return doBeforeMethod(
050                            Description.createTestDescription(clazz, method.getName()), target);
051            }
052    
053            public void doAfterClass(Description description, C c) throws Throwable {
054            }
055    
056            public void doAfterMethod(Description description, M m, Object target)
057                    throws Throwable {
058            }
059    
060            public C doBeforeClass(Description description) throws Throwable {
061                    return null;
062            }
063    
064            public M doBeforeMethod(Description description, Object target)
065                    throws Throwable {
066    
067                    return null;
068            }
069    
070    }