package jamex.link;

import java.util.LinkedList;
import javax.jms.Connection;
import javax.jms.Session;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;

public class AbstractBrokerBasedTestCase
{
  private Connection m_connection;
  private final LinkedList<Session> m_sessions = new LinkedList<Session>();

  @BeforeClass
  public static void startupBroker()
    throws Exception
  {
    TestHelper.startupBroker();
  }

  @AfterClass
  public static void shutdownBroker()
    throws Exception
  {
    TestHelper.shutdownBroker();
  }

  @Before
  public void initSesion()
    throws Exception
  {
    // Create the connection.
    m_connection = TestHelper.createConnection();
    m_connection.start();

    // Create the session

  }

  @After
  public void shutdownSesion()
    throws Exception
  {
    for( final Session session : m_sessions )
    {
      session.close();
    }
    m_sessions.clear();
    if( null != m_connection )
    {
      m_connection.stop();
      m_connection = null;
    }
  }

  protected final Session createSession()
    throws Exception
  {
    return createSession( false, Session.AUTO_ACKNOWLEDGE );
  }

  protected final Session createSession( final boolean transacted, final int acknowledgeMode )
    throws Exception
  {
    final Session session = getConnection().createSession( transacted, acknowledgeMode );
    m_sessions.add( session );
    return session;
  }

  protected final Connection getConnection()
  {
    if( null == m_connection )
    {
      throw new IllegalStateException( "null == m_connection" );
    }
    return m_connection;
  }
}
@@ -619,19 +619,23 @@
 oid init
-Ses
+Connect
 ion()%0A  
@@ -661,38 +661,8 @@
   %7B%0A
-    // Create the connection.%0A
     
@@ -737,36 +737,8 @@
 ();%0A
-%0A    // Create the session%0A%0A
   %7D%0A
@@ -769,19 +769,23 @@
 shutdown
-Ses
+Connect
 ion()%0A  

Refactor to improve naming