Java Doc for RndEngine.java in  » Testing » TT » U2 » T2 » 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 » TT » U2.T2 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   U2.T2.Engine
      U2.T2.RndEngine

RndEngine
public class RndEngine extends Engine (Code)
Implements test engine for random testing; it provides the T2's main testing API.

An instance of this class is a test engine. When given a target class to test, an engine randomly generates executions, and also randomly generates objects needed as parameters for method called during the executions. The executions are checked against the class invariant of the target class and its other specifications if present.

What is being checked?

An instance of this class is a test engine. An engine generates executions, looking for violations. Executions leading to violations are reported and can be saved for regression. These are the kinds of violations checked by the engine:

  1. INTERNAL error. When a method of the target object raises an Error, which is not an AssertionError, or RuntimeException.

  2. ASSERTION violation. When a method (or its specification) raises an AssertionError, which is not marked by "PRE". If it is marked by PRE then its pre-condition is not met, in which case the execution will be discarded.

  3. CLASSINV violation. This happens when the state after a step in an execution violates the class invariant.

    Exception thrown by the class invariant will be considered as false. If it throws an unchecked exception, the engine will give a warning.


See Also:   U2.T2.Engine


Field Summary
protected  BaseDomainbaseDomain
     The base domain used by the engine.
protected  floatchooseFieldUpdateProb
     The probability to do field update rather than method call.
protected  LinkedList<Trace>collectedTraces
     Collected execution traces.
protected  floatgenerateNullProb
     When trying to generate an instance of C, and one cannot be found in the base domain, and the engine decided not to look in the pool (hence generating a fresh one), this is the probability of generating null.
protected  InterfaceMapinterfaceMap
     An interface map used by the engine.
protected  intmaxArrayLength
     Maximum collection and array length (along each dimension).
protected  intmaxMkValSeqDepth
     Specify a maximum on the length of every generated mkVal sequence.
protected  intmaxShowDepth
     Maximum depth when showing objects in reporting.
protected  intnumOfIrrelevantChecks
     In the current implementation the number of relevant checks is a bit difficult to count; so we count instead the number of irrelevant checks.
protected static  String[]optionsShortDesc
     Short descriptions of available options.
protected  floatpassTObjAsParamProb
     The probability for chosing to pass the target object as a parameter rather than as a receiver object.
protected  floatpickTargetObjFromPoolProb
     The probability that when a new execution is to be generated, the target object will be picked from the pool rather than created fresh with a constructor.
protected  Randomrnd
     A random generator.

Constructor Summary
public  RndEngine(Class C, Pool p, BaseDomain dom, InterfaceMap imap)
     Create a test engine, with C as the target class, using the given pool, base domain, and interface map.

Method Summary
public static  voidRndTest(Class C, Pool p, BaseDomain dom, InterfaceMap imap, PrintStream out, String[] options)
     A main Testing API; this static method will unleash random testing on a given target class.
public static  voidRndTest(Pool p, BaseDomain dom, InterfaceMap imap, String[] args)
     A main Testing API; almost as the other RndTest.
