Examples of TestStatusCallbackListener


Examples of org.apache.uima.collection.impl.cpm.utils.TestStatusCallbackListener

      // setup CPM
      CollectionProcessingEngine cpe = setupCpm(documentCount, "IOException",
            exceptionSequence, "getNext");

      // Create and register a Status Callback Listener
      TestStatusCallbackListener listener = new CollectionReaderStatusCallbackListener(
            cpe);
      cpe.addStatusCallbackListener(listener);

      cpe.process();

      // wait until cpm has finished
      Date d = new Date();
      long time = d.getTime() + 1000 * TIMEOUT;
      while (!listener.isFinished() && !listener.isAborted()) {
         Thread.sleep(5);
         d = new Date();
         // timeout mechanism
         if (time < d.getTime()) {
            System.out.println("CPM manually aborted!");
            cpe.stop();
            // wait until CPM has aborted
            while (!listener.isAborted()) {
               Thread.sleep(5);
            }
         }
      }

      ManageOutputDevice.setAllSystemOutputToDefault();
      // check the results, if everything worked as expected
      assertEquals(
            "The cpm is still working or the collectionProcessComplete-method of the listener was not called.",
            true, listener.isFinished());
      assertEquals(
            "The cpm propably didn't finish correctly! The aborted method of the listener was called.",
            false, listener.isAborted());
      assertEquals("There are not as much exceptions as expected! ",
            documentCount / exceptionSequence, FunctionErrorStore.getCount());
   }
View Full Code Here

Examples of org.apache.uima.collection.impl.cpm.utils.TestStatusCallbackListener

      // setup CPM
      CollectionProcessingEngine cpe = setupCpm(documentCount,
            "NullPointerException", exceptionSequence, "getNext");

      // Create and register a Status Callback Listener
      TestStatusCallbackListener listener = new CollectionReaderStatusCallbackListener(
            cpe);
      cpe.addStatusCallbackListener(listener);

      cpeProcessNoMsg(cpe, listener);

      ManageOutputDevice.setAllSystemOutputToDefault();
      // check the results, if everything worked as expected
      assertEquals(
            "The cpm is still working or the collectionProcessComplete-method of the listener was not called.",
            true, listener.isFinished());
      assertEquals(
            "The cpm propably didn't finish correctly! The aborted method of the listener was called.",
            false, listener.isAborted());
      assertEquals("There are not as much exceptions as expected! ",
            documentCount / exceptionSequence, FunctionErrorStore.getCount());
   }
View Full Code Here

Examples of org.apache.uima.collection.impl.cpm.utils.TestStatusCallbackListener

      // setup CPM
      CollectionProcessingEngine cpe = setupCpm(documentCount,
            "NullPointerException", exceptionSequence, "hasNext");

      // Create and register a Status Callback Listener
      TestStatusCallbackListener listener = new CollectionReaderStatusCallbackListener(
            cpe);
      cpe.addStatusCallbackListener(listener);

      cpe.process();

      // wait until cpm has finished
      Date d = new Date();
      long time = d.getTime() + 1000 * TIMEOUT;
      while (!listener.isFinished() && !listener.isAborted()) {
         Thread.sleep(5);
         d = new Date();
         // timeout mechanism
         if (time < d.getTime()) {
            manuallyAborted = true;
            cpe.stop();
            // wait until CPM has aborted
            while (!listener.isAborted()) {
               Thread.sleep(5);
            }
         }
      }

      ManageOutputDevice.setAllSystemOutputToDefault();
      // check the results, if everything worked as expected
      assertEquals("The cpm didn't finish correctly! Abort was called.", false,
            listener.isAborted());
      assertEquals("The cpm didn't finish correctly! Finish was not called.",
            true, listener.isFinished());
      assertEquals("The cpm was manually aborted.", false, manuallyAborted);
   }
View Full Code Here

