Java Doc for JTestCase.java in  » Testing » TestGen4J » net » wangs » jtestcase » 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 » TestGen4J » net.wangs.jtestcase 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.wangs.jtestcase.JTestCase

JTestCase
public class JTestCase (Code)
This utility class is used for Unit test to help reading data (test cases) out from xml file.
author:
   Yuqing Wang



Constructor Summary
public  JTestCase(String fileName, String className)
     Constructed from full file name and class name.

Method Summary
public  booleanassertTestCase(String varName, Object varValue, String methodName, String testCase)
     Asserts a given varible's value against its expected value by using expected action.
 
 Following actions are defined.
public  booleanassertTestCase(String varName, Object varValue, String methodName, int index)
     Asserts a given varible's value against its expected value by using expected action.
 
 Following actions are defined.
public  HashtablegetAssertActions(String methodName, String testCase)
     Get all assert actions for a given method and its test case value into Hashtable.
public  HashtablegetAssertActions(String methodName, int index)
     Get all assert actions for a given method and its test case value into Hashtable.
public  HashtablegetAssertTypes(String methodName, String testCase)
     Get types of assert values for a given method and its test case value into Hashtable.
public  HashtablegetAssertTypes(String methodName, int index)
     Get types of assert values for a given method and its test case value into Hashtable, hashed key is assert param's name, value is String value of type of assert param.
public  HashtablegetAssertValues(String methodName, String testCase)
     Get all assert values for a given method and its test case value into Hashtable.
public  HashtablegetAssertValues(String methodName, int index)
     Get all assert values for a given method and its test case value into Hashtable.
public  StringgetClassUnderTest()
    
public  HashtablegetControlParams()
     Retrieves all control parameters.
public  intgetCountOfTestCases(String methodName)
     Get number of test cases for a given method.
public  StringgetException(String methodName, String testCase)
     Get test cases exception name for a given method
Parameters:
  methodName - - name of tested method.
public  StringgetGlobalParamLocale()
    
public  HashtablegetGlobalParamTypes()
     Retrieves types of all global (class-wided) params into Hashtable.
public  HashtablegetGlobalParams()
     Retrieves all global (class-wide) params into Hashtable.
public  VectorgetNameOfTestCases(String methodName)
     Get all test cases' name for a given method into Vector. This method requires that for a given method, each test case should be named uniquely.
Parameters:
  methodName - - name of tested method.
public  MultiKeyHashtablegetTestCaseAssertActions(String methodName, String testCase)
     Get all assert actions for a given method and its test case value into Hashtable.
public  MultiKeyHashtablegetTestCaseAssertActions(String methodName, int index)
     Get all assert actions for a given method and its test case value into Hashtable.
public  MultiKeyHashtablegetTestCaseAssertTypes(String methodName, String testCase)
     Get types of assert values for a given method and its test case value into Hashtable.
public  MultiKeyHashtablegetTestCaseAssertTypes(String methodName, int index)
     Get types of assert values for a given method and its test case value into Hashtable, hashed key is assert param's name, value is String value of type of assert param.
public  MultiKeyHashtablegetTestCaseAssertValues(String methodName, String testCase)
     Get all assert values for a given method and its test case value into Hashtable.
public  MultiKeyHashtablegetTestCaseAssertValues(String methodName, int index)
     Get all assert values for a given method and its test case value into Hashtable.
public  HashtablegetTestCaseParamTypes(String methodName, String testCase)
     Get types of all params for a given method and its test case value into Hashtable.
public  HashtablegetTestCaseParamTypes(String methodName, int index)
     Get types of all params for a given method and the index number of test case into Hashtable.
public  ObjectgetTestCaseParameter(String methodName, String testCase, String parameter)
     Get the value of the specific paramater given his name for a specific methodName and a specific testCase.
Parameters:
  methodName - - name of tested method.
public  HashtablegetTestCaseParams(String methodName, String testCase)
     Get all params for a given method and its test case value into Hashtable.
public  HashtablegetTestCaseParams(String methodName, int index)
     Get all params for a given method and the index number of test case into Hashtable.


