GH-284 - Support for open application modules.
Application modules can now be declared as open, which causes internal components being exposed for access by other modules.
This commit is contained in:
@@ -61,7 +61,7 @@ class ModulithTest {
|
||||
assertThatExceptionOfType(Violations.class).isThrownBy(() -> {
|
||||
|
||||
ApplicationModules
|
||||
.of(Application.class, DEFAULT_EXCLUSIONS.or(Filters.withoutModule("invalid")))
|
||||
.of(Application.class, DEFAULT_EXCLUSIONS.or(Filters.withoutModules("invalid", "opendisallowedclient")))
|
||||
.verify();
|
||||
|
||||
}).satisfies(it -> {
|
||||
|
||||
@@ -211,6 +211,29 @@ class ApplicationModulesIntegrationTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test // GH-284
|
||||
void detectsOpenModule() {
|
||||
|
||||
assertThat(modules.getModuleByName("open")).hasValueSatisfying(it -> {
|
||||
assertThat(it.isOpen()).isTrue();
|
||||
});
|
||||
|
||||
var detectViolations = modules.detectViolations().getMessages();
|
||||
|
||||
assertThat(detectViolations)
|
||||
.isNotEmpty()
|
||||
|
||||
// No invalid references to internals from unrestricted module
|
||||
.noneMatch(it -> it.matches("Module 'openclient' depends on non-exposed type .* within module 'open'"))
|
||||
|
||||
// Invalid reference to internals from restricted module
|
||||
.anyMatch(it -> it.contains("Module 'opendisallowedclient' depends on module 'open'"))
|
||||
|
||||
// No cycle detection
|
||||
.anyMatch(it -> it.contains("Cycle detected: Slice cycleA"))
|
||||
.noneMatch(it -> it.contains("Cycle detected: Slice open"));
|
||||
}
|
||||
|
||||
private static void verifyNamedInterfaces(NamedInterfaces interfaces, String name, Class<?>... types) {
|
||||
|
||||
Stream.of(types).forEach(type -> {
|
||||
|
||||
Reference in New Issue
Block a user