Email Answering System
Version 1.0

test
Class ManagedConnectionUnitTest

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--test.ManagedConnectionUnitTest
All Implemented Interfaces:
ConnectionEventListener, EventListener, junit.framework.Test

public class ManagedConnectionUnitTest
extends junit.framework.TestCase
implements ConnectionEventListener

Unit test for the email resource adapter managed connection.

Author:
Derrick Oswald

Field Summary
protected  ArrayList mEvents
          Event history.
protected  ManagedConnection mManagedConnection
          The managed connection used in the tests.
protected  EmailManagedConnectionFactory mManagedConnectionFactory
          The managed connection factory used to create the managed connections used in the tests.
 
Constructor Summary
ManagedConnectionUnitTest(String testName)
          Construct a ManagedConnection test.
 
Method Summary
protected  void addEvent(String name, ConnectionEvent event)
          Add an event to the event history
protected  void clearEvents()
          Clear out the event history.
 void connectionClosed(ConnectionEvent event)
          Method called when a connection is closed.
 void connectionErrorOccurred(ConnectionEvent event)
          Method called when a connection error occurs.
 void localTransactionCommitted(ConnectionEvent event)
          Method called when a local transaction is committed.
 void localTransactionRolledback(ConnectionEvent event)
          Method called when a local transaction is rolled back.
 void localTransactionStarted(ConnectionEvent event)
          Method called when a local transaction is started.
static void main(String[] args)
          Mainline for the ManagedConnection.
protected  void setUp()
          Create a managed connection.
protected  String showBytes(byte[] data)
          Create a string representation of an array of bytes.
static junit.framework.Test suite()
          Create the suite of tests for the ManagedConnection.
 void test2Cleanups()
          Test calling the cleanup method twice.
 void testAssociateConnection()
          Test the associate connection method.
 void testCleanup()
          Test the cleanup method.
 void testConnectionListener()
          Test the listener methods.
 void testDestroy()
          Test the destroy method.
 void testGetConnection()
          Test the get connection method.
 void testGetConnectionWithSubject()
          Test the get connection method.
 void testGetMetaData()
          Test the get meta data method.
 void testLogWriter()
          Test the logWriter property.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mManagedConnectionFactory

protected EmailManagedConnectionFactory mManagedConnectionFactory
The managed connection factory used to create the managed connections used in the tests. Used in setup() and separately in associate connection test.


mManagedConnection

protected ManagedConnection mManagedConnection
The managed connection used in the tests.


mEvents

protected ArrayList mEvents
Event history.

Constructor Detail

ManagedConnectionUnitTest

public ManagedConnectionUnitTest(String testName)
Construct a ManagedConnection test.

Parameters:
testName - the name of the test
Method Detail

suite

public static junit.framework.Test suite()
Create the suite of tests for the ManagedConnection.

Returns:
The suite of tests.

setUp

protected void setUp()
Create a managed connection.

Overrides:
setUp in class junit.framework.TestCase

addEvent

protected void addEvent(String name,
                        ConnectionEvent event)
Add an event to the event history

Parameters:
name - The mnemonic of the method recieving the event.
event - The event received.

clearEvents

protected void clearEvents()
Clear out the event history.


connectionErrorOccurred

public void connectionErrorOccurred(ConnectionEvent event)
Method called when a connection error occurs.

Specified by:
connectionErrorOccurred in interface ConnectionEventListener
Parameters:
event - The error event information.

localTransactionStarted

public void localTransactionStarted(ConnectionEvent event)
Method called when a local transaction is started.

Specified by:
localTransactionStarted in interface ConnectionEventListener
Parameters:
event - The transaction event information.

localTransactionCommitted

public void localTransactionCommitted(ConnectionEvent event)
Method called when a local transaction is committed.

Specified by:
localTransactionCommitted in interface ConnectionEventListener
Parameters:
event - The transaction event information.

connectionClosed

public void connectionClosed(ConnectionEvent event)
Method called when a connection is closed.

Specified by:
connectionClosed in interface ConnectionEventListener
Parameters:
event - The connection close event information.

localTransactionRolledback

public void localTransactionRolledback(ConnectionEvent event)
Method called when a local transaction is rolled back.

Specified by:
localTransactionRolledback in interface ConnectionEventListener
Parameters:
event - The transaction event information.

showBytes

protected String showBytes(byte[] data)
Create a string representation of an array of bytes. Shows the first 16 bytes in an array as "[xx yy...]".

Parameters:
data - The data to display.
Returns:
The string representation of the bytes in the array

testLogWriter

public void testLogWriter()
Test the logWriter property.


testGetConnection

public void testGetConnection()
Test the get connection method.


testGetConnectionWithSubject

public void testGetConnectionWithSubject()
Test the get connection method.


testGetMetaData

public void testGetMetaData()
Test the get meta data method.


testConnectionListener

public void testConnectionListener()
Test the listener methods. Still need to test connectionErrorOccurred, localTransactionStarted, localTransactionCommitted, and localTransactionRolledback.


testAssociateConnection

public void testAssociateConnection()
Test the associate connection method.


testCleanup

public void testCleanup()
Test the cleanup method.


test2Cleanups

public void test2Cleanups()
Test calling the cleanup method twice.


testDestroy

public void testDestroy()
Test the destroy method.


main

public static void main(String[] args)
Mainline for the ManagedConnection. Invoke the JUnit mainline.

Parameters:
args - JUnit arguments, optionally prefixed by a JUnit test runner class name. The default is junit.swingui.TestRunner, but other possibilities include:

junit.textui.TestRunner

junit.awtui.TestRunner


Email Answering System
Version 1.0

Copyright © 2003 Derrick Oswald. All rights reserved.