| 1 | /* |
| 2 | * JTiger Unit Testing Framework for J2SE 1.5 |
| 3 | * Copyright (C) 2005 Tony Morris |
| 4 | * |
| 5 | * This software is licenced under the |
| 6 | * Common Public Licence version 1.0 |
| 7 | * http://www.opensource.org/licenses/cpl1.0.php |
| 8 | * |
| 9 | * You received a copy of this licence with this software. |
| 10 | */ |
| 11 | package org.jtiger.framework; |
| 12 | |
| 13 | import java.lang.reflect.Method; |
| 14 | |
| 15 | /** |
| 16 | * Provides a default implementation of defining a unit test case method. |
| 17 | * This implementation determines a test case method as having the {@link Test} annotation present. |
| 18 | * |
| 19 | * @see TestDefinition |
| 20 | * @author %javadoc.author.tag% |
| 21 | * @version %version%<br/> |
| 22 | * <i>Build Number %build.number%</i><br/> |
| 23 | * <i>Build Time %build.time% CET (GMT + 1)</i> |
| 24 | */ |
| 25 | public final class DefaultTestDefinitionFactory |
| 26 | { |
| 27 | private DefaultTestDefinitionFactory() |
| 28 | { |
| 29 | |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Returns a new instance of the definition of a unit test case method. |
| 34 | * |
| 35 | * @return A new instance of the definition of a unit test case method. |
| 36 | */ |
| 37 | public static TestDefinition newDefaultTestDefinition() |
| 38 | { |
| 39 | return new DefaultTestDefinitionImpl(); |
| 40 | } |
| 41 | |
| 42 | private static final class DefaultTestDefinitionImpl implements TestDefinition |
| 43 | { |
| 44 | DefaultTestDefinitionImpl() |
| 45 | { |
| 46 | |
| 47 | } |
| 48 | |
| 49 | public boolean isTest(final Method m) |
| 50 | { |
| 51 | if(m == null) |
| 52 | { |
| 53 | return false; |
| 54 | } |
| 55 | |
| 56 | return m.isAnnotationPresent(Test.class); |
| 57 | } |
| 58 | } |
| 59 | } |