xmlBlaster 2.2.0 API

org.xmlBlaster.test.persistence
Class TestPersistenceXMLDB

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

public class TestPersistenceXMLDB
extends junit.framework.TestCase
implements I_Callback

This client tests the persistence driver, the $lt;persistent> flag.

Invoke examples:

    java junit.textui.TestRunner org.xmlBlaster.test.persistence.TestPersistenceXMLDB

    java junit.swingui.TestRunner org.xmlBlaster.test.persistence.TestPersistenceXMLDB
 


Field Summary
private  Global glob
           
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
private  int numReceived
           
private  java.lang.String publishOid
           
private  I_XmlBlasterAccess senderConnection
           
private  java.lang.String senderContent
           
private  java.lang.String senderName
           
private  java.lang.String senderPasswd
           
private  int serverPort
           
private  EmbeddedXmlBlaster serverThread1
           
private  EmbeddedXmlBlaster serverThread2
           
private  EmbeddedXmlBlaster st
           
private  java.lang.String subscribeString
           
 
Constructor Summary
TestPersistenceXMLDB(Global glob, java.lang.String testName)
          Constructs the TestPersistenceXMLDB object.
 
Method Summary
protected  I_XmlBlasterAccess connectClient(java.lang.String name, java.lang.String passwd)
          Connects a client at the server.
protected  void disconnectClient(I_XmlBlasterAccess sc)
          Disconnects a client from the server.
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.persistence.TestPersistenceXMLDB
 void sendPersistent(I_XmlBlasterAccess sc)
          Publish a persistent message.
protected  void setUp()
          Sets up the fixture.
protected  EmbeddedXmlBlaster startServer()
          Starts a xmlBlaster serverthread.
protected  void stopServer(EmbeddedXmlBlaster st)
          Stops a xmlBlaster serverthread.
protected  void subscribe(I_XmlBlasterAccess sc)
          Subscribes to publishOid at the given connection.
static junit.framework.Test suite()
          Method is used by TestRunner to load these tests
protected  void tearDown()
           
 void testPersistent()
          TEST: Subscribes to the message with the given key per XPATH.
 java.lang.String update(java.lang.String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos)
          This is the callback method invoked from xmlBlaster delivering us a new asynchronous 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 final java.lang.String ME
See Also:
Constant Field Values

glob

private Global glob

log

private static java.util.logging.Logger log

senderName

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

senderPasswd

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

publishOid

private java.lang.String publishOid

subscribeString

private java.lang.String subscribeString

senderConnection

private I_XmlBlasterAccess senderConnection

senderContent

private java.lang.String senderContent

numReceived

private int numReceived

st

private EmbeddedXmlBlaster st

serverThread1

private EmbeddedXmlBlaster serverThread1

serverThread2

private EmbeddedXmlBlaster serverThread2

serverPort

private int serverPort
Constructor Detail

TestPersistenceXMLDB

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

Parameters:
glob - Keeps global args and parameters.
testName - The name used in the test suite.
Method Detail

startServer

protected EmbeddedXmlBlaster startServer()
Starts a xmlBlaster serverthread.

Returns:
the server thread.

stopServer

protected void stopServer(EmbeddedXmlBlaster st)
Stops a xmlBlaster serverthread.

Parameters:
st - keeps the server thread

connectClient

protected I_XmlBlasterAccess connectClient(java.lang.String name,
                                           java.lang.String passwd)
Connects a client at the server.

Parameters:
name - The loginname.
passwd - The loginpassword.
Returns:
The sender connection.

disconnectClient

protected void disconnectClient(I_XmlBlasterAccess sc)
Disconnects a client from the server.

Parameters:
sc - A connection of a client to xmlBlaster.

setUp

protected void setUp()
Sets up the fixture. Sends a persistent message to be stored in persistence driver.

Starts the server, creates a connection and does a login.
Sends a persistent message and disconnects from server.
Shuts the server down.

Overrides:
setUp in class junit.framework.TestCase

tearDown

protected void tearDown()
Overrides:
tearDown in class junit.framework.TestCase

sendPersistent

public void sendPersistent(I_XmlBlasterAccess sc)
Publish a persistent message.

Parameters:
sc - A connection of a client to xmlBlaster.

subscribe

protected void subscribe(I_XmlBlasterAccess sc)
Subscribes to publishOid at the given connection.

Parameters:
sc - A connection of a client to xmlBlaster.

testPersistent

public void testPersistent()
TEST: Subscribes to the message with the given key per XPATH.

Starts the server, creates a connection and does a login.
Subscribes to a persistent message waits a while and disconnects from server.
Shuts the server down.


update

public java.lang.String update(java.lang.String cbSessionId,
                               UpdateKey updateKey,
                               byte[] content,
                               UpdateQos updateQos)
This is the callback method invoked from xmlBlaster delivering us a new asynchronous message.

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.
See Also:
I_Callback.update(String, UpdateKey, byte[], UpdateQos)

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.persistence.TestPersistenceXMLDB

Invoke: java org.xmlBlaster.test.persistence.TestPersistenceXMLDB


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.