01: /*
02: * @(#)ImplFactory.java
03: *
04: * Copyright (C) 2002-2003 Matt Albrecht
05: * groboclown@users.sourceforge.net
06: * http://groboutils.sourceforge.net
07: *
08: * Permission is hereby granted, free of charge, to any person obtaining a
09: * 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: * Allows for tests to be written on interfaces or abstract classes, by creating
31: * a specific instance of the interface or abstract class. Test classes will
32: * invoke this method to retrieve the specific instance for their tests.
33: * <P>
34: * Since October 21, 2002, the <tt>createImplObject()</tt> method can now
35: * throw any exception. Some construction implementations throw all kinds
36: * of errors, such as <tt>IOException</tt> or <tt>SQLException</tt>. This
37: * makes the task of creating factories a bit easier, since we no longer
38: * need to worry about proper try/catch blocks.
39: *
40: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
41: * @version $Date: 2003/02/10 22:52:20 $
42: * @since March 2, 2002
43: */
44: public interface ImplFactory {
45: /**
46: * Create a new instance of the interface type for testing through
47: * an InterfaceTest.
48: * <P>
49: * As of 21-Oct-2002, this method can raise any exception, and it will be
50: * correctly caught and reported as a failure by the
51: * <tt>InterfaceTestCase.createImplObject()</tt> method, so that the
52: * creation method can simplify its logic, and add any kind of
53: * initialization without having to worry about the correct way to
54: * handle exceptions.
55: *
56: * @return a new instance of the expected type that the corresponding
57: * <tt>InterfaceTestCase</tt>(s) cover.
58: * @exception Exception thrown under any unexpected condition that
59: * results in the failure to properly create the instance.
60: * @since October 21, 2002: Since this date, this method can now throw
61: * exceptions to make creation a bit easier on us.
62: */
63: public Object createImplObject() throws Exception;
64:
65: /**
66: * All ImplFactory instances should specify a distinguishable name
67: * to help in debugging failed tests due to a particular factory's
68: * instance setup.
69: *
70: * @return a distinguishable name for the factory.
71: * @see CxFactory CxFactory: a helper that simplifies this task for us.
72: */
73: public String toString();
74: }
|