io.socket
Class AbstractTestSocketIO

java.lang.Object
  extended by io.socket.AbstractTestSocketIO
All Implemented Interfaces:
IOCallback
Direct Known Subclasses:
WebsocketTestSocketIO, XHRTestSocketIO

public abstract class AbstractTestSocketIO
extends java.lang.Object
implements IOCallback

The Class AbstractTestSocketIO.


Field Summary
(package private)  java.util.concurrent.LinkedBlockingQueue<java.lang.Object> args
          Received arguments of events
(package private)  java.util.concurrent.LinkedBlockingQueue<java.lang.String> events
          Received queues.
(package private)  java.util.concurrent.LinkedBlockingQueue<java.lang.String> outputs
          stdout of the node executable
(package private)  java.lang.Thread stderrThread
          Thread for processing stderr
(package private)  java.lang.Thread stdoutThread
          Thread for processing stdout
protected static java.lang.String transport
          The transport of this test
 
Constructor Summary
AbstractTestSocketIO()
           
 
Method Summary
 void acknowledge()
          Acknowledge.
(package private)  void doClose()
          Closes a SocketIO connection.
(package private)  void doConnect()
          Sets up a SocketIO connection.
 void emitAndMessage()
          Emit and message.
 void emitAndOn()
          Emit and on.
 void error()
          Error.
 int getPort()
          Gets the port.
 int getProxyPort()
           
 void namespaces()
          Namespaces.
 void on(java.lang.String event, IOAcknowledge ack, java.lang.Object... args)
          On [Event].
 void onConnect()
          On connect.
 void onDisconnect()
          On disconnect.
 void onError(SocketIOException socketIOException)
          On error.
 void onMessage(org.json.JSONObject json, IOAcknowledge ack)
          On message.
 void onMessage(java.lang.String data, IOAcknowledge ack)
          On message.
 void send()
          Tests sending of a message to the server.
 void setUp()
          Sets up the test.
(package private)  java.lang.Object takeArg()
          Take arg.
(package private)  java.lang.String takeEvent()
          Take event.
(package private)  java.lang.String takeLine()
          Take line.
 void tearDown()
          Tears down this test.
static void tearDownAfterClass()
          Tear down after class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

events

java.util.concurrent.LinkedBlockingQueue<java.lang.String> events
Received queues.


outputs

java.util.concurrent.LinkedBlockingQueue<java.lang.String> outputs
stdout of the node executable


args

java.util.concurrent.LinkedBlockingQueue<java.lang.Object> args
Received arguments of events


stdoutThread

java.lang.Thread stdoutThread
Thread for processing stdout


stderrThread

java.lang.Thread stderrThread
Thread for processing stderr


transport

protected static java.lang.String transport
The transport of this test

Constructor Detail

AbstractTestSocketIO

public AbstractTestSocketIO()
Method Detail

tearDownAfterClass

public static void tearDownAfterClass()
                               throws java.lang.Exception
Tear down after class.

Throws:
java.lang.Exception - the exception

setUp

public void setUp()
           throws java.lang.Exception
Sets up the test. Starts the node testserver on a randomly choosed port, starts backgroundthreads for processing stdin/stdout. Adds shutdown-hook for clean kill of the node server.

Throws:
java.lang.Exception - the exception

tearDown

public void tearDown()
              throws java.lang.Exception
Tears down this test. Assures queues are empty.

Throws:
java.lang.Exception - the exception

doConnect

void doConnect()
         throws java.lang.Exception
Sets up a SocketIO connection.

Throws:
java.lang.Exception - the exception

doClose

void doClose()
       throws java.lang.Exception
Closes a SocketIO connection.

Throws:
java.lang.Exception - the exception

send

public void send()
          throws java.lang.Exception
Tests sending of a message to the server. Assures result by stdout.

Throws:
java.lang.Exception - the exception

emitAndOn

public void emitAndOn()
               throws java.lang.Exception
Emit and on.

Throws:
java.lang.Exception - the exception

emitAndMessage

public void emitAndMessage()
                    throws java.lang.Exception
Emit and message.

Throws:
java.lang.Exception - the exception

namespaces

public void namespaces()
                throws java.lang.Exception
Namespaces.

Throws:
java.lang.Exception - the exception

error

public void error()
           throws java.lang.Exception
Error.

Throws:
java.lang.Exception - the exception

acknowledge

public void acknowledge()
                 throws java.lang.Exception
Acknowledge.

Throws:
java.lang.Exception - the exception

takeEvent

java.lang.String takeEvent()
                     throws java.lang.InterruptedException
Take event.

Returns:
the string
Throws:
java.lang.InterruptedException - the interrupted exception

takeLine

java.lang.String takeLine()
                    throws java.lang.InterruptedException
Take line.

Returns:
the string
Throws:
java.lang.InterruptedException - the interrupted exception

takeArg

java.lang.Object takeArg()
                   throws java.lang.InterruptedException
Take arg.

Returns:
the object
Throws:
java.lang.InterruptedException - the interrupted exception

onDisconnect

public void onDisconnect()
Description copied from interface: IOCallback
On disconnect. Called when the socket disconnects and there are no further attempts to reconnect

Specified by:
onDisconnect in interface IOCallback

onConnect

public void onConnect()
Description copied from interface: IOCallback
On connect. Called when the socket becomes ready so it is now able to receive data

Specified by:
onConnect in interface IOCallback

onMessage

public void onMessage(java.lang.String data,
                      IOAcknowledge ack)
Description copied from interface: IOCallback
On message. Called when the server sends String data.

Specified by:
onMessage in interface IOCallback
Parameters:
data - the data.
ack - an IOAcknowledge instance, may be null if there's none

onMessage

public void onMessage(org.json.JSONObject json,
                      IOAcknowledge ack)
Description copied from interface: IOCallback
On message. Called when the server sends JSON data.

Specified by:
onMessage in interface IOCallback
Parameters:
json - JSON object sent by server.
ack - an IOAcknowledge instance, may be null if there's none

on

public void on(java.lang.String event,
               IOAcknowledge ack,
               java.lang.Object... args)
Description copied from interface: IOCallback
On [Event]. Called when server emits an event.

Specified by:
on in interface IOCallback
Parameters:
event - Name of the event
ack - an IOAcknowledge instance, may be null if there's none
args - Arguments of the event

onError

public void onError(SocketIOException socketIOException)
Description copied from interface: IOCallback
On error. Called when socket is in an undefined state. No reconnect attempts will be made.

Specified by:
onError in interface IOCallback
Parameters:
socketIOException - the last exception describing the error

getPort

public int getPort()
Gets the port.

Returns:
the port

getProxyPort

public int getProxyPort()