Class EmbeddedPgExtension
java.lang.Object
de.softwareforge.testing.postgres.junit5.EmbeddedPgExtension
- All Implemented Interfaces:
- AfterAllCallback,- AfterEachCallback,- BeforeAllCallback,- BeforeEachCallback,- Extension,- ParameterResolver,- TestInstantiationAwareExtension
public final class EmbeddedPgExtension
extends Object
implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback, ParameterResolver
A JUnit 5 extension that manages an embedded PostgreSQL database server.
 
 This extension can provide the EmbeddedPostgres instance, a DatabaseInfo or a DataSource object as test parameters.
 
- Using a DatabaseInfoparameter is equivalent to callingcreateDatabaseInfo().
- Using a DataSourceparameter is equivalent to callingcreateDataSource().
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic final classBuilder forEmbeddedPgExtensioncustomization.Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtensionTestInstantiationAwareExtension.ExtensionContextScope
- 
Constructor SummaryConstructorsConstructorDescriptionDefault constructor which allows using this extension with theExtendWithannotation.
- 
Method SummaryModifier and TypeMethodDescriptionvoidafterAll(ExtensionContext extensionContext) voidafterEach(ExtensionContext extensionContext) voidbeforeAll(ExtensionContext extensionContext) voidbeforeEach(ExtensionContext extensionContext) Returns a newDatabaseInfodescribing a database connection.Returns a data source.resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) booleansupportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtensiongetTestInstantiationExtensionContextScope
- 
Constructor Details- 
EmbeddedPgExtensionpublic EmbeddedPgExtension()Default constructor which allows using this extension with theExtendWithannotation.This is equivalent to using @RegisterExtension public static EmbeddedPgExtension pg = MultiDatabaseBuilder.instanceWithDefaults().build();- Since:
- 3.0
 
 
- 
- 
Method Details- 
createDataSourceReturns a data source. Depending on the mode it returns a datasource connected to the same database (single mode) or a new database (multi mode) on every call.- Returns:
- A DataSourceinstance. This is never null.
- Throws:
- SQLException- If a problem connecting to the database occurs.
 
- 
createDatabaseInfoReturns a newDatabaseInfodescribing a database connection.Depending on the mode, this either describes the same database (single mode) or a new database (multi mode). - Returns:
- A DatabaseInfoinstance. This is never null.
- Throws:
- SQLException- If a problem connecting to the database occurs.
 
- 
beforeAll- Specified by:
- beforeAllin interface- BeforeAllCallback
- Throws:
- Exception
 
- 
afterAll- Specified by:
- afterAllin interface- AfterAllCallback
- Throws:
- Exception
 
- 
beforeEach- Specified by:
- beforeEachin interface- BeforeEachCallback
- Throws:
- Exception
 
- 
afterEach- Specified by:
- afterEachin interface- AfterEachCallback
- Throws:
- Exception
 
- 
supportsParameterpublic boolean supportsParameter(@Nonnull ParameterContext parameterContext, ExtensionContext extensionContext) - Specified by:
- supportsParameterin interface- ParameterResolver
 
- 
resolveParameterpublic Object resolveParameter(@Nonnull ParameterContext parameterContext, ExtensionContext extensionContext) - Specified by:
- resolveParameterin interface- ParameterResolver
 
 
-