Class ManagedCas
java.lang.Object
org.apache.uima.fit.testing.junit.ManagedCas
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback
,org.junit.jupiter.api.extension.AfterTestExecutionCallback
,org.junit.jupiter.api.extension.Extension
,org.junit.jupiter.api.extension.TestWatcher
public final class ManagedCas
extends Object
implements org.junit.jupiter.api.extension.TestWatcher, org.junit.jupiter.api.extension.AfterTestExecutionCallback, org.junit.jupiter.api.extension.AfterAllCallback
Provides a
CAS
object which is automatically reset before the test. The idea of this
class is to re-use CAS objects across different test method to avoid the overhead of having to
set up a new CAS every time. Each thread requesting a CAS gets a different instance (the CASes
are internally managed as ThreadLocal
. When a test completes, all of the CASses that
handed out to any thread are reset (except any CASes which may meanwhile have been garbage
collected).-
Constructor Summary
ConstructorDescriptionProvides a CAS with an auto-detected type system.ManagedCas
(TypeSystemDescription aTypeSystemDescription) Provides a CAS with the specified type system. -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterAll
(org.junit.jupiter.api.extension.ExtensionContext aContext) void
afterTestExecution
(org.junit.jupiter.api.extension.ExtensionContext context) get()
Skip validation for the current test run only.withDefaultValidator
(Validator aValidator) Set a default validator for the all test runs.Skip validation by default.withValidator
(Validator aValidator) Set a validator for the current test run only.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.junit.jupiter.api.extension.TestWatcher
testAborted, testDisabled, testFailed, testSuccessful
-
Constructor Details
-
ManagedCas
public ManagedCas()Provides a CAS with an auto-detected type system. -
ManagedCas
Provides a CAS with the specified type system.- Parameters:
aTypeSystemDescription
- the type system used to initialize the CAS.
-
-
Method Details
-
get
- Returns:
- the CAS object managed by this rule.
-
afterAll
- Specified by:
afterAll
in interfaceorg.junit.jupiter.api.extension.AfterAllCallback
- Throws:
Exception
-
afterTestExecution
public void afterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception - Specified by:
afterTestExecution
in interfaceorg.junit.jupiter.api.extension.AfterTestExecutionCallback
- Throws:
Exception
-
skipValidation
Skip validation for the current test run only.- Returns:
- the object for chaining.
-
withoutDefaultValidator
Skip validation by default. If validation is enabled for a particular run usingwithValidator(Validator)
it is reset to a no-op validator again after the test is complete.- Returns:
- the object for chaining.
-
withDefaultValidator
Set a default validator for the all test runs.- Returns:
- the object for chaining.
-
withValidator
Set a validator for the current test run only.- Returns:
- the object for chaining.
-