Constructor Detail
JTestCase
public JTestCase(String fileName, String className) throws JTestCaseException(Code)
Constructed from full file name and class name. This class name is specifed in data file under "/tests/class@name". It's recommended that its value equals to the real testing class's name.
Parameters:
  fileName - - name of data file. Will be searched by absolute path first. If not found,then will be searched based on classpath.
Parameters:
  className - - name of test program. Is defined in data file in /tests/class@name
throws:
  JTestCaseException - Problem with reading the file, validating the XML or with the XML structure




Method Detail
assertTestCase
public boolean assertTestCase(String varName, Object varValue, String methodName, String testCase) throws JTestCaseException(Code)
Asserts a given varible's value against its expected value by using expected action.
 
 Following actions are defined. Expected action in data file should fall into one of them:
 ISNULL, ISNOTNULL, EQUALS, NOTEQUALS, GT (greater than), NOTGT (not greater than), 
 LT (less than), NOTLT (not less than), and TRUE (expression is true).
 The expected asserting results are defined in data file like this:
 ...
 <asserts>
 <assert name="var1" action="EQUALS" type="int">100</assert>
 <assert name="var2" action="NOTNULL"/>
 </asserts>
 ...
 Note: "GT" means "real value" greater than "expected value". Simular to others.

Parameters:
  varName - - name of varible. Defined in data file in /test/class/method/asserts/assert@name.
Parameters:
  varValue - - actually value of this varible.
Parameters:
  methodName - - name of this method. Defined in data file in /test/class/method@name.
Parameters:
  testCase - - name of this test case. Defined in data file in /test/class/method@test-case. boolean. "true" is assertion is true, else "false".



assertTestCase
public boolean assertTestCase(String varName, Object varValue, String methodName, int index) throws JTestCaseException(Code)
Asserts a given varible's value against its expected value by using expected action.
 
 Following actions are defined. Expected action in data file should fall into one of them:
 ISNULL, ISNOTNULL, EQUALS, NOTEQUALS, GT (greater than), NOTGT (not greater than), 
 LT (less than), NOTLT (not less than), and TRUE (expression is true).
 The expected asserting results are defined in data file like this:
 ...
 <asserts>
 <assert name="var1" action="EQUALS" type="int">100</assert>
 <assert name="var2" action="NOTNULL"/>
 </asserts>
 ...
 Note: "GT" means "real value" greater than "expected value". Simular to others.

Parameters:
  varName - - name of varible. Defined in data file in /test/class/method/asserts/assert@name.
Parameters:
  varValue - - actually value of this varible.
Parameters:
  methodName - - name of this method. Defined in data file in /test/class/method@name.
Parameters:
  index - - index number of this test case for this method. boolean. "true" is assertion is true, else "false".



getAssertActions
public Hashtable getAssertActions(String methodName, String testCase) throws JTestCaseException(Code)
Get all assert actions for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of assert action. This method is normally used with getNameOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@name.
Parameters:
  testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's type value defined in /test/class/method/asserts/assert@action.



getAssertActions
public Hashtable getAssertActions(String methodName, int index) throws JTestCaseException(Code)
Get all assert actions for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of assert action. This method os normally used with getCountOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case.
Parameters:
  index - - index number of test case for this method, start from 0. Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's action value defined in /test/class/method/asserts/assert@action.



getAssertTypes
public Hashtable getAssertTypes(String methodName, String testCase) throws JTestCaseException(Code)
Get types of assert values for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of type of assert param. This type is name of java class. This method does not return the types of assert values in complex data types. This means if you have an assert value of type "java.util.Hashtable" this method returns exactly this string and not a hashtable with the data types of the items in the hashtable. This method is normally used with getNameOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case.
Parameters:
  testCase - - name of test case.Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's type value as indecated in /test/class/method/asserts/assert@type.



getAssertTypes
public Hashtable getAssertTypes(String methodName, int index) throws JTestCaseException(Code)
Get types of assert values for a given method and its test case value into Hashtable, hashed key is assert param's name, value is String value of type of assert param. This type is name of java class. This method does not return the types of assert values in complex data types. This means if you have an assert value of type "java.util.Hashtable" this method returns exactly this string and not a hashtable with the data types of the items in the hashtable. This method os normally used with getCountOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case.
Parameters:
  index - - index number of test case for this method, start from 0. Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's type value as indecated in /test/class/method/asserts/assert@type.



