public void checkSerialization() throws com.sun.star.uno.Exception, InterruptedException
{
System.out.println( "testing: request serialization" );
m_currentDocument = OfficeDocument.blankDocument( getORB(), DocumentType.CALC );
final XUndoManager undoManager = getUndoManager();
final int threadCount = 10;
final int actionsPerThread = 10;
final int actionCount = threadCount * actionsPerThread;
// add some actions to the UndoManager, each knowing its position on the stack
final Object lock = new Object();
final Integer actionsUndone[] = new Integer[] { 0 };
for ( int i=actionCount; i>0; )
undoManager.addUndoAction( new CountingUndoAction( --i, lock, actionsUndone ) );
// some concurrent threads which undo the actions
Thread[] threads = new Thread[threadCount];
for ( int i=0; i<threadCount; ++i )
{
threads[i] = new Thread()
{
@Override
public void run()
{
for ( int j=0; j<actionsPerThread; ++j )
{
try { undoManager.undo(); }
catch ( final Exception e )
{
fail( "Those dummy actions are not expected to fail." );
return;
}