GH-319 - Fix ApplicationModule by package name lookup.

Prior to this commit, the lookup for an ApplicationModule would find modules solely depending on the reference string starting with the base package. That means that a module with base package com.acme.foo, a request for com.acme.foobar would've resulted in a positive match, which of course is wrong.

We now match against either the module's base package or against the reference starting with the base package followed by a dot.
This commit is contained in:
Oliver Drotbohm
2023-10-15 17:29:27 +02:00
parent db1c2b813e
commit cb6d71ba60
3 changed files with 36 additions and 1 deletions

View File

@@ -16,11 +16,13 @@
package org.springframework.modulith.core;
import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;
import java.util.List;
import javax.sql.DataSource;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;
@@ -83,4 +85,13 @@ class ModuleUnitTest {
.<Class<?>> extracting(JavaClass::reflect)
.containsExactly(SampleAggregate.class);
}
@Test // GH-319
void containsPackage() {
assertThat(module.containsPackage(packageName)).isTrue();
assertThat(module.containsPackage(packageName + ".foo")).isTrue();
assertThat(module.containsPackage(packageName + "foo")).isFalse();
}
}