net.sf.jameleon.data
Class SqlTag

java.lang.Object
  extended by org.apache.commons.jelly.TagSupport
      extended by net.sf.jameleon.LocationAwareTagSupport
          extended by net.sf.jameleon.JameleonTagSupport
              extended by net.sf.jameleon.data.AbstractDataDrivableTag
                  extended by net.sf.jameleon.data.SqlTag
All Implemented Interfaces:
DataDrivable, BreakPoint, Attributable, DataDrivableResultRecordable, FunctionResultRecordable, SessionResultRecordable, DynaTag, LocationAware, Tag

public class SqlTag
extends AbstractDataDrivableTag

Used to iterate over all tags it is surrounding one time per row in a SQL ResultSet. This tag should work with any RDBMS that provides a JDBC driver. One thing to remember is each JDBC driver seems to act a bit differently when returning the column names returned. Some JDBC drivers will returned the column names in all caps some will return them as undercase, while others may return them as defined when the table was created.


 <testcase xmlns="jelly:jameleon">
   <sql query="SELECT ID, col1 as NAME, col2 as GENDER FROM TEST"
        jdbcUsername="sa"
        jdbcPassword=""
        jdbcUrl="jdbc:hsqldb:hsqldb_sample"
        jdbcDriver="org.hsqldb.jdbcDriver"
        countRow="true">

     <some-session application="someApp" beginSession="true">
       <some-tag-that-uses-context-variables
           functionId="Verify successful navigation, using a different variable."
           id="${ID}"
           name="${NAME}"
           gender="${GENDER}"/>
     </some-session>
   </sql>
 </testcase>
 

Tag Name: <sql>

Field Summary
protected  String id
           
protected  String jdbcDriver
           
protected  String jdbcPassword
           
protected  String jdbcUrl
           
protected  String jdbcUsername
           
protected  String query
           
protected  SqlDataDriver sqld
           
 
Fields inherited from class net.sf.jameleon.data.AbstractDataDrivableTag
addt, breakPoint, countRow, dataDrivableRowResult, executer, failedOnCurrentRow, log, numOfRowFailures, parentFailed, previousStateDir, resultContainer, resultRecorder, rowData, stateStorer, stopTestExecutionOnFailure, tct, vars, xmlOut
 
Fields inherited from class net.sf.jameleon.JameleonTagSupport
attributes, broker, contextVars, fp, unsupportedAttributes
 
Fields inherited from class net.sf.jameleon.LocationAwareTagSupport
columnNumber, elementTagName, lineNumber, scriptFileName
 
Fields inherited from class org.apache.commons.jelly.TagSupport
body, context, hasTrimmed, parent, shouldTrim
 
Constructor Summary
SqlTag()
           
 
Method Summary
protected  DataDriver getDataDriver()
          Gets the DataDriver used for this tag.
protected  String getDataExceptionMessage()
          Gets an error message to be displayed when a error occurs due to the DataDriver.
protected  org.apache.log4j.Logger getLogger()
          Gets the logger used for this tag
protected  String getNewStateStoreLocation(int rowNum)
          Calculates the location of the state to be stored for any tags under this tag.
 String getQuery()
          Gets the query to be used for this tag
 String getTagDescription()
          Describe the tag when error messages occur.
protected  String getTagTraceMsg()
          Gets the trace message when the execution is beginning and ending.
 void setId(String id)
          Set the SQL ID number This is primarily used for debugging.
 void setJdbcDriver(String jdbcDriver)
          Set the JDBC Driver needed for the Database Connection
 void setJdbcPassword(String jdbcPassword)
          Set the JDBC Password for the Database Connection
 void setJdbcUrl(String jdbcUrl)
          Set the JDBC URL for the Database Connection
 void setJdbcUsername(String jdbcUsername)
          Set the JDBC UserName for the Database Connection
 void setQuery(String query)
          Set the SQL Query for the Database Connection
protected  void setupDataDriver()
          Sets up the DataDriver by calling any implementation-dependent methods.
 
Methods inherited from class net.sf.jameleon.data.AbstractDataDrivableTag
addVariablesToRowData, createNewResult, destroyVariables, doTag, executeDrivableRow, getDataDrivableRowResult, getFailedOnCurrentRow, getKeyMapping, getResultContainer, getRowData, getTestCaseTag, getTraceKeyValuePairs, init, isBreakPoint, isCountRow, mapKeys, recordDataDrivableResult, recordFunctionResult, recordResult, recordSessionResult, recordThisResult, removeChildlessResult, setBreakPoint, setCountRow, setFailedOnCurrentRow, setResultError, setStopTestExecutionOnFailure, setUpDataDrivable, setVariablesInContext, traceMsg
 
