org.objectweb.jonas_lib.deployment.tests
Class AbsDeploymentTest

java.lang.Object
  extended by org.objectweb.jonas_lib.deployment.tests.AbsDeploymentTest
Direct Known Subclasses:
ClientDeploymentTest, ClusterDaemonConfigurationTest, DomainMapTest, EarDeploymentTest, EJBDeploymentTest, JonasClientDeploymentTest, JonasEJBDeploymentTest, JonasRarDeploymentTest, JonasWebDeploymentTest, JonasWsDeploymentTest, RarDeploymentTest, WebDeploymentTest, WsDeploymentTest

public abstract class AbsDeploymentTest
extends java.lang.Object

Defines an abstract class for testing the classes built with Digester

Author:
Florent Benoit

Constructor Summary
protected AbsDeploymentTest()
          Build a new Test
 
Method Summary
protected  void addElement(Element element, java.lang.reflect.Method method, java.lang.Class[] argsMethod, boolean random)
          Add to an element its sub element Add many times a sub-element if random is not set to true
protected  boolean aleatOK()
          Random for returning true or false
protected  void checkDiff(java.lang.String xmlOriginal, java.lang.String xmlParsed)
          Check the difference between original xml and parsed xml
protected  java.lang.String convertUpperCaseToXml(java.lang.String name)
          Convert the name of an element into its xml string representation example : WebApp --> web-app
 void fill(Element element, boolean random)
          Fill the structure of the given element.
protected  void fillQName(Element element, java.lang.reflect.Method method, boolean random)
          Set the QName attribute of the given element
protected  void fillString(Element element, java.lang.reflect.Method method, boolean random)
          Set the string attribute of the given element
protected  java.lang.String getNameCounterForElement(Element element, java.lang.reflect.Method method)
          Gives a Name + counter for a type of an element This is used to add counter when adding xml attributes Only use in order to make easier the read of the parsed XML file
abstract  AbsElement getTopLevelElement()
           
protected  int nbAleat()
          Gives a number between 0 and 5
abstract  java.lang.String parse(java.io.Reader reader, java.lang.String name, boolean validation)
           
 void parseElement()
          Gets the xml after digester parsing
 void parseXmlfromFile(java.lang.String fileName)
          parse with validation from an xml file
protected  void setElement(Element element, java.lang.reflect.Method method, java.lang.Class[] argsMethod, boolean random)
          Set the subelement of an element The subelement may not be set if random is used
 void startTest(boolean random)
          Defines the function for the specific test
 void stress()
          Create an xml structure and then parse the resulting xml and check the result No validation is done if random is set to true
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbsDeploymentTest

protected AbsDeploymentTest()
Build a new Test

Method Detail

stress

public void stress()
            throws java.lang.Exception
Create an xml structure and then parse the resulting xml and check the result No validation is done if random is set to true

Throws:
java.lang.Exception - if the stress test is not successfull

getTopLevelElement

public abstract AbsElement getTopLevelElement()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

parse

public abstract java.lang.String parse(java.io.Reader reader,
                                       java.lang.String name,
                                       boolean validation)
                                throws java.lang.Exception
Throws:
java.lang.Exception

startTest

public void startTest(boolean random)
               throws java.lang.Exception
Defines the function for the specific test

Parameters:
random - use random or not to fill elements
Throws:
java.lang.Exception - if the test failed

parseElement

public void parseElement()
                  throws java.lang.Exception
Gets the xml after digester parsing

Throws:
java.lang.Exception - if the parsing fail

parseXmlfromFile

public void parseXmlfromFile(java.lang.String fileName)
                      throws java.lang.Exception
parse with validation from an xml file

Throws:
java.lang.Exception - if the parsing fail

checkDiff

protected void checkDiff(java.lang.String xmlOriginal,
                         java.lang.String xmlParsed)
                  throws java.lang.Exception
Check the difference between original xml and parsed xml

Parameters:
xmlOriginal - original XML
xmlParsed - parsed XML
Throws:
java.lang.Exception - if there is a difference between original and parsed XML

fill

public void fill(Element element,
                 boolean random)
          throws java.lang.Exception
Fill the structure of the given element. Fill randomly if random is set to true

Parameters:
element - element to fill
random - determines if the element must be filled randomly or not
Throws:
java.lang.Exception - if the element can not be filled

aleatOK

protected boolean aleatOK()
Random for returning true or false

Returns:
true or false with random

nbAleat

protected int nbAleat()
Gives a number between 0 and 5

Returns:
a random intger number between 0 and 5

addElement

protected void addElement(Element element,
                          java.lang.reflect.Method method,
                          java.lang.Class[] argsMethod,
                          boolean random)
                   throws java.lang.Exception
Add to an element its sub element Add many times a sub-element if random is not set to true

Parameters:
element - element on which we have to add sub elements
method - method of the element (determine type of the sub element
argsMethod - arguments of the method
random - use random or not
Throws:
java.lang.Exception - if the subelement can not be added

setElement

protected void setElement(Element element,
                          java.lang.reflect.Method method,
                          java.lang.Class[] argsMethod,
                          boolean random)
                   throws java.lang.Exception
Set the subelement of an element The subelement may not be set if random is used

Parameters:
element - element on which we have to add sub elements
method - method of the element (determine type of the sub element
argsMethod - arguments of the method
random - use random or not
Throws:
java.lang.Exception - if the subelement can not be set

fillString

protected void fillString(Element element,
                          java.lang.reflect.Method method,
                          boolean random)
                   throws java.lang.Exception
Set the string attribute of the given element

Parameters:
element - element on which we have to set the string
method - method of the element (determine type of the sub element
random - use random or not
Throws:
java.lang.Exception - if the String attribute can not be added

fillQName

protected void fillQName(Element element,
                         java.lang.reflect.Method method,
                         boolean random)
                  throws java.lang.Exception
Set the QName attribute of the given element

Parameters:
element - element on which we have to set the string
method - method of the element (determine type of the sub element
random - use random or not
Throws:
java.lang.Exception - if the QName can not be set

getNameCounterForElement

protected java.lang.String getNameCounterForElement(Element element,
                                                    java.lang.reflect.Method method)
Gives a Name + counter for a type of an element This is used to add counter when adding xml attributes Only use in order to make easier the read of the parsed XML file

Parameters:
element - the given element for which we want a counter
method - the name of the string to add
Returns:
the Name + counter for the specified element type

convertUpperCaseToXml

protected java.lang.String convertUpperCaseToXml(java.lang.String name)
Convert the name of an element into its xml string representation example : WebApp --> web-app

Parameters:
name - the name of the element to convert
Returns:
the xml string representation of an element