xmlBlaster 2.2.0 API

org.xmlBlaster.test.contrib.filewatcher
Class TestFileWatcherPlugin

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

public class TestFileWatcherPlugin
extends junit.framework.TestCase
implements I_Callback

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

See Also:
I_XmlBlasterAccess

Field Summary
private  Global connGlobal
           
private  java.lang.String dirName
           
private  java.lang.String dirNameDiscarded
           
private  java.lang.String dirNameSent
           
private  Global global
           
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
private  java.lang.String oid
           
private  MsgInterceptor updateInterceptor
           
 
Constructor Summary
TestFileWatcherPlugin()
           
TestFileWatcherPlugin(Global global)
           
 
Method Summary
private  void checkDirs()
           
private  void checkMoved(java.lang.String name, boolean absSubPath, java.lang.String subDirName)
           
private  void cleanUpDirs()
           
private  boolean compareContent(byte[] buf1, byte[] buf2)
           
private  void delete(java.lang.String filename)
           
private  void doPublish(I_Info prop, boolean deliverFirst, boolean deliverSecond, boolean absSubPath)
           
private  void getBaseDir()
           
private  java.lang.String getConnectQos(Global glob)
           
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.TestFilePollerPlugin
protected  void setUp()
          Sets up the fixture.
private  void singleDump(java.lang.String filename, int filesize, java.lang.String lockExt, long delay, boolean deliver, boolean absSubPath, java.lang.String movedDir)
           
protected  void tearDown()
          Tears down the fixture.
 void testDirectories()
          Tests the creation of the necessary directories
 void testPublishWithMoveAbsolute()
           
 void testPublishWithMoveRelative()
           
 void testPublishWithMoveRelativeLockMode()
           
 void testSimplePublish()
           
 void testSimplePublishWithFilter()
           
 void testSimplePublishWithFilterLockMode()
           
 void testSimplePublishWithFilterRegex()
           
 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.
private  byte[] writeFile(java.lang.String filename, int size, java.lang.String lockExt, long timeToWait)
           
 
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

dirName

private java.lang.String dirName

dirNameSent

private java.lang.String dirNameSent

dirNameDiscarded

private java.lang.String dirNameDiscarded

updateInterceptor

private MsgInterceptor updateInterceptor
Constructor Detail

TestFileWatcherPlugin

public TestFileWatcherPlugin()

TestFileWatcherPlugin

public TestFileWatcherPlugin(Global global)
Method Detail

getBaseDir

private void getBaseDir()

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

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

testDirectories

public void testDirectories()
Tests the creation of the necessary directories


singleDump

private void singleDump(java.lang.String filename,
                        int filesize,
                        java.lang.String lockExt,
                        long delay,
                        boolean deliver,
                        boolean absSubPath,
                        java.lang.String movedDir)

checkMoved

private void checkMoved(java.lang.String name,
                        boolean absSubPath,
                        java.lang.String subDirName)

doPublish

private void doPublish(I_Info prop,
                       boolean deliverFirst,
                       boolean deliverSecond,
                       boolean absSubPath)

testSimplePublish

public void testSimplePublish()

testSimplePublishWithFilter

public void testSimplePublishWithFilter()

testSimplePublishWithFilterRegex

public void testSimplePublishWithFilterRegex()

testPublishWithMoveAbsolute

public void testPublishWithMoveAbsolute()

testPublishWithMoveRelative

public void testPublishWithMoveRelative()

testPublishWithMoveRelativeLockMode

public void testPublishWithMoveRelativeLockMode()

testSimplePublishWithFilterLockMode

public void testSimplePublishWithFilterLockMode()

compareContent

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

writeFile

private byte[] writeFile(java.lang.String filename,
                         int size,
                         java.lang.String lockExt,
                         long timeToWait)

checkDirs

private void checkDirs()

getConnectQos

private java.lang.String getConnectQos(Global glob)

delete

private void delete(java.lang.String filename)

cleanUpDirs

private void cleanUpDirs()

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

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


xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.