-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-360 - Fix potential UnsupportedOperationException in test bootstrap.
- Loading branch information
Showing
2 changed files
with
54 additions
and
37 deletions.
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
44 changes: 44 additions & 0 deletions
44
...t/java/org/springframework/modulith/test/ModuleTestAutoConfigurationIntegrationTests.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,44 @@ | ||
package org.springframework.modulith.test; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.autoconfigure.AutoConfigurations; | ||
import org.springframework.boot.autoconfigure.domain.EntityScan; | ||
import org.springframework.boot.autoconfigure.domain.EntityScanPackages; | ||
import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
||
/** | ||
* Integration tests for {@link ModuleTestAutoConfiguration}. | ||
* | ||
* @author Oliver Drotbohm | ||
*/ | ||
class ModuleTestAutoConfigurationIntegrationTests { | ||
|
||
@Test // GH-360 | ||
void bootstrapsTestWithManualEntityScanOfModulithPackage() { | ||
|
||
var execution = mock(ModuleTestExecution.class); | ||
|
||
doReturn(Stream.of("org.springframework.modulith.test")) | ||
.when(execution).getBasePackages(); | ||
|
||
new ApplicationContextRunner() | ||
.withBean(ModuleTestExecution.class, () -> execution) | ||
.withConfiguration(AutoConfigurations.of(ModuleTestAutoConfiguration.class)) | ||
.withUserConfiguration(ManualModulithEntityScan.class) | ||
.run(ctx -> { | ||
|
||
assertThat(ctx).hasNotFailed(); | ||
assertThat(ctx.getBean(EntityScanPackages.class).getPackageNames()) | ||
.containsExactlyInAnyOrder("org.springframework.modulith.test", | ||
"org.springframework.modulith.events.jpa"); | ||
}); | ||
} | ||
|
||
@EntityScan("org.springframework.modulith.events.jpa") | ||
static class ManualModulithEntityScan {} | ||
} |