KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > test > common > TestAnnotations


1 package org.jacorb.test.common;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 2005 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301, USA.
22  */

23
24 import junit.framework.*;
25
26 /**
27  * Represents JacORB-specific javadoc annotations for JUnit tests.
28  *
29  * @author Andre Spiegel spiegel@gnu.org
30  * @version $Id: TestAnnotations.java,v 1.2 2005/05/13 13:15:27 andre.spiegel Exp $
31  */

32 public class TestAnnotations
33 {
34     private static JacORBVersionComparator jacorbVersionComparator =
35         new JacORBVersionComparator();
36     
37     private String JavaDoc clientSince = null;
38     private String JavaDoc serverSince = null;
39     
40     public TestAnnotations (String JavaDoc clientSince, String JavaDoc serverSince)
41     {
42         this.clientSince = clientSince;
43         this.serverSince = serverSince;
44     }
45     
46     public String JavaDoc getClientSince()
47     {
48         return clientSince;
49     }
50     
51     public String JavaDoc getServerSince()
52     {
53         return serverSince;
54     }
55
56     public static TestAnnotations forTestCase (TestCase t)
57     {
58         TestAnnotationsParser p = TestAnnotationsParser.getInstance(t.getClass());
59         String JavaDoc methodName = t.getName().replaceAll("\\(.+\\)", "");
60         return p.getMethodAnnotations (methodName);
61     }
62     
63     public static TestAnnotations forTestSuite (TestSuite t)
64     {
65         return TestAnnotationsParser.getInstance(t.getClass())
66                                     .getClassAnnotations();
67     }
68     
69     public static TestAnnotations forClass (Class JavaDoc c)
70     {
71         return TestAnnotationsParser.getInstance(c)
72                                     .getClassAnnotations();
73     }
74     
75     /**
76      * Returns true if the entity annotated by these TestAnnotations
77      * is applicable to the given client and server version.
78      */

79     public boolean isApplicableTo (String JavaDoc clientVersion, String JavaDoc serverVersion)
80     {
81         int clientCompare = jacorbVersionComparator.compare (clientVersion,
82                                                              clientSince);
83         int serverCompare = jacorbVersionComparator.compare (serverVersion,
84                                                              serverSince);
85         return clientCompare >= 0 && serverCompare >= 0;
86     }
87     
88 }
89
Popular Tags