Class ManagedJCas
java.lang.Object
org.apache.uima.fit.testing.junit.ManagedJCas
- 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 ManagedJCas
extends Object
implements org.junit.jupiter.api.extension.TestWatcher, org.junit.jupiter.api.extension.AfterTestExecutionCallback, org.junit.jupiter.api.extension.AfterAllCallback
Provides a
JCas
object which is automatically reset before the test. The idea of this
class is to re-use JCas objects across different test method to avoid the overhead of having to
set up a new JCas every time. Each thread requesting a JCas gets a different instance (the JCases
are internally managed as ThreadLocal
. When a test completes, all of the JCasses that
handed out to any thread are reset (except any JCases which may meanwhile have been garbage
collected).-
Constructor Summary
ConstructorDescriptionProvides a JCas with an auto-detected type system.ManagedJCas
(TypeSystemDescription aTypeSystemDescription) Provides a JCas 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
-
ManagedJCas
public ManagedJCas()Provides a JCas with an auto-detected type system. -
ManagedJCas
Provides a JCas with the specified type system.- Parameters:
aTypeSystemDescription
- the type system used to initialize the CAS.
-
-
Method Details
-
get
- Returns:
- the JCas 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.
-