From 4defe36fa69a752629ba74554f17f8aa949a3660 Mon Sep 17 00:00:00 2001 From: Yiwei Li Date: Sun, 9 Oct 2022 21:39:02 -0500 Subject: [PATCH] Fix Flaky Test: getComponent --- .../servlet/WebxFrameworkFilterTests.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/webx/framework/src/test/java/com/alibaba/citrus/webx/servlet/WebxFrameworkFilterTests.java b/webx/framework/src/test/java/com/alibaba/citrus/webx/servlet/WebxFrameworkFilterTests.java index d1ba67755..a57e67d43 100644 --- a/webx/framework/src/test/java/com/alibaba/citrus/webx/servlet/WebxFrameworkFilterTests.java +++ b/webx/framework/src/test/java/com/alibaba/citrus/webx/servlet/WebxFrameworkFilterTests.java @@ -28,6 +28,9 @@ import javax.servlet.FilterChain; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.regex.Pattern; +import java.util.regex.Matcher; +import java.util.Collections; import com.alibaba.citrus.service.requestcontext.RequestContext; import com.alibaba.citrus.util.CollectionUtil; @@ -138,7 +141,21 @@ public void getComponent() throws Exception { assertSame(components.getParentWebxConfiguration(), rootComponent.getWebxConfiguration()); assertSame(components.getParentApplicationContext(), rootComponent.getApplicationContext()); assertSame(components, rootComponent.getWebxComponents()); - assertEquals(components.toString(), rootComponent.toString()); + + Pattern p = Pattern.compile("\\{(.*?)\\}"); + Matcher m = p.matcher(components.toString()); + List l1 = new ArrayList(); + while(m.find()) { + l1.add(m.group(1)); + } + Collections.sort(l1); + m = p.matcher(rootComponent.toString()); + List l2 = new ArrayList(); + while(m.find()) { + l2.add(m.group(1)); + } + Collections.sort(l2); + assertEquals(l1, l2); try { rootComponent.getWebxController();