SAT: Socket Acceptance Test

Rick Mugridge, October 2002

Sat is a framework for testing socket-based servers. It uses Fit as its means of getting test input from an html file (such as this one), and for providing feedback on the tests.

Sat uses a SatFixture table to process tests (this class in turn extends ActionRowFixture, which provides a general approach to running commands on each row in turn).

The rows of the table are as follows:

See TestSATXml.html for details of a fixture for handling XML messages.

Single Client Tests

Test Valid Response

ServerHelloHi expects to receive "<Hello/>" and if it does, it replies with "<Hi/>".

sat.fit.SatFixture
startServer sat.mockServer.ServerHelloHi
send <Hello/>
delay 100
comment We should receive Hi in the next message
rx <Hi/>
send <Shutdown/>
stopServer

Test Wrong message sent first

If ServerHelloHi doesn't receive "<Hello/>" it replies with a message specifying what it expected:

sat.fit.SatFixture
startServer sat.mockServer.ServerHelloHi
send <Hello2/>
rx Expected '<Hello/>' but got '<Hello2/>'
send <Shutdown/>
stopServer

Here we can check that we don't expect to receive "<Hi/>":

sat.fit.SatFixture
startServer sat.mockServer.ServerHelloHi
send <Hello2/>
rxDiffers <Hi/>
send <Shutdown/>
stopServer

Test Extra Read

sat.fit.SatFixture
startServer sat.mockServer.ServerHelloHi
send <Hello/>
rx <Hi/>
rxTimesOut <Hi/>
send <Shutdown/>
stopServer

Extra Client

The mock server used here will only accept a connection with a single client. 

This tests that send and rx are refused with the second client.

sat.fit.SatFixture
startServer sat.mockServer.ServerHelloHi
send <Hello/>
sendRefused <Hello/>
rx <Hi/>
rxRefused <Hi/>
send <Shutdown/>
sendRefused <Shutdown/>
stopServer

Two Client Tests

Test Valid Response

sat.fit.SatFixture
startServer sat.mockServer.ServerTwoConnections
send <Hello/> <Hello2/>
rx <Hi/> <Hi2/>
send <Shutdown/>
stopServer

Test wrong receipt on Second Client

sat.fit.SatFixture
startServer sat.mockServer.ServerTwoConnections
send <Hello/> <Hello2/>
rx <Hi/>
rxDiffers <Hi2222/>
send <Shutdown/>
stopServer

Test Extra rx on Second Client

sat.fit.SatFixture
startServer sat.mockServer.ServerTwoConnections
send <Hello/> <Hello2/>
rx <Hi/> <Hi2/>
rxTimesOut <Hi2/>
send <Shutdown/>
stopServer

Test Close on Second Client

sat.fit.SatFixture
startServer sat.mockServer.ServerTwoConnections
send <Hello/> <Hello2/>
rx <Hi/> <Hi2/>
close close
send <Shutdown/>
stopServer

Timeouts and Post-Send Delays

I'm slack here, as I haven't bothered to automatically test that the delays occur as required.  An exercise for the reader.

sat.fit.SatFixture
postSendDelay 100
timeOut 1000
startServer sat.mockServer.ServerTwoConnections
send <Hello/> <Hello2/>
delay 200
rx <Hi/> <Hi2/>
postSendDelay 100
send <Shutdown/>
stopServer

Tracing

Test tracing

I'm slack here, as I haven't bothered to automatically test that the tracing output appears.  An exercise for the reader.

sat.fit.SatFixture
traceOn  
startServer sat.mockServer.ServerTwoConnections
traceOff  
send <Hello/> <Hello2/>
rx <Hi/> <Hi2/>
traceOn  
send <Shutdown/>
stopServer

Summary

fit.Summary