getAssertValues
public Hashtable getAssertValues(String methodName, String testCase) throws JTestCaseException(Code)
Get all assert values for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of assert param. This method is normally used with getNameOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case.
Parameters:
  testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's Object value with type as indecated in /test/class/method/asserts/assert@type. If not "type" specified in data file, then "String" is default type.



getAssertValues
public Hashtable getAssertValues(String methodName, int index) throws JTestCaseException(Code)
Get all assert values for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of assert param. This method os normally used with getCountOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case.
Parameters:
  index - - index number of test case for this method, start from 0. Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's Object value with type as indecated in /test/class/method/asserts/assert@type. If not "type" specified in data file, then "String" is default type.



getClassUnderTest
public String getClassUnderTest()(Code)
Returns the class name used to find the class tags in XML the class name



getControlParams
public Hashtable getControlParams() throws JTestCaseException(Code)
Retrieves all control parameters. Control parameters are parameters that are defined for the whole JTestCase data set. They are valid for all class-tags in the file. A hashtable with the control parameters. Key is defined in /tests/params/param@name,value is param's object value with type as indicated in /test/class/params/param@type. If "type" is not specified in data file, then "String" is default type.
throws:
  JTestCaseException - in case of any errors



getCountOfTestCases
public int getCountOfTestCases(String methodName) throws JTestCaseException(Code)
Get number of test cases for a given method. This method name is specified in data file in /tests/class/method@name. It's recommended that its value equals to the real testing method's name.
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@name. int. Number of test cases that are defined for this method in data file.



getException
public String getException(String methodName, String testCase) throws JTestCaseException(Code)
Get test cases exception name for a given method
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. String representing the exception



getGlobalParamLocale
public String getGlobalParamLocale() throws JTestCaseException(Code)
Helps setting the Locale for DateFormats the global Parameter named 'locale'
throws:
  JTestCaseException -



getGlobalParamTypes
public Hashtable getGlobalParamTypes() throws JTestCaseException(Code)
Retrieves types of all global (class-wided) params into Hashtable. HashKey is param's name, HashValue is param's type in String which represents java class's name. These params are common to all tested methods for the specified tested class, and should be retrieved in testing class's constructor. Hashtable. Key is param's name defined in /tests/class/params/param@name, value is param's Object value with type as indecated in /test/class/params/param@type. If not "type" specified in data file, then "String" is default type.



getGlobalParams
public Hashtable getGlobalParams() throws JTestCaseException(Code)
Retrieves all global (class-wide) params into Hashtable. HashKey is param's name, HashValue is param's value. These params are common to all tested methods for the specified tested class, and should be retrieved in testing class's constructor. Hashtable. Key is param's name defined in /tests/class/params/param@name, value is param's Object value with type as indicated in /test/class/params/param@type. If not "type" specified in data file, then "String" is default type.



getNameOfTestCases
public Vector getNameOfTestCases(String methodName) throws JTestCaseException(Code)
Get all test cases' name for a given method into Vector. This method requires that for a given method, each test case should be named uniquely.
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case. Vector of names of test cases that are defined for this method in data file in/tests/class/method@test-case.



getTestCaseAssertActions
public MultiKeyHashtable getTestCaseAssertActions(String methodName, String testCase) throws JTestCaseException(Code)
Get all assert actions for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of assert action. This method is normally used with getNameOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@name.
Parameters:
  testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's type value defined in /test/class/method/asserts/assert@action.



getTestCaseAssertActions
public MultiKeyHashtable getTestCaseAssertActions(String methodName, int index) throws JTestCaseException(Code)
Get all assert actions for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of assert action. This method os normally used with getCountOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case.
Parameters:
  index - - index number of test case for this method, start from 0. Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's action value defined in /test/class/method/asserts/assert@action.



