public class DefaultTestContext extends ObjectSE implements TestContext
TestContext
インターフェースのデフォルト実装。コンストラクターと説明 |
---|
DefaultTestContext(ClassSE<?> testClass, MergedContextConfiguration mergedContextConfiguration, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate) 指定された引数から新しい DefaultTestContext を構築します。 |
DefaultTestContext(DefaultTestContext testContext) 指定されたコンテキストの属性と不変の状態に基づいて新しい DefaultTestContext を作成するためのコピーコンストラクター。 |
修飾子と型 | メソッドと説明 |
---|---|
StringSE[] | attributeNames() すべての属性の名前を返します。 |
<T> T | computeAttribute(StringSE name, FunctionSE<StringSE,T> computeFunction) |
ApplicationContext | getApplicationContext() このテストコンテキストのアプリケーションコンテキストを取得します。 |
ObjectSE | getAttribute(StringSE name) name で識別される属性の値を取得します。 |
ClassSE<?> | getTestClass() このテストコンテキストのテストクラスSEを取得します。 |
ThrowableSE | getTestException() |
ObjectSE | getTestInstance() このテストコンテキストの現在のテストインスタンスを取得SEします。 |
MethodSE | getTestMethod() このテストコンテキストの現在のテストメソッドを取得SEします。 |
boolean | hasApplicationContext() このテストコンテキストのアプリケーションコンテキストがコンテキストキャッシュに存在するかどうかを確認します。 |
boolean | hasAttribute(StringSE name) name で識別される属性が存在する場合は、true を返します。 |
void | markApplicationContextDirty(DirtiesContext.HierarchyMode hierarchyMode) このテストコンテキストに関連付けられたアプリケーションコンテキストをダーティとしてマークします (つまり、コンテキストキャッシュから削除し、閉じます)。 |
ObjectSE | removeAttribute(StringSE name) name で識別される属性を削除し、その値を返します。 |
void | setAttribute(StringSE name, ObjectSE value) name で定義された属性を、指定された value に設定します。 |
StringSE | toString() このテストコンテキストの状態の文字列表現を提供します。 |
void | updateState(ObjectSE testInstance, MethodSE testMethod, ThrowableSE testException) このテストコンテキストを更新して、現在実行中のテストの状態を反映させます。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
publishEvent
public DefaultTestContext(DefaultTestContext testContext)
DefaultTestContext
を作成するためのコピーコンストラクター。不変状態には、標準コンストラクターに提供されるすべての引数が含まれます。
NullPointerExceptionSE
- 提供された DefaultTestContext
が null
の場合 public DefaultTestContext(ClassSE<?> testClass, MergedContextConfiguration mergedContextConfiguration, CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate)
DefaultTestContext
を構築します。testClass
- このテストコンテキストのテストクラス mergedContextConfiguration
- このテストコンテキストのマージされたアプリケーションコンテキスト構成 cacheAwareContextLoaderDelegate
- このテストコンテキストのアプリケーションコンテキストをロードおよび閉じるために使用するデリゲート public boolean hasApplicationContext()
TestContext
の hasApplicationContext
true
(アプリケーションコンテキストがすでにロードされ、コンテキストキャッシュに格納されている場合)getApplicationContext()
, CacheAwareContextLoaderDelegate.isContextLoaded(org.springframework.test.context.MergedContextConfiguration)
public ApplicationContext getApplicationContext()
デフォルトの実装は、この TestContext
の構築時に提供された CacheAwareContextLoaderDelegate
に委譲します。
TestContext
の getApplicationContext
null
)IllegalStateExceptionSE
- コンテキストローダーデリゲートによって返されたコンテキストがアクティブでない場合 (つまり、閉鎖されています)CacheAwareContextLoaderDelegate.loadContext(org.springframework.test.context.MergedContextConfiguration)
public void markApplicationContextDirty(@Nullable DirtiesContext.HierarchyMode hierarchyMode)
デフォルトの実装は、この TestContext
の構築時に提供された CacheAwareContextLoaderDelegate
に委譲します。
TestContext
の markApplicationContextDirty
hierarchyMode
- コンテキストが階層の一部である場合に適用されるコンテキストキャッシュのクリアモード (null
の場合があります)CacheAwareContextLoaderDelegate.closeContext(org.springframework.test.context.MergedContextConfiguration, org.springframework.test.annotation.DirtiesContext.HierarchyMode)
public final ClassSE<?> getTestClass()
TestContext
TestContext
の getTestClass
null
)public final ObjectSE getTestInstance()
TestContext
メモ: これは変更可能なプロパティです。
TestContext
の getTestInstance
null
)TestContext.updateState(Object, Method, Throwable)
public final MethodSE getTestMethod()
TestContext
メモ: これは変更可能なプロパティです。
TestContext
の getTestMethod
null
)TestContext.updateState(Object, Method, Throwable)
@Nullable public final ThrowableSE getTestException()
TestContext
TestContext
の getTestException
null
TestContext.updateState(Object, Method, Throwable)
public void updateState(@Nullable ObjectSE testInstance, @Nullable MethodSE testMethod, @Nullable ThrowableSE testException)
TestContext
警告 : このメソッドは TestContextManager
によってのみ呼び出されます。
注意: このメソッドの同時呼び出しは、基盤となる実装によっては、スレッドセーフではない場合があります。
TestContext
の updateState
testInstance
- 現在のテストインスタンス (null
の場合があります)testMethod
- 現在のテストメソッド (null
の場合があります)testException
- テストメソッドでスローされた例外、または例外がスローされなかった場合は null
public void setAttribute(StringSE name, @Nullable ObjectSE value)
AttributeAccessor
name
で定義された属性を、指定された value
に設定します。value
が null
の場合、属性は removed
です。
一般に、ユーザーは、クラスまたはパッケージ名を接頭辞として使用するなど、完全修飾名を使用して、他のメタデータ属性との重複を防ぐように注意する必要があります。
AttributeAccessor
の setAttribute
name
- 一意の属性キー value
- 添付する属性値 @Nullable public ObjectSE getAttribute(StringSE name)
AttributeAccessor
name
で識別される属性の値を取得します。 属性が存在しない場合は null
を返します。
AttributeAccessor
の getAttribute
name
- 一意の属性キー public <T> T computeAttribute(StringSE name, FunctionSE<StringSE,T> computeFunction)
AttributeAccessor
name
で識別される属性の新しい値を計算し、この AttributeAccessor
に新しい値を設定します。name
で識別される属性の値がこの AttributeAccessor
にすでに存在する場合、提供された計算関数を適用せずに既存の値が返されます。
このメソッドのデフォルトの実装はスレッドセーフではありませんが、このインターフェースの具体的な実装によってオーバーライドできます。
AttributeAccessor
の computeAttribute
T
- 属性値の型 name
- 一意の属性キー computeFunction
- 属性名の新しい値を計算する関数。関数は null
値を返してはなりません AttributeAccessor.getAttribute(String)
, AttributeAccessor.setAttribute(String, Object)
@Nullable public ObjectSE removeAttribute(StringSE name)
AttributeAccessor
name
で識別される属性を削除し、その値を返します。name
に属性が見つからない場合は、null
を返します。
AttributeAccessor
の removeAttribute
name
- 一意の属性キー public boolean hasAttribute(StringSE name)
AttributeAccessor
name
で識別される属性が存在する場合は、true
を返します。 それ以外の場合は false
を返します。
AttributeAccessor
の hasAttribute
name
- 一意の属性キー public StringSE[] attributeNames()
AttributeAccessor
AttributeAccessor
の attributeNames
public StringSE toString()
ObjectSE
の toStringSE