You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2024/08/02 13:35:05 UTC
(cxf) branch main updated: [CXF-9042] Fixed non-idempotent unit tests (#1978)
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/main by this push:
new 0740778cbc [CXF-9042] Fixed non-idempotent unit tests (#1978)
0740778cbc is described below
commit 0740778cbc6e159a99a3811113b71440dd841236
Author: Kaiyao Ke <47...@users.noreply.github.com>
AuthorDate: Fri Aug 2 21:35:00 2024 +0800
[CXF-9042] Fixed non-idempotent unit tests (#1978)
* fixed non-idempotent unit tests
* updated MBeans unregistering
* create new document when creating token wrapper
---
.../cxf/management/InstrumentationManagerTest.java | 37 +++++++++++++---------
.../operation/ValidateJWTTransformationTest.java | 2 +-
.../systest/dispatch/DispatchClientServerTest.java | 15 +++++----
3 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java b/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java
index 39ab81ac2d..5e0a136613 100644
--- a/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java
+++ b/rt/management/src/test/java/org/apache/cxf/management/InstrumentationManagerTest.java
@@ -89,23 +89,30 @@ public class InstrumentationManagerTest {
ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME
+ ":type=WorkQueues,*");
Set<ObjectName> s = mbs.queryNames(name, null);
- assertEquals(2, s.size());
- Iterator<ObjectName> it = s.iterator();
- while (it.hasNext()) {
- ObjectName n = it.next();
- Long result =
- (Long)mbs.invoke(n, "getWorkQueueMaxSize", new Object[0], new String[0]);
- assertEquals(result, Long.valueOf(256));
- Integer hwm =
- (Integer)mbs.invoke(n, "getHighWaterMark", new Object[0], new String[0]);
- if (n.getCanonicalName().contains("test-wq")) {
- assertEquals(10, hwm.intValue());
- } else {
- assertEquals(15, hwm.intValue());
+ try {
+ assertEquals(2, s.size());
+ Iterator<ObjectName> it = s.iterator();
+ while (it.hasNext()) {
+ ObjectName n = it.next();
+ Long result =
+ (Long)mbs.invoke(n, "getWorkQueueMaxSize", new Object[0], new String[0]);
+ assertEquals(result, Long.valueOf(256));
+ Integer hwm =
+ (Integer)mbs.invoke(n, "getHighWaterMark", new Object[0], new String[0]);
+ if (n.getCanonicalName().contains("test-wq")) {
+ assertEquals(10, hwm.intValue());
+ } else {
+ assertEquals(15, hwm.intValue());
+ }
}
+ } finally {
+ // Unregister MBeans at the end of the test
+ Iterator<ObjectName> it2 = s.iterator();
+ while (it2.hasNext()) {
+ mbs.unregisterMBean(it2.next());
+ }
+ bus.shutdown(true);
}
-
- bus.shutdown(true);
}
@Test
diff --git a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateJWTTransformationTest.java b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateJWTTransformationTest.java
index 59f19e40dd..765269b2f3 100644
--- a/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateJWTTransformationTest.java
+++ b/services/sts/sts-core/src/test/java/org/apache/cxf/sts/operation/ValidateJWTTransformationTest.java
@@ -338,7 +338,7 @@ public class ValidateJWTTransformationTest {
}
private Element createTokenWrapper(String token) {
- Document doc = DOMUtils.getEmptyDocument();
+ Document doc = DOMUtils.createDocument();
Element tokenWrapper = doc.createElementNS(null, "TokenWrapper");
tokenWrapper.setTextContent(token);
return tokenWrapper;
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
index 1cb5bb01e8..0928d00c4d 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java
@@ -659,6 +659,11 @@ public class DispatchClientServerTest extends AbstractBusClientServerTestBase {
@Test
public void testJAXBObjectPAYLOADWithFeature() throws Exception {
+ // Save initial counts
+ int initialCount = TestDispatchFeature.getCount();
+ int initialInInterceptorCount = TestDispatchFeature.getInInterceptorCount();
+ int initialOutInterceptorCount = TestDispatchFeature.getOutInterceptorCount();
+
createBus("org/apache/cxf/systest/dispatch/client-config.xml");
BusFactory.setThreadDefaultBus(bus);
@@ -688,15 +693,13 @@ public class DispatchClientServerTest extends AbstractBusClientServerTestBase {
String responseValue = ((GreetMeResponse)response).getResponseType();
assertEquals("Expected string, " + expected, expected, responseValue);
- assertEquals("Feature should be applied", 1, TestDispatchFeature.getCount());
+ assertEquals("Feature should be applied", initialCount + 1, TestDispatchFeature.getCount());
assertEquals("Feature based interceptors should be added",
- 1, TestDispatchFeature.getCount());
-
+ initialCount + 1, TestDispatchFeature.getCount());
assertEquals("Feature based In interceptors has be added to in chain.",
- 1, TestDispatchFeature.getInInterceptorCount());
-
+ initialInInterceptorCount + 1, TestDispatchFeature.getInInterceptorCount());
assertEquals("Feature based interceptors has to be added to out chain.",
- 1, TestDispatchFeature.getOutInterceptorCount());
+ initialOutInterceptorCount + 1, TestDispatchFeature.getOutInterceptorCount());
bus.shutdown(true);
}