1616 */
1717package org .apache .activemq .jms .pool ;
1818
19- import static org .junit .Assert .assertNotSame ;
20- import static org .junit .Assert .assertTrue ;
21- import static org .junit .Assert .fail ;
22-
23- import java .util .ArrayList ;
24- import java .util .List ;
25-
2619import jakarta .jms .Connection ;
2720import jakarta .jms .ExceptionListener ;
2821import jakarta .jms .JMSException ;
2922import jakarta .jms .JMSSecurityException ;
3023import jakarta .jms .MessageProducer ;
3124import jakarta .jms .Queue ;
3225import jakarta .jms .Session ;
33-
3426import org .apache .activemq .ActiveMQConnectionFactory ;
3527import org .apache .activemq .broker .BrokerPlugin ;
3628import org .apache .activemq .broker .BrokerService ;
5042import org .slf4j .Logger ;
5143import org .slf4j .LoggerFactory ;
5244
45+ import java .util .ArrayList ;
46+ import java .util .List ;
47+
48+ import static org .junit .Assert .assertNotSame ;
49+ import static org .junit .Assert .assertTrue ;
50+ import static org .junit .Assert .fail ;
51+
5352/**
5453 * Test Pooled connections ability to handle security exceptions
5554 */
@@ -112,7 +111,6 @@ public void onException(JMSException exception) {
112111 @ Test
113112 public void testFailureGetsNewConnectionOnRetryLooped () throws Exception {
114113 for (int i = 0 ; i < 10 ; ++i ) {
115- LOG .info ("Iteration: {}" , i );
116114 testFailureGetsNewConnectionOnRetry ();
117115 }
118116 }
@@ -136,13 +134,15 @@ public void testFailureGetsNewConnectionOnRetry() throws Exception {
136134 @ Override
137135 public boolean isSatisified () throws Exception {
138136 try (final PooledConnection newConnection = (PooledConnection ) pooledConnFact .createConnection ("invalid" , "credentials" )) {
139- return connection1 .getConnection () != newConnection .getConnection ();
137+ return connection1 .pool != ((PooledConnection )newConnection ).pool ;
138+ } catch (Exception e ) {
139+ return false ;
140140 }
141141 }
142142 }));
143143
144144 final PooledConnection connection2 = (PooledConnection ) pooledConnFact .createConnection ("invalid" , "credentials" );
145- assertNotSame (connection1 .getConnection () , connection2 .getConnection () );
145+ assertNotSame (connection1 .pool , connection2 .pool );
146146
147147 try {
148148 connection2 .start ();
@@ -235,13 +235,15 @@ public void testFailoverWithInvalidCredentials() throws Exception {
235235 @ Override
236236 public boolean isSatisified () throws Exception {
237237 try (final PooledConnection newConnection = (PooledConnection ) pooledConnFact .createConnection ("invalid" , "credentials" )) {
238- return connection1 .getConnection () != newConnection .getConnection ();
238+ return connection1 .pool != ((PooledConnection )newConnection ).pool ;
239+ } catch (Exception e ) {
240+ return false ;
239241 }
240242 }
241243 }));
242244
243245 final PooledConnection connection2 = (PooledConnection ) pooledConnFact .createConnection ("invalid" , "credentials" );
244- assertNotSame (connection1 .getConnection () , connection2 .getConnection () );
246+ assertNotSame (connection1 .pool , connection2 .pool );
245247
246248 try {
247249 connection2 .start ();
@@ -412,4 +414,4 @@ protected BrokerPlugin configureAuthorization() throws Exception {
412414
413415 return authorizationPlugin ;
414416 }
415- }
417+ }
0 commit comments