public class TestHarness
extends java.lang.Object
if (TestHarness.isActive()) { TestHarness.setLisaProp("propname", "Value"); }
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
LISAINTTAG |
static java.lang.String |
LISAINTTAG2 |
Modifier and Type | Method and Description |
---|---|
static void |
addExceptionEvent(java.lang.Throwable th)
Tell lisa that an exception has occurred.
|
static void |
addExceptionEvent(java.lang.Throwable th,
boolean failTest)
Tell lisa that an exception has occurred.
|
static java.lang.String |
base64EncodedLisaTag(java.lang.String xmlRep)
Takes a garden-variety LISAInt xml string and base64 encodes it.
|
static java.lang.String |
closeOnCurrentThread()
If you have opened a LISA context you need to close it.
|
static void |
closeOnCurrentThread(javax.jms.Message message)
Closes the current LISA context and adds a LISA integration property to the message.
|
static void |
failTest(java.lang.String reason)
Tell lisa that the current node has failed and that the entire test
script should fail.
|
static CompInfo |
getCompInfoForCurrentThread()
For advanced users; This can be used to transmit very detailed
information back to the LISA instance such as internal exceptions (which
are normally hidden behind error pages), LISA log messages, etc.
|
static boolean |
getFailOnLoggedException() |
static boolean |
getForceGC() |
static java.lang.String |
getIntegrationLogLevel() |
static JavaIntegrator |
getJavaIntegratorForCurrentThread()
For advanced users; This can be used to transmit very detailed
information back to the LISA instance such as internal exceptions (which
are normally hidden behind error pages), LISA log messages, etc.
|
static java.lang.Object |
getJaxWsMessageContext()
Deprecated.
|
static java.lang.String |
getParentLoggerName() |
static boolean |
isActive()
Analogous to calling logger.isDebugEnabled() - this is a very inexpensive way to ensure that you don't
waste any cpu cycles building strings, etc to send to LISA when there's no LISA context anyway.
|
static boolean |
isEnabled()
Inexpensively determine whether LISA integration is configured for this
server.
|
static void |
log(java.lang.String message)
Log an arbitrary message to the LISA framework.
|
static TestHarness |
openOnCurrentThread(javax.jms.Message message)
Creates a new LISA context for the current thread.
|
static TestHarness |
openOnCurrentThread(java.lang.String transactionName)
Creates a new LISA context for the current thread.
|
static TestHarness |
openOnCurrentThread(java.lang.String transactionName,
boolean forceGC,
boolean failOnLoggedException,
java.lang.String parentLoggerName,
org.apache.log4j.Level parentLogLevel)
Assembles a LISA context on the current thread.
|
static void |
setDeferredLisaProp(java.lang.String propName,
java.lang.Object propValue)
Set an arbitrary property name to a value.
|
static void |
setFailOnLoggedException(boolean value) |
static void |
setJaxWsMessageContext(java.lang.Object o)
Deprecated.
|
static void |
setLisaProp(java.lang.String propName,
java.lang.Object propValue)
Set an arbitrary property name to a value.
|
static void |
setLisaProp(java.lang.String propName,
java.io.Serializable propValue)
Old declaration (Serializeable value).
|
public static final java.lang.String LISAINTTAG
public static final java.lang.String LISAINTTAG2
public static boolean isEnabled()
public static boolean isActive()
For example:
if (TestHarness.isActive()) TestHarness.setLisaProp("myProp", object.someExpensiveCall());
public static TestHarness openOnCurrentThread(java.lang.String transactionName)
transactionName
- an arbitrary nameopenOnCurrentThread(String,boolean,boolean,String,Level)
public static TestHarness openOnCurrentThread(javax.jms.Message message) throws javax.jms.JMSException
message
- - the JMS message you have received and are starting to transact. Future versions of LISA may
parse the message properties to look for LISA integration directivesjavax.jms.JMSException
- if the call to getJMSCorellationID failsopenOnCurrentThread(String)
public static TestHarness openOnCurrentThread(java.lang.String transactionName, boolean forceGC, boolean failOnLoggedException, java.lang.String parentLoggerName, org.apache.log4j.Level parentLogLevel)
transactionName
- The transaction name reported back to LISA. May be null.forceGC
- Whether to call System.gc() several times before computing Heap metrics for LISA. Doing so will
give you a more accurate indication of the memory cost of a transaction and help detect memory leaks early. It
is an expensive operation, sometimes taking seconds, depending on the VM and the state of the heap.failOnLoggedException
- Whether to fail the LISA test if log4j is called with an exception during the transaction. This is
usually indicative of an error however it is common for the exception to be logged and 'swallowed', leading to tests which
appear to pass but in fact are failing. By default LISA tests will fail if an exception is logged but sometimes you want to
test that an exception is being logged (eg a duplicate primary key). So you would have a LISA test that deliberately creates
an exception and tests that it occurs, but the LISA test as a whole should not fail.parentLoggerName
- The top-level log4j logger to gather log messages from. If empty or null, the root logger is used.
More typically you would set this to something like 'com.mycompany.myproduct.mycomponent' to reduce
the verbosity of DEBUG messages. If you set the parentLogLevel to INFO it's usually OK to have this
emptyparentLogLevel
- The level of logging detail you wish to capture in the LISA context.java.lang.IllegalStateException
- if LISA_Integration is not enabled.public static java.lang.String closeOnCurrentThread()
public static void closeOnCurrentThread(javax.jms.Message message) throws javax.jms.JMSException
message
- The message will have a LISAINT2 property added to it which can be interpreted by the JmsFilter
on the LISA client side.javax.jms.JMSException
- if the message is read-only or cannot be changedpublic static CompInfo getCompInfoForCurrentThread()
public static JavaIntegrator getJavaIntegratorForCurrentThread()
public static void setLisaProp(java.lang.String propName, java.io.Serializable propValue)
propName
- propValue
- public static void setLisaProp(java.lang.String propName, java.lang.Object propValue)
propName
- An arbitrary property name.propValue
- Any object; it will be serialized by XStream ((http://xstream.codehaus.org) and deserialized
on the LISA side if the necessary classes are available. At the very least, the XML representation of the
object is available as 'propName.xml'public static void setDeferredLisaProp(java.lang.String propName, java.lang.Object propValue)
propName
- An arbitrary property name.propValue
- any object, but usually you would use a string. objects are serialized using xstreampublic static void log(java.lang.String message)
message
- An arbitrary message which raise an EVENT_NODEMSG on the LISA
side with the message in the long info fieldjava.lang.IllegalStateException
- if LISA Integration is not activepublic static void failTest(java.lang.String reason)
reason
- Some arbitrary reason. Maybe e.getMessage()public static void addExceptionEvent(java.lang.Throwable th)
th
- The exceptionpublic static void addExceptionEvent(java.lang.Throwable th, boolean failTest)
th
- The exceptionfailTest
- whether to immediately fail the testpublic static java.lang.String base64EncodedLisaTag(java.lang.String xmlRep)
xmlRep
- Some arbitrary stringpublic static java.lang.String getIntegrationLogLevel()
public static java.lang.String getParentLoggerName()
public static boolean getForceGC()
public static boolean getFailOnLoggedException()
public static void setFailOnLoggedException(boolean value)
public static java.lang.Object getJaxWsMessageContext()
public static void setJaxWsMessageContext(java.lang.Object o)
Copyright © 1998-2014 CA, Inc. All Rights Reserved.