You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2022/02/10 20:29:18 UTC
[commons-dbcp] 03/03: Adds a test for PoolableConnectionMXBean compliance
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git
commit 239acbedcbbad2b4e2cd8e4ca4900363274d00b7
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Thu Feb 10 16:45:33 2022 +0100
Adds a test for PoolableConnectionMXBean compliance
---
.../apache/commons/dbcp2/TestPoolableConnection.java | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java b/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
index 02ab602..38e058f 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
@@ -18,18 +18,24 @@ package org.apache.commons.dbcp2;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
+import javax.management.JMX;
+import javax.management.NotCompliantMBeanException;
+
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import com.sun.jmx.mbeanserver.Introspector;
+
/**
*/
public class TestPoolableConnection {
@@ -202,4 +208,18 @@ public class TestPoolableConnection {
assertEquals(false, ((PoolableConnection) conn).isDisconnectionSqlException(rootException));
assertEquals(false, ((PoolableConnection) conn).isFatalException(rootException));
}
+
+ /**
+ * Tests if the {@link PoolableConnectionMXBean} interface is a valid MXBean
+ * interface.
+ */
+ @Test
+ public void testMXBeanCompliance() {
+ assertTrue(JMX.isMXBeanInterface(PoolableConnectionMXBean.class));
+ try {
+ Introspector.testComplianceMXBeanInterface(PoolableConnectionMXBean.class);
+ } catch (NotCompliantMBeanException e) {
+ fail(e);
+ }
+ }
}