JSlim  


com.gtcgroup.jslim
Class ServiceLocatorTesting

java.lang.Object
  extended bycom.gtcgroup.jslim.ServiceLocatorSuper
      extended bycom.gtcgroup.jslim.ServiceLocatorTesting

public final class ServiceLocatorTesting
extends ServiceLocatorSuper

This JSlim class provides additional ServiceLocator services intended (primarily) to enhance application (unit) testability.

For details please review the example jslim.xml.

Copyright (c) 1999 - 2004 by Global Technology Consulting Group, Inc. at gtcGroup.com.
Use is authorized, provided the source is acknowledged by inclusion of this copyright notice.

Since:
v. 1.0
Author:
MDT (MarvinToll@gtcGroup.com)

Constructor Summary
private ServiceLocatorTesting()
          Constructor.
 
Method Summary
static boolean closeJDBC(java.sql.Connection connection)
          This convenience method closes a Connection object.
static java.util.ArrayList getArray(java.lang.String strElementKey)
          This method returns an ArrayList object.
static boolean getBoolean(java.lang.String strElementKey)
          This method returns a boolean.
static int getInt(java.lang.String strElementKey)
          This method returns a int.
static java.sql.Connection getJDBC(java.lang.String strServiceKey)
          This method returns uncached JDBC Connection objects for unit testing.
static java.lang.String getText(java.lang.String strElementKey)
          This method returns an String object.
static void logDebug(java.lang.String strSourceClass, java.lang.String strSourceMethod, java.lang.String strMessage)
          Level - 300.
static void logEnter(java.lang.String strSourceClass, java.lang.String strSourceMethod)
          Level - 400.
static void logException(java.lang.String strSourceClass, java.lang.String strSourceMethod, java.lang.String strMessage, java.lang.Throwable throwable)
          Level - 500.
static void logExit(java.lang.String strSourceClass, java.lang.String strSourceMethod)
          Level - 400.
static void logFine(java.lang.String strSourceClass, java.lang.String strSourceMethod, java.lang.String strMessage)
          Level - 500.
static void logFiner(java.lang.String strSourceClass, java.lang.String strSourceMethod, java.lang.String strMessage)
          Level - 400.
static void logFinest(java.lang.String strSourceClass, java.lang.String strSourceMethod, java.lang.String strMessage)
          Level - 300.
static void logSQLException(java.lang.String strSourceClass, java.lang.String strSourceMethod, java.lang.String strMessage, java.sql.SQLException sE)
          Level - 500.
static void logWarning(java.lang.String strSourceClass, java.lang.String strSourceMethod, java.lang.String strMessage)
          Level - 500.
static void setUp(java.util.ArrayList alDocumentNames)
          This method supports unit testing with the dynamic loading of descriptor documents and automatic removal of previously cached resources.
static void setUp(java.util.ArrayList alDocumentNames, boolean blnOverWriteValues)
          This method supports unit testing with the dynamic loading of descriptor documents and automatic removal of previously cached resources.
static void setUp(java.lang.String strDocumentName)
          This method supports unit testing with the dynamic loading of descriptor documents and automatic removal of previously cached resources.
static void setUp(java.lang.String strDocumentName, boolean blnOverWriteValues)
          This method supports unit testing with the dynamic loading of descriptor documents and automatic removal of previously cached resources.
static void tearDown()
          This method supports unit testing by returning to the original descriptor document(s) state including no cached resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceLocatorTesting

private ServiceLocatorTesting()
Constructor.

Method Detail

getJDBC

public static final java.sql.Connection getJDBC(java.lang.String strServiceKey)
                                         throws JSlimException

This method returns uncached JDBC Connection objects for unit testing. The processing sequence is as follows:

Note: Connections should be closed [ServiceLocatorTesting.closeJDBC()] after use.

Parameters:
strServiceKey - Represents the service key read from a descriptor document.
Returns:
A Connection object.
Throws:
JSlimException - if an exception encountered.

closeJDBC

public static final boolean closeJDBC(java.sql.Connection connection)
                               throws JSlimException

This convenience method closes a Connection object.

Parameters:
connection - A connection (session) with a specific database. SQL statements are executed and results are returned within the context of a connection.
Returns:
Whether or not the Connection closed successfully.
Throws:
JSlimException - if an exception encountered.

setUp

public static final void setUp(java.lang.String strDocumentName)
                        throws JSlimException

This method supports unit testing with the dynamic loading of descriptor documents and automatic removal of previously cached resources. This version presumes it is appropriate to override existing values.

Parameters:
strDocumentName - The relative (to classpath) document name.
Throws:
JSlimException - if an exception encountered.

setUp

public static final void setUp(java.lang.String strDocumentName,
                               boolean blnOverWriteValues)
                        throws JSlimException

This method supports unit testing with the dynamic loading of descriptor documents and automatic removal of previously cached resources. This version has an argument indicating whether or not existing values should be overriden.

Parameters:
strDocumentName - The relative (to classpath) document name.
blnOverWriteValues - Indicates if previous values can be overridden.
Throws:
JSlimException - if an exception encountered.n

setUp

public static final void setUp(java.util.ArrayList alDocumentNames)
                        throws JSlimException