public static  booleandoesTargetClassConform(Class C)
     Check if a given class is of the right kind (e.g.
public static  voidmain(String[] args)
     Just for testing this class.
public static  voidprintUsage(PrintStream out)
     Print usage help to the console.
public  voidreport(PrintStream out)
     To report violating executions found by the engine.
public  voidrunMe()
     The method to run the engine (that is, to run an automated random testing).

Field Detail
baseDomain
protected BaseDomain baseDomain(Code)
The base domain used by the engine.



chooseFieldUpdateProb
protected float chooseFieldUpdateProb(Code)
The probability to do field update rather than method call. Default is 0.1.



collectedTraces
protected LinkedList<Trace> collectedTraces(Code)
Collected execution traces. Violating executions are collected here, but future versions may add random traces to be collected. When the engine is finished, collected traces are saved and can be reloaded and replayed by a regression engine.



generateNullProb
protected float generateNullProb(Code)
When trying to generate an instance of C, and one cannot be found in the base domain, and the engine decided not to look in the pool (hence generating a fresh one), this is the probability of generating null. If less or equal to null, then generating null in this way will be surpressed.



interfaceMap
protected InterfaceMap interfaceMap(Code)
An interface map used by the engine. The map lists interfaces, and for each possible concrete classes (currently juts one) that implement it. When the engine needs to generate an instance of an interface I, it first look it up in this interface map. If the map says it has implementations, one (say, C) will be selected and the engine will then proceed by trying to generate an instance of C instead.



maxArrayLength
protected int maxArrayLength(Code)
Maximum collection and array length (along each dimension). The default is 4.



maxMkValSeqDepth
protected int maxMkValSeqDepth(Code)
Specify a maximum on the length of every generated mkVal sequence. Default is 4.



maxShowDepth
protected int maxShowDepth(Code)
Maximum depth when showing objects in reporting. That is, subobjects at deeper than this depth will not be shown. The default is 5.



numOfIrrelevantChecks
protected int numOfIrrelevantChecks(Code)
In the current implementation the number of relevant checks is a bit difficult to count; so we count instead the number of irrelevant checks.



optionsShortDesc
protected static String[] optionsShortDesc(Code)
Short descriptions of available options.



passTObjAsParamProb
protected float passTObjAsParamProb(Code)
The probability for chosing to pass the target object as a parameter rather than as a receiver object. Default is 0.4.



pickTargetObjFromPoolProb
protected float pickTargetObjFromPoolProb(Code)
The probability that when a new execution is to be generated, the target object will be picked from the pool rather than created fresh with a constructor. Default is 0.7.



rnd
protected Random rnd(Code)
A random generator.




Constructor Detail
RndEngine
public RndEngine(Class C, Pool p, BaseDomain dom, InterfaceMap imap)(Code)
Create a test engine, with C as the target class, using the given pool, base domain, and interface map.




Method Detail
RndTest
public static void RndTest(Class C, Pool p, BaseDomain dom, InterfaceMap imap, PrintStream out, String[] options) throws T2Exception(Code)
A main Testing API; this static method will unleash random testing on a given target class. Internally the method creates a default test engine and uses it to test the class C. Options can be passed to customize the engine; then the engine is run. Violating executions will be reported and saved in the file C.tr. The method terminates if the underlying test engine throws a T2Error.
Parameters:
  C - The class to test. Passing null will print the usage info to the console.
Parameters:
  p - An object pool to be used by the testing engine.
Parameters:
  dom - A base domain to be used by the engine.
Parameters:
  out - The (default) printstream to which the engine will send report.
Parameters:
  options - Options to configure the engine before runningit; see the source code of printUsage in this class to seeavailable options.



RndTest
public static void RndTest(Pool p, BaseDomain dom, InterfaceMap imap, String[] args)(Code)
A main Testing API; almost as the other RndTest. However, this one internally catches exceptions and logs the corresponding messages and tracestack. Report will be sent by default to the console.
Parameters:
  args - List of options, including the name of the target class; the latter has to be the first in the list; if the list is empty, help
See Also:   RndEngine.RndTest(ClassPoolBaseDomainInterfaceMapPrintStreamString[])



doesTargetClassConform
public static boolean doesTargetClassConform(Class C)(Code)
Check if a given class is of the right kind (e.g. it is not an interface) to be checked with this engine. It the class is not of the right, messages will also be logged.



main
public static void main(String[] args)(Code)
Just for testing this class.



printUsage
public static void printUsage(PrintStream out)(Code)
Print usage help to the console.



report
public void report(PrintStream out)(Code)
To report violating executions found by the engine.



runMe
public void runMe()(Code)
The method to run the engine (that is, to run an automated random testing).



Fields inherited from U2.T2.Engine
protected Class CUT(Code)(Java Doc)
protected int maxExecLength(Code)(Java Doc)
protected int maxNumOfSteps(Code)(Java Doc)
protected int maxNumViolations(Code)(Java Doc)
protected int numOfExecs(Code)(Java Doc)
protected int numOfRelevantChecks(Code)(Java Doc)
protected int numOfSteps(Code)(Java Doc)
protected int numOfViolations(Code)(Java Doc)
protected Pool pool(Code)(Java Doc)

Methods inherited from U2.T2.Engine
public static List<Constructor> getConsIPs(Class C)(Code)(Java Doc)
public static List<Field> getFieldsIPs(Class C)(Code)(Java Doc)
public static List<Method> getMethsIPs(Class C)(Code)(Java Doc)
public static HashMap<Method, Method> mk_specMap(Class C, List<Method> methods)(Code)(Java Doc)
abstract public void report(PrintStream out)(Code)(Java Doc)
abstract public void runMe()(Code)(Java Doc)

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.