01: /*
02: * @(#)Sample3ImplIUTest.java
03: *
04: * Original author is Matt Albrecht
05: * groboclown@users.sourceforge.net
06: * http://groboutils.sourceforge.net
07: *
08: * This code sample has been submitted to the public domain, to show uses
09: * for the Interface testing framework.
10: *
11: * This program is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14: */
15:
16: package net.sourceforge.groboutils.junit.v1.iftc;
17:
18: import junit.framework.Test;
19: import junit.framework.TestCase;
20: import junit.framework.TestSuite;
21:
22: /**
23: * Tests the Sample3Impl class.
24: * <P>
25: * Formatted for 70-column publication.
26: *
27: * @author Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
28: * @version $Date: 2002/07/28 22:43:58 $
29: * @since July 20, 2002
30: */
31: public class Sample3ImplIUTest extends TestCase {
32: private static final Class THIS_CLASS = Sample3ImplIUTest.class;
33:
34: public Sample3ImplIUTest(String name) {
35: super (name);
36: }
37:
38: //-------------------------------------------------------------------------
39: // Tests
40:
41: public void testConstructor1() {
42: new Sample3Impl((String[]) null);
43: }
44:
45: public static class Sample2ImplFactory implements
46: Sample2IUTestI.Sample2Factory {
47: public Sample2 create(String[] s) {
48: return new Sample3Impl(s);
49: }
50:
51: public Sample2 create(String s) {
52: return new Sample3Impl(new String[] { s });
53: }
54: }
55:
56: public static Test suite() {
57: TestSuite suite = new TestSuite(THIS_CLASS);
58:
59: //------
60: // These two InterfaceTestSuites will share the same set of
61: // factories
62: InterfaceTestSuite its = Sample3IUTestI.suite();
63: its.addInterfaceTestSuite(Sample4IUTestI.suite());
64: its.addFactory(new ImplFactory() {
65: public Object createImplObject() {
66: return new Sample3Impl();
67: }
68: });
69: its.addFactory(new ImplFactory() {
70: public Object createImplObject() {
71: return new Sample3Impl(new String[] { "a", "b" });
72: }
73: });
74: suite.addTest(its);
75:
76: //------
77: // This InterfaceTestSuite needs a different kind of factory.
78: its = Sample2IUTestI.suite();
79: its.addFactory(new ImplFactory() {
80: public Object createImplObject() {
81: return new Sample2ImplFactory();
82: }
83: });
84: suite.addTest(its);
85:
86: return suite;
87: }
88:
89: public static void main(String[] args) {
90: String[] name = { THIS_CLASS.getName() };
91:
92: junit.textui.TestRunner.main(name);
93: }
94: }
|