org.hd.d.pg2k.test.dev
Class HTTPTunnelTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.hd.d.pg2k.test.dev.HTTPTunnelTest
All Implemented Interfaces:
junit.framework.Test

public final class HTTPTunnelTest
extends junit.framework.TestCase

Test the HTTP communications tunnel. May need to be running in a WAR container and in master mode for this to work (unless, exceptionally, the loopbackURL is pointing at another instance).


Field Summary
private  SimpleLoggerIF logger
           
private static java.util.Random rnd
          Private source of OK pseudo-random numbers.
 
Constructor Summary
HTTPTunnelTest(java.lang.String name)
           
 
Method Summary
static boolean canConnectToLoopbackURL()
          Check that we can open a basic HTTP connection OK to the loopbackURL.
static DataSourceBean getDataSourceBeanIfMaster()
          If ServletContext exists and we are in master mode, return DataSource.
 void testAgainstDeadMaster()
          Test behaviour against dead master.
static void testHTTPLoopback()
          Does basic loopback test.
 void testHTTPTunnelNOOP()
          Attempts basic test of tunnel by doing a NO-OP (NOOP).
static void testIntSerRoutines()
          Test that our hand-crafted serialisation routines work.
static void testRawPacketStreamSerialiseObject()
          Test that stream-serialising compression works...
 void testTunnelBasic()
          Attempts to test basic use of the tunnel for normal traffic.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, 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

logger

private final SimpleLoggerIF logger

rnd

private static final java.util.Random rnd
Private source of OK pseudo-random numbers.

Constructor Detail

HTTPTunnelTest

public HTTPTunnelTest(java.lang.String name)
Method Detail

testIntSerRoutines

public static void testIntSerRoutines()
                               throws java.lang.Exception
Test that our hand-crafted serialisation routines work. This primarily means that we can decode with DataInputStream what we hand-encoded.

Throws:
java.lang.Exception

testRawPacketStreamSerialiseObject

public static void testRawPacketStreamSerialiseObject()
                                               throws java.lang.Exception
Test that stream-serialising compression works...

Throws:
java.lang.Exception

canConnectToLoopbackURL

public static boolean canConnectToLoopbackURL()
Check that we can open a basic HTTP connection OK to the loopbackURL. Returns immediately if no loopbackURL is set.


getDataSourceBeanIfMaster

public static DataSourceBean getDataSourceBeanIfMaster()
If ServletContext exists and we are in master mode, return DataSource. Also, we check that basic loop-back is OK.

Else we return null.


testHTTPLoopback

public static void testHTTPLoopback()
Does basic loopback test. If not, does not cause a failure but warns that this is not possible. Mainly useful in case other tests are silently disabled by this.


testHTTPTunnelNOOP

public void testHTTPTunnelNOOP()
                        throws java.lang.Exception
Attempts basic test of tunnel by doing a NO-OP (NOOP). May require us to be in "master" mode.

Throws:
java.lang.Exception

testTunnelBasic

public void testTunnelBasic()
                     throws java.lang.Exception
Attempts to test basic use of the tunnel for normal traffic. May require us to be in "master" mode.

Throws:
java.lang.Exception

testAgainstDeadMaster

public void testAgainstDeadMaster()
                           throws java.lang.Exception
Test behaviour against dead master. We do this by connecting to a bogus loopback address.

We do not have to be master for this, nor even running as a servlet...

We simply check that we recover from a first dead connection, then subsequent connection attempts are refused for at least the minimum failure time and not much more than the maximum... These refusals should be with a "PGMasterNotInService" exception.

Throws:
java.lang.Exception

DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.