forked from dropwizard/dropwizard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend DAOTestExtension with BeforeAll/AfterAll callbacks (dropwizard…
…#4680) # Problem The `DAOTestExtension` currently does not implement the Junit5 `BeforeAll` and `AfterAll` callbacks, therefore its not possible to register it as a proper extension during testing. # Solution Implement the `BeforeAllCallback` and `AfterAllCallback` interfaces. # Result `DAOTestExtension` can be registered as a proper extension during testing using the `@RegisterExtension` annotation.
- Loading branch information
1 parent
786cad5
commit 3493ae9
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ing/src/test/java/io/dropwizard/testing/junit5/DAOTestExtensionRegisterExtensionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.dropwizard.testing.junit5; | ||
|
||
import io.dropwizard.testing.app.TestEntity; | ||
import org.hibernate.SessionFactory; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
|
||
class DAOTestExtensionRegisterExtensionTest { | ||
|
||
@RegisterExtension | ||
static final DAOTestExtension daoTestExtension = | ||
DAOTestExtension.newBuilder() | ||
.addEntityClass(TestEntity.class) | ||
.build(); | ||
|
||
@Test | ||
void shouldProvideSession() { | ||
final SessionFactory sessionFactory = daoTestExtension.getSessionFactory(); | ||
assertThat(sessionFactory).isNotNull(); | ||
} | ||
} |