Methods inherited from class net.sf.jameleon.JameleonTagSupport
cleanVariablesInContext, createAttributes, describeAttributes, getAttributeBroker, getAttributes, getAttributeType, getClassAttributes, getFunctionalPoint, getUnsupportedAttributes, loadFunctionalPoint, resetFunctionalPoint, setAttribute, setVariableInContext, testForUnsupportedAttributesCaught
 
Methods inherited from class net.sf.jameleon.LocationAwareTagSupport
getColumnNumber, getElementName, getFileName, getLineNumber, setColumnNumber, setElementName, setFileName, setLineNumber
 
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.jelly.Tag
getBody, getContext, getParent, invokeBody, setBody, setContext, setParent
 

Field Detail

sqld

protected SqlDataDriver sqld

query

protected String query

id

protected String id

jdbcDriver

protected String jdbcDriver

jdbcUrl

protected String jdbcUrl

jdbcUsername

protected String jdbcUsername

jdbcPassword

protected String jdbcPassword
Constructor Detail

SqlTag

public SqlTag()
Method Detail

getLogger

protected org.apache.log4j.Logger getLogger()
Gets the logger used for this tag

Specified by:
getLogger in class AbstractDataDrivableTag
Returns:
the logger used for this tag.

getDataDriver

protected DataDriver getDataDriver()
Gets the DataDriver used for this tag.

Specified by:
getDataDriver in class AbstractDataDrivableTag
Returns:
the DataDriver used for this tag.

getDataExceptionMessage

protected String getDataExceptionMessage()
Gets an error message to be displayed when a error occurs due to the DataDriver.

Specified by:
getDataExceptionMessage in class AbstractDataDrivableTag
Returns:
an error message to be displayed when a error occurs due to the DataDriver.

setupDataDriver

protected void setupDataDriver()
Sets up the DataDriver by calling any implementation-dependent methods.

Specified by:
setupDataDriver in class AbstractDataDrivableTag

getQuery

public String getQuery()
Gets the query to be used for this tag

Returns:
the query used by this tag

getTagTraceMsg

protected String getTagTraceMsg()
Gets the trace message when the execution is beginning and ending. The message displayed will already start with BEGIN: or END:

Specified by:
getTagTraceMsg in class AbstractDataDrivableTag
Returns:
the trace message when the execution is just beginning and ending.

getTagDescription

public String getTagDescription()
Describe the tag when error messages occur. The most appropriate message might be the tag name itself.

Specified by:
getTagDescription in class AbstractDataDrivableTag
Returns:
A brief description of the tag or the tag name itself.

getNewStateStoreLocation

protected String getNewStateStoreLocation(int rowNum)
Calculates the location of the state to be stored for any tags under this tag. The result should be a relative path that simply has the row number in it along with some unique indentifier for this tag like the handle name or something.

Specified by:
getNewStateStoreLocation in class AbstractDataDrivableTag
Returns:
the location of the state to be stored for any tags under this tag minus the baseDir calculation stuff.

setJdbcDriver

public void setJdbcDriver(String jdbcDriver)
Set the JDBC Driver needed for the Database Connection

This attribute is recognized by Jameleon
Required: true

setJdbcUrl

public void setJdbcUrl(String jdbcUrl)
Set the JDBC URL for the Database Connection

This attribute is recognized by Jameleon
Required: true

setJdbcUsername

public void setJdbcUsername(String jdbcUsername)
Set the JDBC UserName for the Database Connection

This attribute is recognized by Jameleon
Required: true

setJdbcPassword

public void setJdbcPassword(String jdbcPassword)
Set the JDBC Password for the Database Connection

This attribute is recognized by Jameleon
Required: false

setQuery

public void setQuery(String query)
Set the SQL Query for the Database Connection

This attribute is recognized by Jameleon
Required: true

setId

public void setId(String id)
Set the SQL ID number This is primarily used for debugging. It also provides a means to distinguish between nested SqlTag tags.

This attribute is recognized by Jameleon
Required: false


Copyright © 2003-2008 Christian Hargraves. All Rights Reserved.