File tree Expand file tree Collapse file tree 5 files changed +68
-7
lines changed
main/java/org/springframework/modulith/test
org/springframework/modulith/test Expand file tree Collapse file tree 5 files changed +68
-7
lines changed Original file line number Diff line number Diff line change @@ -63,12 +63,9 @@ static class ModuleContextCustomizer implements ContextCustomizer {
63
63
private static final Logger LOGGER = LoggerFactory .getLogger (ModuleContextCustomizer .class );
64
64
65
65
private final Supplier <ModuleTestExecution > execution ;
66
- private final Class <?> source ;
67
66
68
67
ModuleContextCustomizer (Class <?> testClass ) {
69
-
70
68
this .execution = ModuleTestExecution .of (testClass );
71
- this .source = testClass ;
72
69
}
73
70
74
71
/*
@@ -166,6 +163,7 @@ private static void logModules(ModuleTestExecution execution) {
166
163
*/
167
164
@ Override
168
165
public boolean equals (Object obj ) {
166
+
169
167
if (this == obj ) {
170
168
return true ;
171
169
}
@@ -174,7 +172,7 @@ public boolean equals(Object obj) {
174
172
return false ;
175
173
}
176
174
177
- return Objects .equals (this .source , that .source );
175
+ return Objects .equals (this .execution . get () , that .execution . get () );
178
176
}
179
177
180
178
/*
@@ -183,7 +181,7 @@ public boolean equals(Object obj) {
183
181
*/
184
182
@ Override
185
183
public int hashCode () {
186
- return Objects .hashCode (source );
184
+ return Objects .hashCode (execution . get () );
187
185
}
188
186
189
187
private static void logHeadline (String headline ) {
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2025 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ package example .module ;
17
+
18
+ import org .springframework .modulith .test .ApplicationModuleTest ;
19
+
20
+ /**
21
+ * @author Oliver Drotbohm
22
+ */
23
+ @ ApplicationModuleTest
24
+ public class SampleTestA {
25
+
26
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2025 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * https://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ package example .module ;
17
+
18
+ import org .springframework .modulith .test .ApplicationModuleTest ;
19
+
20
+ /**
21
+ * @author Oliver Drotbohm
22
+ */
23
+ @ ApplicationModuleTest
24
+ public class SampleTestB {}
Original file line number Diff line number Diff line change 18
18
import static org .assertj .core .api .Assertions .*;
19
19
20
20
import example .module .SampleTestA ;
21
+ import example .module .SampleTestB ;
21
22
22
23
import org .junit .jupiter .api .Test ;
23
24
import org .springframework .modulith .core .ApplicationModule ;
@@ -34,8 +35,8 @@ class ModuleContextCustomizerUnitTests {
34
35
@ Test
35
36
void instancesForSameTargetTypeAreEqual () {
36
37
37
- var left = new ModuleContextCustomizer (Object .class );
38
- var right = new ModuleContextCustomizer (Object .class );
38
+ var left = new ModuleContextCustomizer (SampleTestA .class );
39
+ var right = new ModuleContextCustomizer (SampleTestA .class );
39
40
40
41
assertThat (left ).isEqualTo (right );
41
42
assertThat (right ).isEqualTo (left );
@@ -53,4 +54,15 @@ void usesTestClassIfConfigured() {
53
54
.extracting (ApplicationModuleIdentifier ::toString )
54
55
.isEqualTo ("module" );
55
56
}
57
+
58
+ @ Test // GH-1050
59
+ void instancesWithSameModuleSetupAreConsideredEqual () {
60
+
61
+ var left = new ModuleContextCustomizer (SampleTestA .class );
62
+ var right = new ModuleContextCustomizer (SampleTestB .class );
63
+
64
+ assertThat (left ).isEqualTo (right );
65
+ assertThat (right ).isEqualTo (left );
66
+ assertThat (left ).hasSameHashCodeAs (right );
67
+ }
56
68
}
Original file line number Diff line number Diff line change
1
+ org.springframework.modulith.core.ApplicationModulesFactory=org.springframework.modulith.test.TestApplicationModules.Factory
You can’t perform that action at this time.
0 commit comments