KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > pmti > v1 > autodoc > v1 > AutoDocITImpl


1 /*
2  * @(#)AutoDocITImpl.java
3  *
4  * Copyright (C) 2002-2003 Matt Albrecht
5  * groboclown@users.sourceforge.net
6  * http://groboutils.sourceforge.net
7  *
8  * Part of the GroboUtils package at:
9  * http://groboutils.sourceforge.net
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice shall be included in
19  * all copies or substantial portions of the Software.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  */

29 package net.sourceforge.groboutils.pmti.v1.autodoc.v1;
30
31
32 import net.sourceforge.groboutils.autodoc.v1.AutoDocIT;
33
34 import net.sourceforge.groboutils.autodoc.v1.testserver.TestInfo;
35 import net.sourceforge.groboutils.autodoc.v1.testserver.TestData;
36 import net.sourceforge.groboutils.autodoc.v1.testserver.TestCorrelate;
37 import net.sourceforge.groboutils.autodoc.v1.testserver.MonitorFinder;
38
39 import org.apache.log4j.Logger;
40  
41
42 /**
43  * Issue Tracker entry point. Allows bugs and requriements to be tracked
44  * directly to the test that ensures that part of the bug/requirement has been
45  * fulfilled in the current code base.
46  * <P>
47  * The alternate forms of the base {@link #testsIssue( String, String )} are
48  * for convenience only.
49  *
50  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
51  * @version $Date: 2003/02/10 22:51:56 $
52  * @since March 30, 2002
53  */

54 public class AutoDocITImpl extends TestCorrelate implements AutoDocIT
55 {
56     private static final Logger LOG = Logger.getLogger( AutoDocITImpl.class );
57     
58     /**
59      * Default constructor, which requires an owning class. The monitor
60      * finder will be the default ITFMonitorFinder.
61      */

62     public AutoDocITImpl( Class JavaDoc owner )
63     {
64         this( owner, new ITFMonitorFinder() );
65     }
66     
67     
68     /**
69      * Creates a new implementation of AutoDocIT, with the given owner and
70      * monitor finder.
71      */

72     public AutoDocITImpl( Class JavaDoc owner, MonitorFinder finder )
73     {
74         super( owner, finder );
75         
76         if (owner == null)
77         {
78             throw new IllegalArgumentException JavaDoc("no null args");
79         }
80     }
81     
82     
83     
84     /**
85      * Traces an issue from the owning class and declared method, to the
86      * given ID. This is a <tt>long</tt>, as some systems may allow for
87      * more than 2 billion issues.
88      *
89      * @param methodName the owning class's method to trace the issue back to.
90      * @param issueID the id of the issue being tracked.
91      */

92     public void testsIssue( String JavaDoc methodName, long issueID )
93     {
94         testsIssue( methodName, Long.toString( issueID ) );
95     }
96     
97     
98     /**
99      * Traces an issue from the owning class and declared method, to the
100      * given ID.
101      *
102      * @param methodName the owning class's method to trace the issue back to.
103      * @param issueID the id of the issue being tracked.
104      */

105     public void testsIssue( String JavaDoc methodName, String JavaDoc issueID )
106     {
107         TestInfo ti = createTestInfo( methodName );
108         sendTestIssue( ti, issueID );
109     }
110     
111     
112     /**
113      * Traces an issue from the owning class to the given ID.
114      * The method will still be given to the underlying tracker, but it will
115      * be discovered through the stack trace. Hence, this is a volitile
116      * method for tracking; it should only be called from the owning class
117      * which is actually testing the bug.
118      *
119      * @param issueID the id of the issue being tracked.
120      */

121     public void testsIssue( long issueID )
122     {
123         testsIssue( Long.toString( issueID ) );
124     }
125     
126     
127     /**
128      * Traces an issue from the owning class to the given ID.
129      * The method will still be given to the underlying tracker, but it will
130      * be discovered through the stack trace. Hence, this is a volitile
131      * method for tracking; it should only be called from the owning class
132      * which is actually testing the bug.
133      *
134      * @param issueID the id of the issue being tracked.
135      */

136     public void testsIssue( String JavaDoc issueID )
137     {
138         TestInfo ti = createTestInfoFromStack();
139         sendTestIssue( ti, issueID );
140     }
141     
142     
143     /**
144      * Send the 'testsIssue' call to the monitor.
145      */

146     protected void sendTestIssue( TestInfo ti, String JavaDoc issueID )
147     {
148         TestData td = getTestData( ti );
149
150         if (td == null)
151         {
152             LOG.warn( "test data for "+ti+" never registered." );
153             return;
154         }
155         
156         // assertion for security/robustness
157
if (!(td instanceof ITFTestData))
158         {
159             throw new IllegalStateException JavaDoc( "Expected the monitor to create "+
160                 ITFTestData.class.getName()+", but it created a "+
161                 td.getClass().getName()+" instead." );
162         }
163         ((ITFTestData)td).addIssueID( issueID );
164     }
165 }
166
167
Popular Tags