xmlBlaster 2.2.0 API

org.xmlBlaster.test.stress
Class LoadTestSub

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

public class LoadTestSub
extends junit.framework.TestCase
implements I_Callback

This client does a subscribe() with many publish() calls.
The same message is published 1000 times, to measure messages/second performance.

This client may be invoked multiple time on the same xmlBlaster server, as it cleans up everything after his tests are done.

Invoke examples:

    java junit.textui.TestRunner org.xmlBlaster.test.stress.LoadTestSub
    java junit.swingui.TestRunner org.xmlBlaster.test.stress.LoadTestSub
 


Field Summary
private  int burstModePublish
           
private  java.lang.String contentMime
           
private  java.lang.String contentMimeExtended
           
private  Global glob
           
private  int lastContentNumber
           
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
private  boolean messageArrived
           
private  int numPublish
           
private  int numReceived
           
private  java.lang.String passwd
           
private  boolean persistent
           
private  java.lang.String publishOid
           
private  boolean publishOneway
           
private  java.lang.String receiverName
           
private  I_XmlBlasterAccess senderConnection
           
private  java.lang.String senderName
           
private  java.lang.String someContent
           
private  StopWatch stopWatch
           
private  java.lang.String subscribeOid
           
 
Constructor Summary
LoadTestSub()
           
LoadTestSub(Global glob, java.lang.String testName, java.lang.String loginName, java.lang.String passwd, int numPublish, int burstModePublish, boolean publishOneway, boolean persistent)
          Constructs the LoadTestSub object.
 
Method Summary
 void doPublish()
          TEST: Construct a message and publish it.
 void doSubscribeXPath()
          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.stress.LoadTestSub
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 testManyPublish()
          TEST: Construct a message and publish it,
the previous XPath subscription should match and send an update.
 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.
(package private) static void usage()
           
private  void waitOnUpdate(long timeout, int numWait)
          Little helper, waits until the wanted number of messages are arrived or returns when the given timeout occurs.
 
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

messageArrived

private boolean messageArrived

stopWatch

private StopWatch stopWatch

glob

private Global glob

log

private static java.util.logging.Logger log

subscribeOid

private java.lang.String subscribeOid

publishOid

private java.lang.String publishOid

senderConnection

private I_XmlBlasterAccess senderConnection

senderName

private java.lang.String senderName

receiverName

private java.lang.String receiverName

passwd

private java.lang.String passwd

numPublish

private final int numPublish

numReceived

private int numReceived

burstModePublish

private int burstModePublish

publishOneway

private boolean publishOneway

persistent

private boolean persistent

contentMime

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

contentMimeExtended

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

lastContentNumber

private int lastContentNumber

someContent

private final java.lang.String someContent
See Also:
Constant Field Values
Constructor Detail

LoadTestSub

public LoadTestSub()

LoadTestSub

public LoadTestSub(Global glob,
                   java.lang.String testName,
                   java.lang.String loginName,
                   java.lang.String passwd,
                   int numPublish,
                   int burstModePublish,
                   boolean publishOneway,
                   boolean persistent)
Constructs the LoadTestSub object.

Parameters:
testName - The name used in the test suite
loginName - The name to login to the xmlBlaster
numPublish - The number of messages to send
burstModePublish - send given number of publish messages in one bulk
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

doSubscribeXPath

public void doSubscribeXPath()
TEST: Subscribe to messages with XPATH.

The returned subscribeOid is checked


doPublish

public void doPublish()
TEST: Construct a message and publish it.

The returned publishOid is checked


testManyPublish

public void testManyPublish()
TEST: Construct a message and publish it,
the previous XPath subscription should match and send an update.


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)

waitOnUpdate

private void waitOnUpdate(long timeout,
                          int numWait)
Little helper, waits until the wanted number of messages are arrived or returns when the given timeout occurs.

Parameters:
timeout - in milliseconds
numWait - how many messages to wait

suite

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


usage

static void usage()

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.stress.LoadTestSub

Invoke: java org.xmlBlaster.test.stress.LoadTestSub
You can use the command line option -numPublish 5000 to change the number of messages sent.


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.