Source Code Cross Referenced for BaseTest.java in  » Testing » Ejb3Unit » com » bm » testsuite » 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 » Testing » Ejb3Unit » com.bm.testsuite 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.bm.testsuite;
002:
003:        import java.lang.reflect.Field;
004:        import java.util.Collection;
005:        import org.jmock.MockObjectTestCase;
006:
007:        import com.bm.introspectors.Property;
008:        import com.bm.utils.BeanEqualsTester;
009:
010:        /**
011:         * Superclass of all EJB3unit methods. An extension of junit.framework.TestCase
012:         * that adds those methods that we really wish were part of JUnit.
013:         * 
014:         * @author Daniel Wiese
015:         * @since 09.02.2006
016:         */
017:        public class BaseTest extends MockObjectTestCase {
018:
019:            /**
020:             * Create an instance.
021:             * 
022:             * @param name
023:             *            The name of the test
024:             */
025:            public BaseTest(final String name) {
026:                super (name);
027:            }
028:
029:            /**
030:             * Default costructor.
031:             */
032:            public BaseTest() {
033:                super ();
034:            }
035:
036:            /**
037:             * Assert that the two collections are the same irrespective of order.
038:             * 
039:             * @param a
040:             *            The first collection
041:             * @param b
042:             *            The second collection
043:             * @param <T> -
044:             *            the type of the collection
045:             */
046:            public <T> void assertCollectionsEqual(
047:                    final Collection<? extends T> a,
048:                    final Collection<? extends T> b) {
049:                BeanEqualsTester.testColletionsForEqual(a, b);
050:            }
051:
052:            /**
053:             * Assert that the specified condition is false. Older versions of junit
054:             * have assertTrue() but not assertFalse so we add it here to be sure that
055:             * it is present.
056:             * 
057:             * @param description
058:             *            The failure message to be used if the condition is not false.
059:             * @param condition
060:             *            The value to check.
061:             */
062:            public static void assertFalse(final String description,
063:                    final boolean condition) {
064:                if (condition) {
065:                    fail(description + ": Expected false");
066:                }
067:            }
068:
069:            /**
070:             * Assert that the specified condition is false. Older versions of junit
071:             * have assertTrue() but not assertFalse so we add it here to be sure that
072:             * it is present.
073:             * 
074:             * @param condition
075:             *            The value to check.
076:             */
077:            public static void assertFalse(final boolean condition) {
078:                if (condition) {
079:                    fail("Expected false");
080:                }
081:            }
082:
083:            /**
084:             * Assert that the specified object is an instance of this class.
085:             * 
086:             * @param label
087:             *            A description of the test
088:             * @param object
089:             *            The object to test
090:             * @param clazz
091:             *            The class
092:             * @param <T> -
093:             *            the type of the object
094:             */
095:            public <T> void assertInstanceOf(final String label,
096:                    final T object, final Class<? extends T> clazz) {
097:                if (!clazz.isAssignableFrom(object.getClass())) {
098:                    fail(label + ": object [" + object
099:                            + "] is not an instance of class ["
100:                            + clazz.getName() + "]");
101:                }
102:            }
103:
104:            /**
105:             * Assert that the specified object is an instance of this class.
106:             * 
107:             * @param object
108:             *            The object to test
109:             * @param clazz
110:             *            The class
111:             * @param <T> -
112:             *            the type of the object
113:             */
114:            public <T> void assertInstanceOf(final T object,
115:                    final Class<? extends T> clazz) {
116:                this .assertInstanceOf("", object, clazz);
117:            }
118:
119:            /**
120:             * We donīt want that test fails because htey have no test method.
121:             * 
122:             * @author Daniel Wiese
123:             * @since 23.04.2006
124:             */
125:            public void testNothing() {
126:                // intentionally left blank
127:            }
128:
129:            /**
130:             * Sets a value for a field in the tested-bean instance.
131:             * 
132:             * @author Daniel Wiese
133:             * @since 02.05.2006
134:             * @param fieldName -
135:             *            the name of the field
136:             * @param toSet -
137:             *            the value to set
138:             */
139:            protected void setValueForField(Object forObject, String fieldName,
140:                    Object toSet) {
141:                try {
142:                    final Field field = forObject.getClass().getDeclaredField(
143:                            fieldName);
144:                    Property prop = new Property(field);
145:                    prop.setField(forObject, toSet);
146:                } catch (SecurityException e) {
147:                    throw new RuntimeException(e);
148:                } catch (NoSuchFieldException e) {
149:                    throw new RuntimeException(e);
150:                } catch (IllegalAccessException e) {
151:                    throw new RuntimeException(e);
152:                }
153:            }
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.