KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * @(#)Sample3ImplIUTest.java
3  *
4  * Original author is Matt Albrecht
5  * groboclown@users.sourceforge.net
6  * http://groboutils.sourceforge.net
7  *
8  * This code sample has been submitted to the public domain, to show uses
9  * 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 /**
24  * Tests the Sample3Impl class.
25  * <P>
26  * Formatted for 70-column publication.
27  *
28  * @author Matt Albrecht <a HREF="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
29  * @version $Date: 2002/07/28 22:43:58 $
30  * @since July 20, 2002
31  */

32 public class Sample3ImplIUTest extends TestCase {
33     private static final Class JavaDoc THIS_CLASS = Sample3ImplIUTest.class;
34     
35     public Sample3ImplIUTest( String JavaDoc name ) {
36         super( name );
37     }
38
39     //-------------------------------------------------------------------------
40
// Tests
41

42     public void testConstructor1() {
43         new Sample3Impl( (String JavaDoc[])null );
44     }
45     
46     
47     public static class Sample2ImplFactory
48         implements Sample2IUTestI.Sample2Factory {
49         public Sample2 create( String JavaDoc[] s ) {
50             return new Sample3Impl( s );
51         }
52         
53         public Sample2 create( String JavaDoc s ) {
54             return new Sample3Impl( new String JavaDoc[] { s } );
55         }
56     }
57     
58     
59     public static Test suite() {
60         TestSuite suite = new TestSuite( THIS_CLASS );
61         
62         //------
63
// These two InterfaceTestSuites will share the same set of
64
// factories
65
InterfaceTestSuite its = Sample3IUTestI.suite();
66         its.addInterfaceTestSuite( Sample4IUTestI.suite() );
67         its.addFactory( new ImplFactory() {
68             public Object JavaDoc createImplObject() {
69                 return new Sample3Impl();
70             }
71         } );
72         its.addFactory( new ImplFactory() {
73             public Object JavaDoc createImplObject() {
74                 return new Sample3Impl( new String JavaDoc[] { "a", "b" } );
75             }
76         } );
77         suite.addTest( its );
78         
79         //------
80
// This InterfaceTestSuite needs a different kind of factory.
81
its = Sample2IUTestI.suite();
82         its.addFactory( new ImplFactory() {
83             public Object JavaDoc createImplObject() {
84                 return new Sample2ImplFactory();
85             }
86         } );
87         suite.addTest( its );
88         
89         return suite;
90     }
91     
92     public static void main( String JavaDoc[] args ) {
93         String JavaDoc[] name = { THIS_CLASS.getName() };
94         
95         junit.textui.TestRunner.main( name );
96     }
97 }
98
99
Popular Tags