Examples of TestStatusCallbackListener


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

   * @throws Exception
   */
  public void testNumToProcess() throws Exception {
    int exceptionSequence = 25;
    int documentCount = 50; // number of documents processed
    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    String functionName = "process";
    String exceptionName = "AnnotatorProcessException";
    ManageOutputDevice.setAllSystemOutputToNirvana();

    // setup CPM
    Object[] objs = setupConfigurableCpm(documentCount, exceptionName, exceptionSequence,
            functionName);

    CpeDescription cpeDesc = (CpeDescription) objs[0];
    cpeDesc.setProcessingUnitThreadCount(1);
    cpeDesc.setNumToProcess(20);
    CpeIntegratedCasProcessor integratedProcessor = (CpeIntegratedCasProcessor) objs[1];
    integratedProcessor.setActionOnMaxError("terminate");
    CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc, null,
            null);

    // 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);
    }

    ManageOutputDevice.setAllSystemOutputToDefault();
    // check the results, if everything worked as expected
    assertEquals(
            "The cpm propably didn't finish correctly! The aborted method of the listener was called.",
            false, listener.isAborted());
    assertEquals("The cpm didn't finish by calling the Listener.", true, listener.isFinished());
    assertEquals("There are not as much exceptions as expected! ", 0, FunctionErrorStore.getCount());
    assertEquals("There is a difference between the expected and the processed document number. ",
            20, FunctionErrorStore.getAnnotatorProcessCount());
  }
View Full Code Here

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

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

    // 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(
            "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, "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);

    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(
            "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

   * @throws Exception
   */
  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 statusinformation are
    // made avaiable
    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

  public void testInitializeWithNullPointerException() throws Exception {
    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
      CollectionProcessingEngine cpe = setupCpm(documentCount,
            "CollectionException", 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
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.