接口 AotTestAttributes
- 所有已知实现类:
DefaultAotTestAttributes
AOT test attributes are supported in two modes of operation: build-time
and run-time. At build time, test components can contribute
attributes during the AOT processing phase. At run time, test components can
retrieve attributes that were contributed at
build time. If AotDetector.useGeneratedArtifacts() returns true,
run-time mode applies.
For example, if a test component computes something at build time that cannot be computed at run time, the result of the build-time computation can be stored as an AOT attribute and retrieved at run time without repeating the computation.
An AotContextLoader would typically contribute an attribute in
loadContextForAotProcessing();
whereas, an AotTestExecutionListener would typically contribute an attribute
in processAheadOfTime().
Any other test component — such as a
TestContextBootstrapper
— can choose to contribute an attribute at any point in time. Note that
contributing an attribute during standard JVM test execution will not have any
adverse side effect since AOT attributes will be ignored in that scenario. In
any case, you should use AotDetector.useGeneratedArtifacts() to determine
if invocations of setAttribute(String, String) and
removeAttribute(String) are permitted.
- 从以下版本开始:
- 4.0
- 作者:
- Sam Brannen, Harry Yang
-
方法概要
修饰符和类型方法说明default booleangetBoolean(String name) Retrieve the attribute value for the given name as aboolean.static AotTestAttributesGet the current instance ofAotTestAttributesto use.Retrieve the attribute value for the given name as aString.voidremoveAttribute(String name) Remove the attribute stored under the provided name.default voidsetAttribute(String name, boolean value) Set abooleanattribute for later retrieval during AOT run-time execution.voidsetAttribute(String name, String value) Set aStringattribute for later retrieval during AOT run-time execution.
-
方法详细资料
-
getInstance
Get the current instance ofAotTestAttributesto use.See the class-level
Javadocfor details on the two supported modes. -
setAttribute
Set aStringattribute for later retrieval during AOT run-time execution.In general, users should take care to prevent overlaps with other metadata attributes by using fully-qualified names, perhaps using a class or package name as a prefix.
- 参数:
name- the unique attribute namevalue- the associated attribute value- 抛出:
UnsupportedOperationException- if invoked during AOT run-time executionIllegalArgumentException- if the provided value isnullor if an attempt is made to override an existing attribute- 另请参阅:
-
setAttribute(String, boolean)removeAttribute(String)AotDetector.useGeneratedArtifacts()
-
setAttribute
Set abooleanattribute for later retrieval during AOT run-time execution.In general, users should take care to prevent overlaps with other metadata attributes by using fully-qualified names, perhaps using a class or package name as a prefix.
- 参数:
name- the unique attribute namevalue- the associated attribute value- 抛出:
UnsupportedOperationException- if invoked during AOT run-time executionIllegalArgumentException- if an attempt is made to override an existing attribute- 另请参阅:
-
setAttribute(String, String)removeAttribute(String)Boolean.toString(boolean)AotDetector.useGeneratedArtifacts()
-
removeAttribute
Remove the attribute stored under the provided name.- 参数:
name- the unique attribute name- 抛出:
UnsupportedOperationException- if invoked during AOT run-time execution- 另请参阅:
-
AotDetector.useGeneratedArtifacts()setAttribute(String, String)
-
getString
Retrieve the attribute value for the given name as aString.- 参数:
name- the unique attribute name- 返回:
- the associated attribute value, or
nullif not found - 另请参阅:
-
getBoolean
Retrieve the attribute value for the given name as aboolean.- 参数:
name- the unique attribute name- 返回:
trueif the attribute is set to "true" (ignoring case), false otherwise- 另请参阅:
-