getTestCaseAssertTypes
public MultiKeyHashtable getTestCaseAssertTypes(String methodName, String testCase) throws JTestCaseException(Code)
Get types of assert values for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of type of assert param. This type is name of java class. This method does not return the types of assert values in complex data types. This means if you have an assert value of type "java.util.Hashtable" this method returns exactly this string and not a hashtable with the data types of the items in the hashtable. This method is normally used with getNameOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case.
Parameters:
  testCase - - name of test case.Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's type value as indecated in /test/class/method/asserts/assert@type.



getTestCaseAssertTypes
public MultiKeyHashtable getTestCaseAssertTypes(String methodName, int index) throws JTestCaseException(Code)
Get types of assert values for a given method and its test case value into Hashtable, hashed key is assert param's name, value is String value of type of assert param. This type is name of java class. This method does not return the types of assert values in complex data types. This means if you have an assert value of type "java.util.Hashtable" this method returns exactly this string and not a hashtable with the data types of the items in the hashtable. This method os normally used with getCountOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case.
Parameters:
  index - - index number of test case for this method, start from 0. Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's type value as indecated in /test/class/method/asserts/assert@type.



getTestCaseAssertValues
public MultiKeyHashtable getTestCaseAssertValues(String methodName, String testCase) throws JTestCaseException(Code)
Get all assert values for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of assert param. This method is normally used with getNameOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case.
Parameters:
  testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's Object value with type as indecated in /test/class/method/asserts/assert@type. If not "type" specified in data file, then "String" is default type.



getTestCaseAssertValues
public MultiKeyHashtable getTestCaseAssertValues(String methodName, int index) throws JTestCaseException(Code)
Get all assert values for a given method and its test case value into Hashtable. Hashed key is assert param's name, value is String value of assert param. This method os normally used with getCountOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@test-case.
Parameters:
  index - - index number of test case for this method, start from 0. Hashtable. Key is assert param's name defined in /tests/class/method/asserts/assert@name, value is assert param's Object value with type as indecated in /test/class/method/asserts/assert@type. If not "type" specified in data file, then "String" is default type.



getTestCaseParamTypes
public Hashtable getTestCaseParamTypes(String methodName, String testCase) throws JTestCaseException(Code)
Get types of all params for a given method and its test case value into Hashtable. Hashed key is param's name, value is String value of param type, which conforms to java class name. This method is normally used with getNameOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@name.
Parameters:
  testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's type value defined in /test/class/method/params/param@type.



getTestCaseParamTypes
public Hashtable getTestCaseParamTypes(String methodName, int index) throws JTestCaseException(Code)
Get types of all params for a given method and the index number of test case into Hashtable. Hashed key is param's name, value is String value of param type, which conforms to java class name. This method is normally used with getCountOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@name.
Parameters:
  index - - index number of test case for this method, start from 0. Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's type value defined in /test/class/method/params/param@type.



getTestCaseParameter
public Object getTestCaseParameter(String methodName, String testCase, String parameter) throws JTestCaseException(Code)
Get the value of the specific paramater given his name for a specific methodName and a specific testCase.
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@name.
Parameters:
  testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName".
Parameters:
  parameter - the name of the parameter to be read. the value of the specific parameter for the specific method and testCase.
since:
   2.1.3
author:
   ckoelle



getTestCaseParams
public Hashtable getTestCaseParams(String methodName, String testCase) throws JTestCaseException(Code)
Get all params for a given method and its test case value into Hashtable. Hashed key is param's name, value is value of param. This method is normally used with getNameOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@name.
Parameters:
  testCase - - name of test case. Defined in data file in /tests/class/method@test-case. Should be unique for the given "methodName". Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's Object value with type as indecated in /test/class/method/params/param@type. If not "type" specified in data file, then "String" is default type.



getTestCaseParams
public Hashtable getTestCaseParams(String methodName, int index) throws JTestCaseException(Code)
Get all params for a given method and the index number of test case into Hashtable. Hashed key is param's name, value is String value of param. This method is normally used with getCountOfTestCases().
Parameters:
  methodName - - name of tested method. Defined in data file in /tests/class/method@name.
Parameters:
  index - - index number of test case for this method, start from 0. Hashtable. Key is param's name defined in /tests/class/method/params/param@name, value is param's Object value with type as indecated in /test/class/method/params/param@type. If not "type" specified in data file, then "String" is default type.



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.