public abstract class TestPropertySourceUtils extends ObjectSE
@TestPropertySource を操作し、テスト PropertySources を Environment に追加するためのユーティリティメソッド。主にフレームワーク内での使用を目的としています。
TestPropertySource| 修飾子と型 | フィールドと説明 |
|---|---|
static StringSE | INLINED_PROPERTIES_PROPERTY_SOURCE_NAME インライン化されたプロパティから作成された MapPropertySource の名前。 |
| コンストラクターと説明 |
|---|
TestPropertySourceUtils() |
| 修飾子と型 | メソッドと説明 |
|---|---|
static void | addInlinedPropertiesToEnvironment(ConfigurableApplicationContext context, StringSE... inlinedProperties) 指定されたインライン化されたプロパティを、提供された context の Environment に追加します。 |
static void | addInlinedPropertiesToEnvironment(ConfigurableEnvironment environment, StringSE... inlinedProperties) 指定されたインライン化されたプロパティ(キーと値のペアの形式)を、指定された environment に追加します。 |
static void | addPropertiesFilesToEnvironment(ConfigurableApplicationContext context, StringSE... locations) |
static void | addPropertiesFilesToEnvironment(ConfigurableEnvironment environment, ResourceLoader resourceLoader, StringSE... locations) |
static MapSE<StringSE, ObjectSE> | convertInlinedPropertiesToMap(StringSE... inlinedProperties) 提供されたインライン化されたプロパティ(キーと値のペアの形式)をプロパティ名でキー付けされたマップに変換し、返されるマップでのプロパティ名の順序を維持します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEpublic static final StringSE INLINED_PROPERTIES_PROPERTY_SOURCE_NAME
MapPropertySource の名前。public static void addPropertiesFilesToEnvironment(ConfigurableApplicationContext context, StringSE... locations)
locations の PropertiesSE ファイルを、提供された context の Environment に追加します。 このメソッドは、単に addPropertiesFilesToEnvironment(ConfigurableEnvironment, ResourceLoader, String...) に委譲します。
context - 環境を更新する必要があるアプリケーションコンテキスト。nulllocations - 環境に追加する Properties ファイルのリソースの場所。空になる可能性がありますが、null はありません IllegalStateExceptionSE - プロパティファイルの処理中にエラーが発生した場合 ResourcePropertySource, TestPropertySource.locations(), addPropertiesFilesToEnvironment(ConfigurableEnvironment, ResourceLoader, String...)public static void addPropertiesFilesToEnvironment(ConfigurableEnvironment environment, ResourceLoader resourceLoader, StringSE... locations)
locations から提供された environment に PropertiesSE ファイルを追加します。 リソースの場所(${...} など)のプロパティプレースホルダーは、Environment に対して解決されます。
各プロパティファイルは ResourcePropertySource に変換され、優先順位の最も高い環境の PropertySources に追加されます。
environment - 更新する環境。nullresourceLoader - 各リソースをロードするために使用する ResourceLoader。nulllocations - 環境に追加する Properties ファイルのリソースの場所。空になる可能性がありますが、null はありません IllegalStateExceptionSE - プロパティファイルの処理中にエラーが発生した場合 ResourcePropertySource, TestPropertySource.locations(), addPropertiesFilesToEnvironment(ConfigurableApplicationContext, String...)public static void addInlinedPropertiesToEnvironment(ConfigurableApplicationContext context, StringSE... inlinedProperties)
context の Environment に追加します。 このメソッドは、単に addInlinedPropertiesToEnvironment(ConfigurableEnvironment, String[]) に委譲します。
context - 環境を更新する必要があるアプリケーションコンテキスト。nullinlinedProperties - 環境に追加するインラインプロパティ。空になる可能性がありますが、null になることはありません TestPropertySource.properties(), addInlinedPropertiesToEnvironment(ConfigurableEnvironment, String[])public static void addInlinedPropertiesToEnvironment(ConfigurableEnvironment environment, StringSE... inlinedProperties)
environment に追加します。 すべてのキーと値のペアは、最高の優先順位を持つ単一の MapPropertySource として Environment に追加されます。
インライン化されたプロパティの解析の詳細については、convertInlinedPropertiesToMap(java.lang.String...) の Javadoc を参照してください。
environment - 更新する環境。nullinlinedProperties - 環境に追加するインラインプロパティ。空になる可能性がありますが、null になることはありません MapPropertySource, INLINED_PROPERTIES_PROPERTY_SOURCE_NAME, TestPropertySource.properties(), convertInlinedPropertiesToMap(java.lang.String...)public static MapSE<StringSE,ObjectSE> convertInlinedPropertiesToMap(StringSE... inlinedProperties)
キーと値のペアの解析は、すべてのペアをメモリ内の仮想プロパティファイルに変換し、Properties.load(java.io.Reader)SE に委譲して各仮想ファイルを解析することで実現されます。
インライン化されたプロパティの詳細については、TestPropertySource.properties() の Javadoc を参照してください。
inlinedProperties - 変換するインラインプロパティ。空になる可能性がありますが、null になることはありません IllegalStateExceptionSE - 特定のキーと値のペアを解析できない場合、または特定のインラインプロパティに複数のキーと値のペアが含まれている場合 addInlinedPropertiesToEnvironment(ConfigurableEnvironment, String[])