Source Code Cross Referenced for CxFactoryUTest.java in  » Test-Coverage » GroboUtils » net » sourceforge » groboutils » junit » v1 » iftc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » GroboUtils » net.sourceforge.groboutils.junit.v1.iftc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)CxFactoryUTest.java
003:         *
004:         * Copyright (C) 2002-2003 Matt Albrecht
005:         * groboclown@users.sourceforge.net
006:         * http://groboutils.sourceforge.net
007:         *
008:         *  Permission is hereby granted, free of charge, to any person obtaining a
009:         *  copy of this software and associated documentation files (the "Software"),
010:         *  to deal in the Software without restriction, including without limitation
011:         *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
012:         *  and/or sell copies of the Software, and to permit persons to whom the
013:         *  Software is furnished to do so, subject to the following conditions:
014:         *
015:         *  The above copyright notice and this permission notice shall be included in
016:         *  all copies or substantial portions of the Software.
017:         *
018:         *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
019:         *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
020:         *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
021:         *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
022:         *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
023:         *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
024:         *  DEALINGS IN THE SOFTWARE.
025:         */
026:
027:        package net.sourceforge.groboutils.junit.v1.iftc;
028:
029:        import org.easymock.EasyMock;
030:        import org.easymock.MockControl;
031:        import junit.framework.Test;
032:        import junit.framework.TestCase;
033:        import junit.framework.TestSuite;
034:
035:        /**
036:         * Tests the CxFactory class.  Concrete test for an abstract class.
037:         *
038:         * @author    Matt Albrecht <a href="mailto:groboclown@users.sourceforge.net">groboclown@users.sourceforge.net</a>
039:         * @since     October 30, 2002
040:         * @version   $Date: 2003/05/29 13:05:52 $
041:         */
042:        public class CxFactoryUTest extends TestCase {
043:            //-------------------------------------------------------------------------
044:            // Standard JUnit Class-specific declarations
045:
046:            private static final Class THIS_CLASS = CxFactoryUTest.class;
047:            private static final String TC = "CxFactoryUTest";
048:            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
049:                    .getLogger(THIS_CLASS);
050:
051:            public CxFactoryUTest(String name) {
052:                super (name);
053:            }
054:
055:            // intentionally non-static inner class
056:            public class MyCxFactory extends CxFactory {
057:                public MyCxFactory(String n) {
058:                    super (n);
059:                }
060:
061:                public MyCxFactory(String n, boolean a) {
062:                    super (n, a);
063:                }
064:
065:                public Object createImplObject() {
066:                    return "";
067:                }
068:            }
069:
070:            // intentionally static inner class
071:            public static class MyStaticCxFactory extends CxFactory {
072:                public MyStaticCxFactory(String n) {
073:                    super (n);
074:                }
075:
076:                public MyStaticCxFactory(String n, boolean a) {
077:                    super (n, a);
078:                }
079:
080:                public Object createImplObject() {
081:                    return "";
082:                }
083:            }
084:
085:            //-------------------------------------------------------------------------
086:            // Tests
087:
088:            public void testToString1() {
089:                // try with a named inner class.
090:                CxFactory cf = new MyCxFactory("1");
091:                assertEquals("Returned unexpected factory name.", "1", cf
092:                        .toString());
093:            }
094:
095:            public void testToString1b() {
096:                // try with a named inner class.
097:                CxFactory cf = new MyCxFactory("1b", false);
098:                assertEquals("Returned unexpected factory name.", "1b", cf
099:                        .toString());
100:            }
101:
102:            public void testToString1a() {
103:                // try with a named inner class.
104:                CxFactory cf = new MyCxFactory("1a", true);
105:                assertEquals("Returned unexpected factory name.", TC + "-1a",
106:                        cf.toString());
107:            }
108:
109:            public void testToString2() {
110:                // try with an anonymous inner class.
111:                // CxFactory should use the name of the owning class's name,
112:                // not the inner class's name.
113:                CxFactory cf = new MyCxFactory("2") {
114:                };
115:                assertEquals("Returned unexpected factory name.", "2", cf
116:                        .toString());
117:            }
118:
119:            public void testToString2b() {
120:                // try with an anonymous inner class.
121:                // CxFactory should use the name of the owning class's name,
122:                // not the inner class's name.
123:                CxFactory cf = new MyCxFactory("2b", false) {
124:                };
125:                assertEquals("Returned unexpected factory name.", "2b", cf
126:                        .toString());
127:            }
128:
129:            public void testToString2a() {
130:                // try with an anonymous inner class.
131:                // CxFactory should use the name of the owning class's name,
132:                // not the inner class's name.
133:                CxFactory cf = new MyCxFactory("2a", true) {
134:                };
135:                assertEquals("Returned unexpected factory name.", TC + "-2a",
136:                        cf.toString());
137:            }
138:
139:            public void testToString3() {
140:                // try with a static inner class.
141:                // CxFactory should use the name of the owning class's name,
142:                // not the inner class's name.
143:                CxFactory cf = new MyStaticCxFactory("3") {
144:                };
145:                assertEquals("Returned unexpected factory name.", "3", cf
146:                        .toString());
147:            }
148:
149:            public void testToString3b() {
150:                // try with a static inner class.
151:                // CxFactory should use the name of the owning class's name,
152:                // not the inner class's name.
153:                CxFactory cf = new MyStaticCxFactory("3b", false) {
154:                };
155:                assertEquals("Returned unexpected factory name.", "3b", cf
156:                        .toString());
157:            }
158:
159:            public void testToString3a() {
160:                // try with a static inner class.
161:                // CxFactory should use the name of the owning class's name,
162:                // not the inner class's name.
163:                CxFactory cf = new MyStaticCxFactory("3a", true) {
164:                };
165:                assertEquals("Returned unexpected factory name.", TC + "-3a",
166:                        cf.toString());
167:            }
168:
169:            public void testToString4() {
170:                // try with an outside, stand-alone class.
171:                LOG.debug("Test4:");
172:                CxFactory cf = new CxFactorySample("4");
173:                LOG.debug("Returned Sample factory toString: [" + cf.toString()
174:                        + "]");
175:                assertEquals("Returned unexpected factory name.", "4", cf
176:                        .toString());
177:            }
178:
179:            public void testToString4b() {
180:                // try with an outside, stand-alone class.
181:                LOG.debug("Test4:");
182:                CxFactory cf = new CxFactorySample("4b", false);
183:                LOG.debug("Returned Sample factory toString: [" + cf.toString()
184:                        + "]");
185:                assertEquals("Returned unexpected factory name.", "4b", cf
186:                        .toString());
187:            }
188:
189:            public void testToString4a() {
190:                // try with an outside, stand-alone class.
191:                LOG.debug("Test4:");
192:                CxFactory cf = new CxFactorySample("4a", true);
193:                LOG.debug("Returned Sample factory toString: [" + cf.toString()
194:                        + "]");
195:                assertEquals("Returned unexpected factory name.",
196:                        "CxFactorySample-4a", cf.toString());
197:            }
198:
199:            //-------------------------------------------------------------------------
200:            // Standard JUnit declarations
201:
202:            public static InterfaceTestSuite suite() {
203:                InterfaceTestSuite suite = ImplFactoryUTestI.suite();
204:
205:                // yes, this is an inner class inside an inner class!
206:                // shudder - luckily, this is only for testing.
207:                suite.addFactory(new ImplFactory() {
208:                    public Object createImplObject() {
209:                        return new MyStaticCxFactory("A-B");
210:                    }
211:
212:                    public String toString() {
213:                        return "CxFactory-A";
214:                    }
215:                });
216:                suite.addTestSuite(THIS_CLASS);
217:
218:                return suite;
219:            }
220:
221:            public static void main(String[] args) {
222:                String[] name = { THIS_CLASS.getName() };
223:
224:                // junit.textui.TestRunner.main( name );
225:                // junit.swingui.TestRunner.main( name );
226:
227:                junit.textui.TestRunner.main(name);
228:            }
229:
230:            /**
231:             * 
232:             * @exception Exception thrown under any exceptional condition.
233:             */
234:            protected void setUp() throws Exception {
235:                super .setUp();
236:
237:                // set ourself up
238:            }
239:
240:            /**
241:             * 
242:             * @exception Exception thrown under any exceptional condition.
243:             */
244:            protected void tearDown() throws Exception {
245:                // tear ourself down
246:
247:                super.tearDown();
248:            }
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.