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

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

public final class TunnelTest
extends junit.framework.TestCase

Test the communications tunnel stand-alone (not relying on HTTP, etc).


Field Summary
private  SimpleLoggerIF logger
           
private static java.util.Random rnd
          Private source of OK pseudo-random numbers.
 
Constructor Summary
TunnelTest(java.lang.String name)
           
 
Method Summary
(package private) static void checkExhibitDataConsistency(SimpleExhibitPipelineIF stageA, SimpleExhibitPipelineIF stageB, boolean overTunnel, long stopBy)
          Check that exhibit properties and data from two points match.
static void testAEPDiffTunnel()
          Test getAEP 'diff' routine across the tunnel.
static void testHMACEfficacy()
          Test that our HMAC does detect corruption in, or tampering with, messages.
static void testIntSerRoutines()
          Test that our hand-crafted serialisation routines work.
static void testRawPacketStreamSerialiseObject()
          Test that stream-serialising compression works...
static void testRawPacketWithOverlengthBuffer()
          Test RawPacket using initial portion of over-length input buffer.
 void testTunnelGetRawData()
          Tests basic transparency and behaviour of generic tunnel.
 void testTunnelNOOP()
          Tests basic transparency and behaviour of generic tunnel.
 void testTunnelThumbnails()
          Tests basic transparency and behaviour of generic tunnel.
 
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

TunnelTest

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

testTunnelNOOP

public void testTunnelNOOP()
                    throws java.lang.Exception
Tests basic transparency and behaviour of generic tunnel.

Throws:
java.lang.Exception

testTunnelGetRawData

public void testTunnelGetRawData()
                          throws java.lang.Exception
Tests basic transparency and behaviour of generic tunnel.

Throws:
java.lang.Exception

testTunnelThumbnails

public void testTunnelThumbnails()
                          throws java.lang.Exception
Tests basic transparency and behaviour of generic tunnel.

Throws:
java.lang.Exception

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

testRawPacketWithOverlengthBuffer

public static void testRawPacketWithOverlengthBuffer()
Test RawPacket using initial portion of over-length input buffer.


testRawPacketStreamSerialiseObject

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

Throws:
java.lang.Exception

checkExhibitDataConsistency

static void checkExhibitDataConsistency(SimpleExhibitPipelineIF stageA,
                                        SimpleExhibitPipelineIF stageB,
                                        boolean overTunnel,
                                        long stopBy)
                                 throws java.io.IOException
Check that exhibit properties and data from two points match. The two points can be either side of a tunnel, or either side of a cache, for example.

Any cacheing stages are assumed to have been running long enough (usually at least one poll() if they are asynchronous) to have brought meta-data (eg properties) up-to-date.

Package-visible to be available to other test cases.

Parameters:
stageA - one sample stage in a pipeline possibly on slave side of tunnel); never null
stageB - another sample stage in a pipeline in the same system; never null
overTunnel - if true, the two stages are on either side of a tunnel and objects should have been serialised between the sample stages
stopBy - a target time to stop by when all distinct tests have been run at least once
Throws:
java.io.IOException - in case of unexpected I/O problems

testAEPDiffTunnel

public static void testAEPDiffTunnel()
                              throws java.lang.Exception
Test getAEP 'diff' routine across the tunnel. Checks that it always generates correct results.

Throws:
java.lang.Exception

testHMACEfficacy

public static void testHMACEfficacy()
                             throws java.lang.Exception
Test that our HMAC does detect corruption in, or tampering with, messages. Not even a single-bit change, nor any deletion or insertion of bytes, should go unobserved.

Also, the timestamp and unique ID should prevent replay attacks (and should keep potential participants with bad clocks from communicating).

Note that whatever works on complete messages should also work on streamed messages, though there is an onus on the streaming-related code to behave safely even if fed bogus data.

Throws:
java.lang.Exception

DHD Multimedia Gallery V1.60.69

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