xmlBlaster 2.2.0 API

org.xmlBlaster.test.topic
Class TestReferenceCount

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

public class TestReferenceCount
extends junit.framework.TestCase
implements I_ConnectionStateListener

Tests the correct reference counting for persistent messages after recovery.

   1. Start xmlBlaster server
   2. Publish two messages
   3. Subscribe to message and block in callback
   4. Kill server and clients
   5. Restart server
   6. Start same subscriber - it will receive the message from 3.
   7. Start another subscriber: we expect an update
   If the reference counter is not properly set on recovery
   test 7. will fail.
 
Invoke examples:
   java junit.textui.TestRunner org.xmlBlaster.test.topic.TestReferenceCount
   java junit.swingui.TestRunner -noloading org.xmlBlaster.test.topic.TestReferenceCount
 


Nested Class Summary
(package private)  class TestReferenceCount.Client
           
 
Field Summary
private  Global glob
           
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
private  java.lang.String oid
           
private  int serverPort
           
private  EmbeddedXmlBlaster serverThread
           
 
Constructor Summary
TestReferenceCount(Global glob, java.lang.String testName)
          Constructs the TestReferenceCount object.
TestReferenceCount(java.lang.String testName)
           
 
Method Summary
private  TestReferenceCount.Client doConnect(java.lang.String loginName, I_Callback cb)
          Create a new connection
private  void doErase(I_XmlBlasterAccess con)
          Erase the message.
private  void doPublish(I_XmlBlasterAccess con)
          Construct a message and publish it persistent.
private  void doSubscribe(I_XmlBlasterAccess con)
          Subscribe to message.
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.topic.TestReferenceCount
 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.
static junit.framework.Test suite()
          Method is used by TestRunner to load these tests
protected  void tearDown()
          Tears down the fixture.
 void testReferenceCount()
          Test as described in class javadoc.
 
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

glob

private Global glob

log

private static java.util.logging.Logger log

serverPort

private int serverPort

serverThread

private EmbeddedXmlBlaster serverThread

oid

private java.lang.String oid
Constructor Detail

TestReferenceCount

public TestReferenceCount(java.lang.String testName)

TestReferenceCount

public TestReferenceCount(Global glob,
                          java.lang.String testName)
Constructs the TestReferenceCount object.

Parameters:
testName - The name used in the test suite
Method Detail

setUp

protected void setUp()
Sets up the fixture.

Connect to xmlBlaster and login

Overrides:
setUp in class junit.framework.TestCase

tearDown

protected void tearDown()
Tears down the fixture.

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

Overrides:
tearDown in class junit.framework.TestCase

doConnect

private TestReferenceCount.Client doConnect(java.lang.String loginName,
                                            I_Callback cb)
Create a new connection

Parameters:
loginName - The login name
cb - The callback handle or null

doSubscribe

private void doSubscribe(I_XmlBlasterAccess con)
Subscribe to message.


doPublish

private void doPublish(I_XmlBlasterAccess con)
Construct a message and publish it persistent.


doErase

private void doErase(I_XmlBlasterAccess con)
Erase the message.


testReferenceCount

public void testReferenceCount()
Test as described in class javadoc.


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.

suite

public static junit.framework.Test suite()
Method is used by TestRunner to load these tests


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.topic.TestReferenceCount

Invoke: java org.xmlBlaster.test.topic.TestReferenceCount


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.