| 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 | final class TestDescriptionFactory |
| 16 | { |
| 17 | private TestDescriptionFactory() |
| 18 | { |
| 19 | |
| 20 | } |
| 21 | |
| 22 | static TestDescription newTestDescription() |
| 23 | { |
| 24 | return new TestDescriptionImpl(); |
| 25 | } |
| 26 | |
| 27 | private static final class TestDescriptionImpl implements TestDescription |
| 28 | { |
| 29 | TestDescriptionImpl() |
| 30 | { |
| 31 | |
| 32 | } |
| 33 | |
| 34 | public String getTestDescription(final Method m) throws NullPointerException |
| 35 | { |
| 36 | if(m == null) |
| 37 | { |
| 38 | throw new NullPointerException(); |
| 39 | } |
| 40 | |
| 41 | final Test t = m.getAnnotation(Test.class); |
| 42 | |
| 43 | if(t == null) |
| 44 | { |
| 45 | return null; |
| 46 | } |
| 47 | |
| 48 | return t.description(); |
| 49 | } |
| 50 | } |
| 51 | } |