Skip to content

Commit 400b6e2

Browse files
Stabilize the test ConfigManagerTest.testGetConfigByIdOrName() (#15758)
1 parent f77f43e commit 400b6e2

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

dubbo-common/src/test/java/org/apache/dubbo/config/context/ConfigManagerTest.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,20 @@ void testGetConfigByIdOrName() {
410410
Assertions.fail();
411411
} catch (Exception e) {
412412
Assertions.assertTrue(e instanceof IllegalStateException);
413-
Assertions.assertEquals(
414-
e.getMessage(),
415-
"Found more than one config by name: dubbo, instances: "
416-
+ "[<dubbo:protocol port=\"9103\" name=\"dubbo\" />, <dubbo:protocol name=\"dubbo\" />]. "
417-
+ "Please remove redundant configs or get config by id.");
413+
String msg = e.getMessage();
414+
415+
Assertions.assertTrue(
416+
msg.startsWith("Found more than one config by name: dubbo, instances: "),
417+
"Unexpected message prefix: " + msg);
418+
Assertions.assertTrue(
419+
msg.contains("<dubbo:protocol port=\"9103\" name=\"dubbo\" />"),
420+
"Message should mention protocol with port 9103: " + msg);
421+
Assertions.assertTrue(
422+
msg.contains("<dubbo:protocol name=\"dubbo\" />"),
423+
"Message should mention protocol with default port: " + msg);
424+
Assertions.assertTrue(
425+
msg.endsWith("Please remove redundant configs or get config by id."),
426+
"Unexpected message suffix: " + msg);
418427
}
419428

420429
ModuleConfig moduleConfig = new ModuleConfig();

0 commit comments

Comments
 (0)