xmlBlaster 2.2.0 API

org.xmlBlaster.test.client
Class TestPersistentSession

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.xmlBlaster.test.client.TestPersistentSession
All Implemented Interfaces:
junit.framework.Test, I_Callback, I_ConnectionStateListener

public class TestPersistentSession
extends junit.framework.TestCase
implements I_ConnectionStateListener, I_Callback

Tests the persistent sessions .
For a description of what this persistent sessions and subscriptions are please read the requirement engine.persistence.session.

This is an interesting example, since it creates a XmlBlaster server instance in the same JVM , but in a separate thread, talking over CORBA with it.

Invoke examples:

   java junit.textui.TestRunner -noloading org.xmlBlaster.test.client.TestPersistentSession
   java junit.swingui.TestRunner -noloading org.xmlBlaster.test.client.TestPersistentSession
 

See Also:
I_XmlBlasterAccess

Field Summary
private  java.lang.String contentMime
           
private  boolean exactSubscription
           
private  boolean failsafeCallback
           
private  Global glob
           
private  boolean initialUpdates
           
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
private  int numPublish
           
private  int numStart
           
private  int numStop
           
private  int numSubscribers
           
private  Global origGlobal
           
private  boolean persistent
          the session is persistent from the beginning
private static boolean PERSISTENT
           
private  long reconnectDelay
           
private  java.lang.String senderName
           
private  Global serverGlobal
           
private  int serverPort
           
private  EmbeddedXmlBlaster serverThread
           
private static boolean TRANSIENT
           
private  MsgInterceptor[] updateInterceptors
           
 
Constructor Summary
TestPersistentSession(Global glob, java.lang.String testName)
           
TestPersistentSession(java.lang.String testName)
           
 
Method Summary
private  Global createConnection(Global parentGlobal, java.lang.String sessionName, boolean isPersistent, boolean expectEx)
           
 void doPublish(int counter)
          TEST: Construct a message and publish it.
private  void doSubscribe(int num, boolean isExact, boolean isPersistent)
          TEST: Subscribe to messages with XPATH.