This method supports unit testing with the dynamic loading of descriptor documents and automatic removal of previously cached resources. This version presumes it is appropriate to override existing values.

Parameters:
alDocumentNames - A collection of relative (to classpath) document names.
Throws:
JSlimException - if an exception encountered.

setUp

public static final void setUp(java.util.ArrayList alDocumentNames,
                               boolean blnOverWriteValues)
                        throws JSlimException

This method supports unit testing with the dynamic loading of descriptor documents and automatic removal of previously cached resources. This version has an argument indicating whether or not existing values should be overriden.

Parameters:
alDocumentNames - A collection of relative (to classpath) document names.
blnOverWriteValues - Indicates if previous values can be overridden.
Throws:
JSlimException - if an exception encountered.

tearDown

public static final void tearDown()
                           throws JSlimException

This method supports unit testing by returning to the original descriptor document(s) state including no cached resources. In most cases, this means the state after the first invocation of JSlim - at which time the "jslim.xml" document(s) (if any) were originally loaded.

Throws:
JSlimException - if an exception encountered.

logException

public static final void logException(java.lang.String strSourceClass,
                                      java.lang.String strSourceMethod,
                                      java.lang.String strMessage,
                                      java.lang.Throwable throwable)
Level - 500.

Parameters:
strSourceClass - The class detecting the error.
strSourceMethod - The method detecting the error.
strMessage - The message.
throwable - The originating exception.

logSQLException

public static final void logSQLException(java.lang.String strSourceClass,
                                         java.lang.String strSourceMethod,
                                         java.lang.String strMessage,
                                         java.sql.SQLException sE)
Level - 500.

Parameters:
strSourceClass - The class detecting the error.
strSourceMethod - The method detecting the error.
strMessage - The message.
sE - The originating SQL exception.

logWarning

public static final void logWarning(java.lang.String strSourceClass,
                                    java.lang.String strSourceMethod,
                                    java.lang.String strMessage)
Level - 500.

Parameters:
strSourceClass - The class detecting the error.
strSourceMethod - The method detecting the error.
strMessage - The message.

logFine

public static final void logFine(java.lang.String strSourceClass,
                                 java.lang.String strSourceMethod,
                                 java.lang.String strMessage)
Level - 500.

Parameters:
strSourceClass - The class detecting the error.
strSourceMethod - The method detecting the error.
strMessage - The message.

logEnter

public static final void logEnter(java.lang.String strSourceClass,
                                  java.lang.String strSourceMethod)
Level - 400.

Parameters:
strSourceClass - The class detecting the error.
strSourceMethod - The method detecting the error.

logExit

public static final void logExit(java.lang.String strSourceClass,
                                 java.lang.String strSourceMethod)
Level - 400.

Parameters:
strSourceClass - The class detecting the error.
strSourceMethod - The method detecting the error.

logFiner

public static final void logFiner(java.lang.String strSourceClass,
                                  java.lang.String strSourceMethod,
                                  java.lang.String strMessage)
Level - 400.

Parameters:
strSourceClass - The class detecting the error.
strSourceMethod - The method detecting the error.
strMessage - The message.

logDebug

public static final void logDebug(java.lang.String strSourceClass,
                                  java.lang.String strSourceMethod,
                                  java.lang.String strMessage)
Level - 300.

Parameters:
strSourceClass - The class detecting the error.
strSourceMethod - The method detecting the error.
strMessage - The message.

logFinest

public static final void logFinest(java.lang.String strSourceClass,
                                   java.lang.String strSourceMethod,
                                   java.lang.String strMessage)
Level - 300.

Parameters:
strSourceClass - The class detecting the error.
strSourceMethod - The method detecting the error.
strMessage - The message.

getArray

public static final java.util.ArrayList getArray(java.lang.String strElementKey)
                                          throws JSlimException

This method returns an ArrayList object.

A _Property Service is optionally specified in a descriptor document. The following types are supported:

Parameters:
strElementKey - Represents an element key from a descriptor document.
Returns:
An ArrayList object.
Throws:
JSlimException - if an exception encountered.

getBoolean

public static final boolean getBoolean(java.lang.String strElementKey)
                                throws JSlimException

This method returns a boolean.

A _Property Service is optionally specified in a descriptor document. The following types are supported:

Parameters:
strElementKey - Represents an element key from a descriptor document.
Returns:
A boolean.
Throws:
JSlimException - if an exception encountered.

getInt

public static final int getInt(java.lang.String strElementKey)
                        throws JSlimException

This method returns a int.

A _Property Service is optionally specified in a descriptor document. The following types are supported:

Parameters:
strElementKey - Represents an element key from a descriptor document.
Returns:
A int.
Throws:
JSlimException - if an exception encountered.

getText

public static final java.lang.String getText(java.lang.String strElementKey)
                                      throws JSlimException

This method returns an String object.

A _Property Service is optionally specified in a descriptor document. The following types are supported:

Parameters:
strElementKey - Represents an element key from a descriptor document.
Returns:
An String object.
Throws:
JSlimException - if an exception encountered.

JSlim  


Copyright (c) 1999 - 2004 by Global Technology Consulting Group, Inc. at gtcGroup.com.
Use is authorized, provided the source is acknowledged by inclusion of this copyright notice.