Examples of org.apache.uima.collection.impl.cpm.utils.TestStatusCallbackListener

    */
   public void testInitializeWithResourceInitializationException()
         throws Exception {
      int documentCount = 20; // number of documents processed
      int exceptionSequence = 1; // the sequence in which errors are produced
      TestStatusCallbackListener listener = null; // listener with which the
      // status information are
      // made available
      boolean exceptionThrown = false; // flag, if the expected exception was
      // thrown
      ManageOutputDevice.setAllSystemOutputToNirvana();

      try {
         // setup CPM
         CollectionProcessingEngine cpe = setupCpm(documentCount,
               "ResourceInitializationException", exceptionSequence,
               "initialize");

         // Create and register a Status Callback Listener
         listener = new CollectionReaderStatusCallbackListener(cpe);
         cpe.addStatusCallbackListener(listener);

         cpe.process();

         // wait until cpm has finished

         while (!listener.isFinished() && !listener.isAborted()) {
            Thread.sleep(5);
         }
      } catch (ResourceInitializationException e) {
         exceptionThrown = true;
      } finally {
         ManageOutputDevice.setAllSystemOutputToDefault();
         // check the results, if everything worked as expected
         assertEquals("The cpm didn't finish correctly! Abort was called.",
               false, listener.isAborted());
         assertEquals(
               "The cpm called the listener, that the cpm has finished - which normally could not be.",
               false, listener.isFinished());
         assertEquals("There are not as much exceptions as expected! ", 1,
               FunctionErrorStore.getCount());
         assertEquals(
               "The expected ResourceInitializationException was not fiven back to the programm. ",
               true, exceptionThrown);
View Full Code Here

Examples of org.apache.uima.collection.impl.cpm.utils.TestStatusCallbackListener

      int documentCount = 20; // number of documents processed
      int exceptionSequence = 1; // the sequence in which errors are produced
      boolean exceptionThrown = false; // flag, if the expected exception was
      // thrown
      ManageOutputDevice.setAllSystemOutputToNirvana();
      TestStatusCallbackListener listener = null;

      try {
         // setup CPM
         CollectionProcessingEngine cpe = setupCpm(documentCount,
               "NullPointerException", exceptionSequence, "initialize");

         // Create and register a Status Callback Listener
         listener = new CollectionReaderStatusCallbackListener(cpe);
         cpe.addStatusCallbackListener(listener);

         cpe.process();

         // wait until cpm has finished
         while (!listener.isFinished() && !listener.isAborted()) {
            Thread.sleep(5);
         }
      } catch (ResourceInitializationException e) {
         // e.printStackTrace();
         exceptionThrown = true;
      } finally {
         ManageOutputDevice.setAllSystemOutputToDefault();
         // check the results, if everything worked as expected
         assertEquals("Abort was called.", false, listener.isAborted());
         assertEquals(
               "The cpm called the listener, that the cpm has finished - which normally could not be.",
               false, listener.isFinished());
         assertEquals("There are not as much exceptions as expected! ", 1,
               FunctionErrorStore.getCount());
         assertEquals(
               "The expected ResourceInitializationException was not fiven back to the programm. ",
               true, exceptionThrown);
View Full Code Here

Examples of org.apache.uima.collection.impl.cpm.utils.TestStatusCallbackListener

      // setup CPM
      CollectionProcessingEngine cpe = setupCpm(documentCount, "IOException",
            exceptionSequence, "getProgress");

      // Create and register a Status Callback Listener
      TestStatusCallbackListener listener = new CollectionReaderStatusCallbackListener(
            cpe);
      cpe.addStatusCallbackListener(listener);

      cpe.process();

      // wait until cpm has finished
      while (!listener.isFinished() && !listener.isAborted()) {
         Thread.sleep(5);
      }

      ManageOutputDevice.setAllSystemOutputToDefault();
      // check the results, if everything worked as expected
      assertEquals("Abort was called.", false, listener.isAborted());
      assertEquals(
            "The cpm is still working or the collectionProcessComplete-method of the listener was not called.",
            true, listener.isFinished());
      assertEquals("There are not as much exceptions as expected! ",
            (documentCount / exceptionSequence), FunctionErrorStore.getCount());
      // that's it.
   }
View Full Code Here

Examples of org.apache.uima.collection.impl.cpm.utils.TestStatusCallbackListener

      // setup CPM
      CollectionProcessingEngine cpe = setupCpm(documentCount,
            "NullPointerException", exceptionSequence, "getProgress");

      // Create and register a Status Callback Listener
      TestStatusCallbackListener listener = new CollectionReaderStatusCallbackListener(
            cpe);
      cpe.addStatusCallbackListener(listener);

      cpe.process();

      // wait until cpm has finished
      while (!listener.isFinished() && !listener.isAborted()) {
         Thread.sleep(5);
      }

      ManageOutputDevice.setAllSystemOutputToDefault();
      // check the results, if everything worked as expected
      assertEquals("Abort was called.", false, listener.isAborted());
      assertEquals(
            "The cpm is still working or the collectionProcessComplete-method of the listener was not called.",
            true, listener.isFinished());
      assertEquals("There are not as much exceptions as expected! ",
            (documentCount / exceptionSequence), FunctionErrorStore.getCount());

   }
View Full Code Here

Examples of org.apache.uima.collection.impl.cpm.utils.TestStatusCallbackListener

    // setup CPM to process 1 documents
    CollectionProcessingEngine cpe = setupCpm(documentCount, threadCount, false, true);

    // create and register a status callback listener
    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    cpe.addStatusCallbackListener(listener);

    // run CPM
    cpe.process();

    // wait for initialized call from the CPM
    while (!listener.isInitialized()) {
      Thread.sleep(10);
    }
    System.out.println("SingleThreadCPMMode Initialize was called: " + listener.isInitialized());

    // Let the CPM process some docs, before calling stop
    Thread.sleep(300);

    // stop CPM
    cpe.stop();

    // wait until CPM has aborted
    while (!listener.isAborted()) {
      Thread.sleep(5);
    }
  }
View Full Code Here

Examples of org.apache.uima.collection.impl.cpm.utils.TestStatusCallbackListener

    // setup CPM to process 1 documents
    CollectionProcessingEngine cpe = setupCpm(documentCount, threadCount, false, false);

    // create and register a status callback listener
    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    cpe.addStatusCallbackListener(listener);

    // run CPM
    cpe.process();

    while (!listener.isInitialized()) {
      Thread.sleep(10);
    }
    System.out.println("MultiThreadCPMMode Initialize was called: " + listener.isInitialized());

    // Let the CPM process some docs, before calling stop
    Thread.sleep(300);

    // stop CPM
    cpe.stop();

    // wait until CPM has aborted
    while (!listener.isAborted()) {
      Thread.sleep(5);
    }
  }
View Full Code Here

Examples of org.apache.uima.collection.impl.cpm.utils.TestStatusCallbackListener

    // setup CPM to process documents
    CollectionProcessingEngine cpe = setupCpm(documentCount, threadCount, false, false);

    // create and register a status callback listener
    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    cpe.addStatusCallbackListener(listener);

    // run CPM
    cpe.process();

    while (!listener.isInitialized()) {
      Thread.sleep(10);
    }
    System.out.println("testInitMultiThreadCPM()-Initialize was called: "
            + listener.isInitialized());
    // Let the CPM process some docs, before calling stop
    Thread.sleep(300);

    // stop CPM
    cpe.stop();

    // wait until CPM has aborted
    while (!listener.isAborted()) {
      Thread.sleep(5);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.