static void main(java.lang.String[] args)
          Deprecated. Use the TestRunner from the testsuite to run it:

   java -Djava.compiler= junit.textui.TestRunner org.xmlBlaster.test.client.TestPersistentSession
 void persistentSession(boolean doStop)
          TEST:
 void reachedAlive(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode if the connection was established.
 void reachedAliveSync(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          Invoked when the dispatcher goes to synch again after having delivered entries which where in the queue when the state changed to ALIVE.
 void reachedDead(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          This is the callback method invoked from XmlBlasterAccess informing the client that the connection was lost (i.e.
 void reachedPolling(ConnectionStateEnum oldState, I_XmlBlasterAccess connection)
          This is the callback method invoked from XmlBlasterAccess informing the client that the connection state has changed to POLLING.
protected  void setUp()
          Sets up the fixture.
private  void setup(boolean restrictedEntries)
           
protected  void tearDown()
          Tears down the fixture.
 void testOverflow()
          Tests the requirement: - If the storage for the sessions is overflown, it should throw an exception
 void testXPathInitialRunlevelChange()
           
 void testXPathInitialStop()
           
 void testXPathNoInitialStop()
           
 java.lang.String update(java.lang.String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos)
          This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode about a new message.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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

ME

private static java.lang.String ME

TRANSIENT

private static final boolean TRANSIENT
See Also:
Constant Field Values

PERSISTENT

private static final boolean PERSISTENT
See Also:
Constant Field Values

glob

private Global glob

origGlobal

private Global origGlobal

serverGlobal

private Global serverGlobal

log

private static java.util.logging.Logger log

serverPort

private int serverPort

serverThread

private EmbeddedXmlBlaster serverThread

updateInterceptors

private MsgInterceptor[] updateInterceptors

senderName

private java.lang.String senderName

numPublish

private int numPublish

numStop

private int numStop

numStart

private int numStart

contentMime

private final java.lang.String contentMime
See Also:
Constant Field Values

reconnectDelay

private final long reconnectDelay
See Also:
Constant Field Values

failsafeCallback

private boolean failsafeCallback

persistent

private boolean persistent
the session is persistent from the beginning


exactSubscription

private boolean exactSubscription

initialUpdates

private boolean initialUpdates

numSubscribers

private int numSubscribers
Constructor Detail

TestPersistentSession

public TestPersistentSession(java.lang.String testName)

TestPersistentSession

public TestPersistentSession(Global glob,
                             java.lang.String testName)
Method Detail

setUp

protected void setUp()
Sets up the fixture.

Connect to xmlBlaster and login

Overrides:
setUp in class junit.framework.TestCase

setup

private void setup(boolean restrictedEntries)

tearDown

protected void tearDown()
Tears down the fixture.

cleaning up .... erase() the previous message OID and logout

Overrides:
tearDown in class junit.framework.TestCase

doSubscribe

private void doSubscribe(int num,
                         boolean isExact,
                         boolean isPersistent)
TEST: Subscribe to messages with XPATH.


doPublish

public void doPublish(int counter)
               throws XmlBlasterException
TEST: Construct a message and publish it.

Throws:
XmlBlasterException

persistentSession

public void persistentSession(boolean doStop)
TEST:


reachedAlive

public void reachedAlive(ConnectionStateEnum oldState,
                         I_XmlBlasterAccess connection)
This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode if the connection was established.

This method is enforced through interface I_ConnectionStateListener

Specified by:
reachedAlive in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.

reachedAliveSync

public void reachedAliveSync(ConnectionStateEnum oldState,
                             I_XmlBlasterAccess connection)
Description copied from interface: I_ConnectionStateListener
Invoked when the dispatcher goes to synch again after having delivered entries which where in the queue when the state changed to ALIVE. Note that this could take some time or in the worst case it could never been invoked if the queue is never completely processed.

Specified by:
reachedAliveSync in interface I_ConnectionStateListener
Parameters:
oldState - is always ALIVE.

reachedPolling

public void reachedPolling(ConnectionStateEnum oldState,
                           I_XmlBlasterAccess connection)
Description copied from interface: I_ConnectionStateListener
This is the callback method invoked from XmlBlasterAccess informing the client that the connection state has changed to POLLING.

Specified by:
reachedPolling in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.

reachedDead

public void reachedDead(ConnectionStateEnum oldState,
                        I_XmlBlasterAccess connection)
Description copied from interface: I_ConnectionStateListener
This is the callback method invoked from XmlBlasterAccess informing the client that the connection was lost (i.e. when the state of the connection has gone to DEAD).

Specified by:
reachedDead in interface I_ConnectionStateListener
Parameters:
oldState - The previous state of the connection.

update

public java.lang.String update(java.lang.String cbSessionId,
                               UpdateKey updateKey,
                               byte[] content,
                               UpdateQos updateQos)
                        throws XmlBlasterException
Description copied from interface: I_Callback
This is the callback method invoked from I_XmlBlasterAccess informing the client in an asynchronous mode about a new message.

So you should implement in your client code the I_Callback interface - suppling the update() method where you can do with the message whatever you want.

The raw protocol driver specific update() method (e.g. CORBA-BlasterCallback.update()) is unpacked and for each arrived message this update is called.

Specified by:
update in interface I_Callback
Parameters:
cbSessionId - The session ID specified by the client which registered the callback. You can specify a cbSessionId during connection (with ConnectQos) and this is bounced back here so you can authenticate the message.
updateKey - The arrived key containing the topic name
content - The arrived message content. This is your payload.
Throws:
XmlBlasterException
See Also:
I_XmlBlasterAccess

testXPathInitialStop

public void testXPathInitialStop()

testXPathNoInitialStop

public void testXPathNoInitialStop()

testXPathInitialRunlevelChange

public void testXPathInitialRunlevelChange()

createConnection

private Global createConnection(Global parentGlobal,
                                java.lang.String sessionName,
                                boolean isPersistent,
                                boolean expectEx)

testOverflow

public void testOverflow()
Tests the requirement: - If the storage for the sessions is overflown, it should throw an exception


main

public static void main(java.lang.String[] args)
Deprecated. Use the TestRunner from the testsuite to run it:

   java -Djava.compiler= junit.textui.TestRunner org.xmlBlaster.test.client.TestPersistentSession

Invoke: java org.xmlBlaster.test.client.TestPersistentSession


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.