Java Doc for AssertionUtils.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » util » 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 » ERP CRM Financial » Kuali Financial System » org.kuali.core.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.kuali.core.util.AssertionUtils

AssertionUtils
public class AssertionUtils (Code)
This class contains utility methods for making assertions in production code (not test code). Kuali is not using the assert keyword because those assertions are not enabled by default. We can use the methods of this class instead, or throw AssertionError directly. This makes assertions effective in production and development, and avoids any risk of changes to functionality because any side-effects that might be involved in the assertion are done consistently. Although AssertionError can be thrown directly, and sometimes the compiler requires this, in many cases these method invocations will be easier to read than the extra if block with its negated conditional.

These assertions are for use in production code. They should not be confused with junit.framework.Assert , junit.framework.AssertionFailedError , nor org.kuali.test.util.KualiTestAssertionUtils , which are for test code.

These methods should be used such that when they fail and throw AssertionError , it indicates that there is a bug in our software. Drawing attention to the bug this way, as soon as it's discovered, reduces the amount of work required to fix it. So, we should not catch AssertionError (or Throwable ) and try to handle or work around it; it indicates a need to change some source code so that the assertion is never false. For more about why, when, and how to use assertions, see Kuali's guide to assertions and Sun's guide to assertions.
See Also:   org.kuali.test.util.KualiTestAssertionUtils





Method Summary
public static  voidassertThat(boolean isTrue)
     Asserts that the isTrue parameter is true.
public static  voidassertThat(boolean isTrue, Object detailMessage)
     Asserts that the isTrue parameter is true, with a detail message.
public static  voidassertThat(boolean isTrue, String detailMessageFormat, Object... detailMessageArgs)
     Asserts that the isTrue parameter is true.



Method Detail
assertThat
public static void assertThat(boolean isTrue)(Code)
Asserts that the isTrue parameter is true. If this assertion fails, the AssertionError it throws will have no detail message, only a stacktrace indicating the source file and line number containing the assertion that failed.

This method's name is intended to avoid confusion with JUnit asserts (which are for test code, not production code), and its signature is intended to resemble that of the assert keyword.
Parameters:
  isTrue - whether this assertion succeeds. (Boolean objects are auto-unboxed by JDK 1.5.)
throws:
  AssertionError - if isTrue is false




assertThat
public static void assertThat(boolean isTrue, Object detailMessage)(Code)
Asserts that the isTrue parameter is true, with a detail message. The purpose of the detail message is to capture and communicate details about the assertion failure that will help a developer diagnose and fix the bug that led this assertion to fail. It's meant to be interpreted in the context of a full stack trace and with the source code containing the failed assertion. It is not a user-level error message. Details like "assertion failed" are redundant, not useful.

This method's name is intended to avoid confusion with JUnit asserts (which are for test code, not production code), and its signature is intended to resemble that of the assert keyword.
Parameters:
  isTrue - whether this assertion succeeds. (Boolean objects are auto-unboxed by JDK 1.5.)
Parameters:
  detailMessage - value to use for the AssertionError 's detail message. If this is an instance ofThrowable, then it also becomes the AssertionError 's cause. (Primitives are auto-boxed by JDK 1.5.)Objects are converted Object.toString toString, but only if this assertion fails, so it's better not toconvert this detail in advance. The code will be a little easier to read, and there will be some performanceimprovement (altho it may be insignificant). For example, passing just accountingLine is better than passing accountingLine.toString() or "accounting line:"+accountingLine . Since the assertion has failed, anyinconsistent side-effects from the conversion are not an issue. A null reference is treated as the String "null" .
throws:
  AssertionError - if isTrue is false




assertThat
public static void assertThat(boolean isTrue, String detailMessageFormat, Object... detailMessageArgs)(Code)
Asserts that the isTrue parameter is true. This method is convenient for formatting the detail message, and as an optimization for detail arguments that are expensive to convert to String. For example, suppose foo and bar are two objects with expensive Object.toString methods. If you use
 AssertionUtils.assertThat(foo.equals(bar), "foo: " + foo + " bar: " + bar);
 
then both object's toString methods will be invoked every time this assertion is done, even though those details are not normally needed because this assertion normally succeeds. You can use this method instead to only do those toString invocations if this assertion fails:
 AssertionUtils.assertThat(foo.equals(bar), "foo: %s bar: %s", foo, bar);
 

This method's name is intended to avoid confusion with JUnit asserts (which are for test code, not production code).
Parameters:
  isTrue - whether this assertion succeeds. (Boolean objects are auto-unboxed by JDK 1.5.)
Parameters:
  detailMessageFormat - a to be used in constructing the AssertionError 'sdetail message. The purpose of this message is to capture and communicate details about the assertion failure thatwill help a developer diagnose and fix the bug that led the assertion to fail. It's meant to be interpreted in thecontext of a full stack trace and with the source code containing the failed assertion. It is not auser-level error message. Details like "assertion failed" are redundant, not useful. This detail messagecannot be null .
Parameters:
  detailMessageArgs - one or more arguments to the format string. Nulls are allowed by some format conversions, such as "%s" . (Primitives are auto-boxed by JDK 1.5.) Zero arguments will invoke AssertionUtils.assertThat(boolean,Object)instead, so the detail message will not be treated as a format string.
throws:
  AssertionError - if isTrue is false
throws:
  java.util.IllegalFormatException - if detailMessageFormat contains an illegal syntax, a format specifier thatis incompatible with the given arguments, insufficient arguments given the format string, or other illegalconditions. For specification of all possible formatting errors, see the Details section ofjava.util.Formatter.
throws:
  NullPointerException - if the detailMessageFormat is null
See Also:   String.format




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.