xmlBlaster 2.2.0 API

org.xmlBlaster.test.client
Class TestStreamMessages

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

public class TestStreamMessages
extends junit.framework.TestCase
implements I_StreamingCallback

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.TestStreamMessages
   java junit.swingui.TestRunner -noloading org.xmlBlaster.test.client.TestStreamMessages
 

See Also:
I_XmlBlasterAccess

Field Summary
private  Global connGlobal
           
private  long delay
           
private  Global global
           
private  boolean ignoreException
           
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
private  byte[] msgContent
           
private  java.lang.String oid
           
private  MsgInterceptor updateInterceptor
           
 
Constructor Summary
TestStreamMessages()
           
TestStreamMessages(Global global)
           
 
Method Summary
private  boolean compareContent(byte[] buf1, byte[] buf2)
           
private  byte[] createRandomContent(int size)
           
private  void doPublish(byte[] content, int maxChunkSize, boolean doInterrupt, java.lang.String name)
           
private  void doPublishJMS(byte[] content, int maxChunkSize, boolean doInterrupt, java.lang.String name)
           
private  java.lang.String getMemInfo()
           
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.TestStreamMessages
protected  void setUp()
          Sets up the fixture.
protected  void tearDown()
          Tears down the fixture.
 void testException()
           
 void testInterruptedRead()
           
 void testManyBigChunks()
          This test is to check that we don't have a problem in the buffer of the Pipes due to large chunks of messages.
 void testManyChunks()
           
 void testManyChunksTwoMessages()
           
 void testNormalMessage()
           
 void testSingleChunk()
           
 java.lang.String update(java.lang.String cbSessionId, UpdateKey updateKey, java.io.InputStream is, 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

global

private Global global

log

private static java.util.logging.Logger log

connGlobal

private Global connGlobal

oid

private java.lang.String oid

updateInterceptor

private MsgInterceptor updateInterceptor

msgContent

private byte[] msgContent

delay

private long delay

ignoreException

private boolean ignoreException
Constructor Detail

TestStreamMessages

public TestStreamMessages()

TestStreamMessages

public TestStreamMessages(Global global)
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

getMemInfo

private final java.lang.String getMemInfo()

update

public java.lang.String update(java.lang.String cbSessionId,
                               UpdateKey updateKey,
                               java.io.InputStream is,
                               UpdateQos updateQos)
                        throws XmlBlasterException,
                               java.io.IOException
Description copied from interface: I_StreamingCallback
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.

Specified by:
update in interface I_StreamingCallback
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
Throws:
XmlBlasterException
java.io.IOException
See Also:
I_XmlBlasterAccess

doPublish

private void doPublish(byte[] content,
                       int maxChunkSize,
                       boolean doInterrupt,
                       java.lang.String name)
                throws XmlBlasterException
Throws:
XmlBlasterException

doPublishJMS

private void doPublishJMS(byte[] content,
                          int maxChunkSize,
                          boolean doInterrupt,
                          java.lang.String name)
                   throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createRandomContent

private byte[] createRandomContent(int size)

testManyChunks

public void testManyChunks()

testManyBigChunks

public void testManyBigChunks()
This test is to check that we don't have a problem in the buffer of the Pipes due to large chunks of messages.


testManyChunksTwoMessages

public void testManyChunksTwoMessages()

testSingleChunk

public void testSingleChunk()

testException

public void testException()

testInterruptedRead

public void testInterruptedRead()

testNormalMessage

public void testNormalMessage()

compareContent

private boolean compareContent(byte[] buf1,
                               byte[] buf2)

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.TestStreamMessages

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


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.