Examples of TestStatusCallbackListener


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

    // setup CPM
    CollectionProcessingEngine cpe = setupCpm(documentCount, "AnnotatorProcessException",
            exceptionSequence, "process");

    // 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! ", countExceptions(documentCount,
            exceptionSequence), FunctionErrorStore.getCount());

  }
View Full Code Here

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

    // setup CPM
    CollectionProcessingEngine cpe = setupCpm(documentCount, "OutOfMemoryException",
            exceptionSequence, "process");

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

    // 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! ", countExceptions(documentCount,
            exceptionSequence), FunctionErrorStore.getCount());
    // that's it.
  }
View Full Code Here

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

    int documentCount = 20; // number of document to process
    int exceptionSequence = 1; // the sequence in which errors are produced
    boolean exceptionThrown = false;
    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);
      cpeProcessNoMsg(cpe, listener);
    } catch (NullPointerException e) {
      // e.printStackTrace();
      exceptionThrown = true;

    }

    ManageOutputDevice.setAllSystemOutputToDefault();
    // check the results, if everything worked as expected
    assertEquals("The expected NullPointerException wasn't thrown!", true, exceptionThrown);
    assertEquals(
            "The cpm called the listener, that the cpm has finished - which normally could not be.",
            false, listener.isFinished());
    assertEquals("The aborted-method of the listener was called. (new behaviour?)", false, listener
            .isAborted());
    assertEquals("There are not as much exceptions as expected! ", 1, FunctionErrorStore.getCount());
  }
View Full Code Here

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

  public void testInitializeWithOutOfMemoryException() throws Exception {
    int documentCount = 20; // number of document to process
    int exceptionSequence = 1; // the sequence in which errors are produced
    ManageOutputDevice.setAllSystemOutputToNirvana();

    TestStatusCallbackListener listener = null;

    // setup CPM
    CollectionProcessingEngine cpe = setupCpm(documentCount, "OutOfMemoryException",
            exceptionSequence, "initialize");

    // Create and register a Status Callback Listener
    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 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! ", 1, FunctionErrorStore.getCount());
    // that's it.
  }
View Full Code Here

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

    int documentCount = 20; // number of document to process
    int exceptionSequence = 1; // the sequence in which errors are produced
    boolean exceptionThrown = false;
    ManageOutputDevice.setAllSystemOutputToNirvana();

    TestStatusCallbackListener listener = null;
    try {
      // setup CPM
      CollectionProcessingEngine cpe = setupCpm(documentCount, "AnnotatorInitializationException",
              exceptionSequence, "initialize");

      // Create and register a Status Callback Listener
      listener = new CollectionReaderStatusCallbackListener(cpe);
      cpe.addStatusCallbackListener(listener);
      cpeProcessNoMsg(cpe, listener);
    } catch (NullPointerException e) {
      // e.printStackTrace();
      exceptionThrown = true;

    }

    ManageOutputDevice.setAllSystemOutputToDefault();
    // check the results, if everything worked as expected
    assertEquals("The expected NullPointerException wasn't thrown!", true, exceptionThrown);
    assertEquals(
            "The cpm called the listener, that the cpm has finished - which normally could not be.",
            false, listener.isFinished());
    assertEquals("The aborted-method of the listener was called. (new behaviour?)", false, listener
            .isAborted());
    assertEquals("There are not as much exceptions as expected! ", 1, FunctionErrorStore.getCount());
  }
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;
    ManageOutputDevice.setAllSystemOutputToNirvana();

    TestStatusCallbackListener listener = null;
    try {
      // setup CPM
      CollectionProcessingEngine cpe = setupCpm(documentCount, "AnnotatorConfigurationException",
              exceptionSequence, "initialize");

      // Create and register a Status Callback Listener
      listener = new CollectionReaderStatusCallbackListener(cpe);
      cpe.addStatusCallbackListener(listener);
      cpeProcessNoMsg(cpe, listener);
    } catch (NullPointerException e) {
      // e.printStackTrace();
      exceptionThrown = true;

    }

    ManageOutputDevice.setAllSystemOutputToDefault();
    // check the results, if everything worked as expected
    assertEquals("The expected NullPointerException wasn't thrown!", true, exceptionThrown);
    assertEquals(
            "The cpm called the listener, that the cpm has finished - which normally could not be.",
            false, listener.isFinished());
    assertEquals("The aborted-method of the listener was called. (new behaviour?)", false, listener
            .isAborted());
    assertEquals("There are not as much exceptions as expected! ", 1, FunctionErrorStore.getCount());
  }
View Full Code Here

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

   * @throws Exception
   */
  public void testAeProcessingUnitThreadCount() throws Exception {
    int documentCount = 20; // number of documents processed
    int count = 5; // thread number
    TestStatusCallbackListener listener = null;
    // setup CPM
    Object[] objs = setupConfigurableCpm(documentCount);

    CpeDescription cpeDesc = (CpeDescription) objs[0];
    cpeDesc.setProcessingUnitThreadCount(count);

    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);
    }
    // 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 by calling the Listener.", true, listener.isFinished());
    assertEquals("There are not as much ae's running as expected ", count, FunctionErrorStore
            .getAnnotatorCount());
    // that's it.
  }
View Full Code Here

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

   *
   * @throws Exception
   */
  public void testAeErrorRateThresholdTerminateDefault() throws Exception {
    int documentCount = 1000; // number of documents to process
    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    int exceptionSequence = 5;
    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);
    CpeIntegratedCasProcessor integratedProcessor = (CpeIntegratedCasProcessor) objs[1];
    integratedProcessor.setActionOnMaxError("terminate");
    CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc, null,
            null);

    // register a Status Callback Listener
    cpe.addStatusCallbackListener(listener);
    cpeProcessNoMsg(cpe, listener);

    ManageOutputDevice.setAllSystemOutputToDefault();
    // check the results, if everything worked as expected
    assertEquals(
            "The cpm called the listener, that the cpm has finished - which normally could not be.",
            false, listener.isFinished());
    assertEquals("The aborted-method of the listener wasn't called.", true, listener.isAborted());
    assertEquals("There are not as much exceptions as expected! ", (100 + 1), FunctionErrorStore
            .getCount());
    // that's it.
  }
View Full Code Here

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

   *
   * @throws Exception
   */
  public void testAeErrorRateThresholdTerminateModified1() throws Exception {
    int documentCount = 500; // number of documents to process
    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    int exceptionSequence = 5;
    String functionName = "process";
    String exceptionName = "AnnotatorProcessException";
    ManageOutputDevice.setAllSystemOutputToNirvana();

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

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

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

    ManageOutputDevice.setAllSystemOutputToDefault();
    // check the results, if everything worked as expected
    assertEquals(
            "The cpm called the listener, that the cpm has finished - which normally could not be.",
            false, listener.isFinished());
    assertEquals("The aborted-method of the listener wasn't called.", true, listener.isAborted());
    assertEquals("There are not as much exceptions as expected! ", (5 + 1), 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.