org.objectweb.jonas_lib.deployment.tests
Class AbsDeploymentTest

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

public abstract class AbsDeploymentTest
extends 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, Method method, 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(String xmlOriginal, String xmlParsed)
          Check the difference between original xml and parsed xml
protected  String convertUpperCaseToXml(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, Method method, boolean random)
          Set the QName attribute of the given element
protected  void fillString(Element element, Method method, boolean random)
          Set the string attribute of the given element
protected  String getNameCounterForElement(Element element, 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  String parse(Reader reader, String name, boolean validation)
           
 void parseElement()
          Gets the xml after digester parsing
 void parseXmlfromFile(String fileName)
          parse with validation from an xml file
protected  void setElement(Element element, Method method, 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 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:
Exception - if the stress test is not successfull

getTopLevelElement

public abstract AbsElement getTopLevelElement()
                                       throws Exception
Throws:
Exception

parse

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

startTest

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

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

parseElement

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

Throws:
Exception - if the parsing fail

parseXmlfromFile

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

Throws:
Exception - if the parsing fail

checkDiff

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

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

fill

public void fill(Element element,
                 boolean random)
          throws 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:
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,
                          Method method,
                          Class[] argsMethod,
                          boolean random)
                   throws 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:
Exception - if the subelement can not be added

setElement

protected void setElement(Element element,
                          Method method,
                          Class[] argsMethod,
                          boolean random)
                   throws 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:
Exception - if the subelement can not be set

fillString

protected void fillString(Element element,
                          Method method,
                          boolean random)
                   throws 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:
Exception - if the String attribute can not be added

fillQName

protected void fillQName(Element element,
                         Method method,
                         boolean random)
                  throws 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:
Exception - if the QName can not be set

getNameCounterForElement

protected String getNameCounterForElement(Element element,
                                          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 String convertUpperCaseToXml(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


Copyright © 2007 OW2 Consortium. All Rights Reserved.