1414package io .trino .plugin .jdbc ;
1515
1616import com .google .common .collect .ImmutableMap ;
17- import com . google . common . collect . ImmutableSet ;
17+ import io . trino . plugin . base . jmx . ConnectorObjectNameGeneratorModule ;
1818import io .trino .spi .Plugin ;
1919import io .trino .spi .connector .Connector ;
2020import io .trino .spi .connector .ConnectorFactory ;
2828import java .util .Set ;
2929
3030import static com .google .common .collect .Iterables .getOnlyElement ;
31+ import static io .airlift .configuration .ConfigurationAwareModule .combine ;
32+ import static io .trino .testing .TestingNames .randomNameSuffix ;
3133import static java .lang .String .format ;
3234import static java .lang .management .ManagementFactory .getPlatformMBeanServer ;
3335import static org .assertj .core .api .Assertions .assertThat ;
@@ -38,21 +40,24 @@ public class TestJmxStats
3840 public void testJmxStatsExposure ()
3941 throws Exception
4042 {
41- Plugin plugin = new JdbcPlugin ("base_jdbc" , TestingH2JdbcModule ::new );
43+ String jmxBaseName = getClass ().getSimpleName () + "_" + randomNameSuffix ();
44+ Plugin plugin = new JdbcPlugin (
45+ "base_jdbc" ,
46+ () -> combine (new TestingH2JdbcModule (), new ConnectorObjectNameGeneratorModule ("io.trino.plugin.jdbc" , "trino.plugin.jdbc" )));
4247 ConnectorFactory factory = getOnlyElement (plugin .getConnectorFactories ());
4348 Connector connector = factory .create (
4449 "test" ,
4550 ImmutableMap .of (
4651 "connection-url" , "jdbc:driver:" ,
47- "bootstrap.quiet" , "true" ),
52+ "bootstrap.quiet" , "true" ,
53+ "jmx.base-name" , jmxBaseName ),
4854 new TestingConnectorContext ());
4955 MBeanServer mbeanServer = getPlatformMBeanServer ();
50- Set <ObjectName > objectNames = mbeanServer .queryNames (new ObjectName ("io.trino.plugin.jdbc :*" ), null );
56+ Set <ObjectName > objectNames = mbeanServer .queryNames (new ObjectName ("%s :*" . formatted ( jmxBaseName ) ), null );
5157
52- assertThat (objectNames .containsAll (
53- ImmutableSet .of (
54- new ObjectName ("io.trino.plugin.jdbc:type=ConnectionFactory,name=test" ),
55- new ObjectName ("io.trino.plugin.jdbc:type=JdbcClient,name=test" )))).isTrue ();
58+ assertThat (objectNames ).contains (
59+ new ObjectName ("%s:type=ConnectionFactory,name=test,catalog=test" .formatted (jmxBaseName )),
60+ new ObjectName ("%s:type=JdbcClient,name=test,catalog=test" .formatted (jmxBaseName )));
5661
5762 for (ObjectName objectName : objectNames ) {
5863 MBeanInfo mbeanInfo = mbeanServer .getMBeanInfo (objectName );
0 commit comments