KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > groboutils > junit > v1 > iftc > ImplFactory


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

26
27 package net.sourceforge.groboutils.junit.v1.iftc;
28
29
30
31 /**
32  * Allows for tests to be written on interfaces or abstract classes, by creating
33  * a specific instance of the interface or abstract class. Test classes will
34  * invoke this method to retrieve the specific instance for their tests.
35  * <P>
36  * Since October 21, 2002, the <tt>createImplObject()</tt> method can now
37  * throw any exception. Some construction implementations throw all kinds
38  * of errors, such as <tt>IOException</tt> or <tt>SQLException</tt>. This
39  * makes the task of creating factories a bit easier, since we no longer
40  * need to worry about proper try/catch blocks.
41  *
42  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
43  * @version $Date: 2003/02/10 22:52:20 $
44  * @since March 2, 2002
45  */

46 public interface ImplFactory
47 {
48     /**
49      * Create a new instance of the interface type for testing through
50      * an InterfaceTest.
51      * <P>
52      * As of 21-Oct-2002, this method can raise any exception, and it will be
53      * correctly caught and reported as a failure by the
54      * <tt>InterfaceTestCase.createImplObject()</tt> method, so that the
55      * creation method can simplify its logic, and add any kind of
56      * initialization without having to worry about the correct way to
57      * handle exceptions.
58      *
59      * @return a new instance of the expected type that the corresponding
60      * <tt>InterfaceTestCase</tt>(s) cover.
61      * @exception Exception thrown under any unexpected condition that
62      * results in the failure to properly create the instance.
63      * @since October 21, 2002: Since this date, this method can now throw
64      * exceptions to make creation a bit easier on us.
65      */

66     public Object JavaDoc createImplObject() throws Exception JavaDoc;
67     
68     
69     /**
70      * All ImplFactory instances should specify a distinguishable name
71      * to help in debugging failed tests due to a particular factory's
72      * instance setup.
73      *
74      * @return a distinguishable name for the factory.
75      * @see CxFactory CxFactory: a helper that simplifies this task for us.
76      */

77     public String JavaDoc toString();
78 }
79
80
Popular Tags