Examples of TestStatusCallbackListener


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
    boolean exceptionThrown = false;
    TestStatusCallbackListener listener = null;
    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 (NullPointerException e) {
      exceptionThrown = true;
    } finally {
      // check the results, if everything worked as expected
      ManageOutputDevice.setAllSystemOutputToDefault();
      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 testInitializeWithNullPointerException() throws Exception {
    int documentCount = 20; // number of documents processed
    int exceptionSequence = 1; // the sequence in which errors are produced
    boolean exceptionThrown = false;
    // setup CPM
    TestStatusCallbackListener listener = null;
    ManageOutputDevice.setAllSystemOutputToNirvana();
    try {
      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 (NullPointerException e) {
      // e.printStackTrace();
      exceptionThrown = true;
    } finally {
      // check the results, if everything worked as expected
      ManageOutputDevice.setAllSystemOutputToDefault();
      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 testInitializeWithOutOfMemoryError() throws Exception {
    int documentCount = 20; // number of documents processed
    int exceptionSequence = 1; // the sequence in which errors are produced
    boolean errorThrown = false;
    // setup CPM
    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    ManageOutputDevice.setAllSystemOutputToNirvana();
    try {
      CollectionProcessingEngine cpe = setupCpm(documentCount, "OutOfMemoryError",
              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 (OutOfMemoryError er) {
      errorThrown = true;
    } finally {
      // check the results, if everything worked as expected
      ManageOutputDevice.setAllSystemOutputToDefault();
      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());
      assertEquals("The expected Error wasn't thrown! ", true, errorThrown);
    }
  }
View Full Code Here

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

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

    // 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);
    }
    // check the results, if everything worked as expected
    ManageOutputDevice.setAllSystemOutputToDefault();
    assertEquals(
            "The cpm is still working or the collectionProcessComplete-method of the listener was not called.",
            true, listener.isFinished());
    assertEquals("The aborted-method of the listener was called. (new behaviour?)", false, listener
            .isAborted());
    assertEquals("There are not as much exceptions  thrown as expected! ",
            ((documentCount) / exceptionSequence), FunctionErrorStore.getCount());
    assertEquals(
            "The CAS which causes the error wasn't given to the process methode. Null was returned.",
            false, null == listener.getLastCas());
  }
View Full Code Here

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

    // setup CPM
    CollectionProcessingEngine cpe = setupCpm(documentCount, "ResourceProcessException",
            exceptionSequence, "processCas");

    // 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);
    }
    // check the results, if everything worked as expected
    ManageOutputDevice.setAllSystemOutputToDefault();
    assertEquals("The cpm did not call the listener, that the cpm has finished.", true, listener
            .isFinished());
    assertEquals("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, "NullPointerException",
            exceptionSequence, "processCas");

    // 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);
    }
    // check the results, if everything worked as expected
    ManageOutputDevice.setAllSystemOutputToDefault();
    assertEquals("The cpm did not call the listener, that the cpm has finished.", true, listener
            .isFinished());
    assertEquals("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, "AnnotatorProcessException",
            exceptionSequence, "process");

    // 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! ", 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);
    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());
    // 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);
    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! ", 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);
      cpe.process();
      // wait until cpm has finished
      while (!listener.isFinished() && !listener.isAborted()) {
        Thread.sleep(5);
      }
    } 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
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.