3535import static java .util .concurrent .Executors .newSingleThreadExecutor ;
3636import static java .util .stream .IntStream .range ;
3737import static java .util .stream .Stream .of ;
38+ import static org .assertj .core .api .Assertions .assertThat ;
3839import static org .assertj .core .api .Assertions .assertThatThrownBy ;
3940import static org .assertj .core .api .Fail .fail ;
4041
4142import com .rabbitmq .client .amqp .AmqpException ;
43+ import com .rabbitmq .client .amqp .AmqpException .AmqpEntityDoesNotExistException ;
44+ import com .rabbitmq .client .amqp .AmqpException .AmqpResourceInvalidStateException ;
4245import com .rabbitmq .client .amqp .Connection ;
4346import com .rabbitmq .client .amqp .ConsumerBuilder ;
4447import com .rabbitmq .client .amqp .Environment ;
@@ -337,7 +340,7 @@ void pauseShouldStopMessageArrivalUnpauseShouldResumeIt() {
337340 void publisherShouldThrowWhenExchangeDoesNotExist () {
338341 String doesNotExist = uuid ();
339342 assertThatThrownBy (() -> connection .publisherBuilder ().exchange (doesNotExist ).build ())
340- .isInstanceOf (AmqpException . AmqpEntityDoesNotExistException .class )
343+ .isInstanceOf (AmqpEntityDoesNotExistException .class )
341344 .hasMessageContaining (doesNotExist );
342345 }
343346
@@ -367,7 +370,7 @@ void publisherSendingShouldThrowWhenExchangeHasBeenDeleted() {
367370 try {
368371 publisher .publish (publisher .message (), ctx -> {});
369372 return false ;
370- } catch (AmqpException . AmqpEntityDoesNotExistException e ) {
373+ } catch (AmqpEntityDoesNotExistException e ) {
371374 exception .set (e );
372375 return true ;
373376 }
@@ -377,7 +380,7 @@ void publisherSendingShouldThrowWhenExchangeHasBeenDeleted() {
377380 .forEach (
378381 e ->
379382 org .assertj .core .api .Assertions .assertThat (e )
380- .isInstanceOf (AmqpException . AmqpEntityDoesNotExistException .class )
383+ .isInstanceOf (AmqpEntityDoesNotExistException .class )
381384 .hasMessageContaining (name )
382385 .hasMessageContaining (ExceptionUtils .ERROR_NOT_FOUND ));
383386 }
@@ -387,7 +390,7 @@ void publisherSendingShouldThrowWhenExchangeHasBeenDeleted() {
387390 void publisherShouldThrowWhenQueueDoesNotExist () {
388391 String doesNotExist = uuid ();
389392 assertThatThrownBy (() -> connection .publisherBuilder ().queue (doesNotExist ).build ())
390- .isInstanceOf (AmqpException . AmqpEntityDoesNotExistException .class )
393+ .isInstanceOf (AmqpEntityDoesNotExistException .class )
391394 .hasMessageContaining (doesNotExist );
392395 }
393396
@@ -415,18 +418,20 @@ void publisherSendingShouldThrowWhenQueueHasBeenDeleted() {
415418 try {
416419 publisher .publish (publisher .message (), ctx -> {});
417420 return false ;
418- } catch (AmqpException . AmqpEntityDoesNotExistException e ) {
421+ } catch (AmqpEntityDoesNotExistException | AmqpResourceInvalidStateException e ) {
419422 exception .set (e );
420423 return true ;
421424 }
422425 });
423426 assertThat (closedSync ).completes ();
424- of (exception .get (), closedException .get ())
425- .forEach (
426- e ->
427- org .assertj .core .api .Assertions .assertThat (e )
428- .isInstanceOf (AmqpException .AmqpEntityDoesNotExistException .class )
429- .hasMessageContaining (ExceptionUtils .ERROR_RESOURCE_DELETED ));
427+
428+ assertThat (exception .get ())
429+ .isInstanceOfAny (
430+ AmqpEntityDoesNotExistException .class , AmqpEntityDoesNotExistException .class );
431+
432+ assertThat (closedException .get ())
433+ .isInstanceOf (AmqpEntityDoesNotExistException .class )
434+ .hasMessageContaining (ExceptionUtils .ERROR_RESOURCE_DELETED );
430435 }
431436
432437 @ Test
@@ -478,7 +483,7 @@ void consumerShouldThrowWhenQueueDoesNotExist() {
478483 .queue (doesNotExist )
479484 .messageHandler ((ctx , msg ) -> {})
480485 .build ())
481- .isInstanceOf (AmqpException . AmqpEntityDoesNotExistException .class )
486+ .isInstanceOf (AmqpEntityDoesNotExistException .class )
482487 .hasMessageContaining (doesNotExist );
483488 }
484489
@@ -510,7 +515,7 @@ void consumerShouldGetClosedWhenQueueIsDeleted() {
510515 connection .management ().queueDelete (name );
511516 assertThat (closedSync ).completes ();
512517 org .assertj .core .api .Assertions .assertThat (exception .get ())
513- .isInstanceOf (AmqpException . AmqpEntityDoesNotExistException .class )
518+ .isInstanceOf (AmqpEntityDoesNotExistException .class )
514519 .hasMessageContaining (ExceptionUtils .ERROR_RESOURCE_DELETED );
515520 }
516521
@@ -780,7 +785,7 @@ void queuePurgeShouldRemoveAllMessages(TestInfo info) {
780785 void queuePurgeOnNonExistingQueueShouldThrowException (TestInfo info ) {
781786 String q = TestUtils .name (info );
782787 assertThatThrownBy (() -> connection .management ().queuePurge (q ))
783- .isInstanceOf (AmqpException . AmqpEntityDoesNotExistException .class )
788+ .isInstanceOf (AmqpEntityDoesNotExistException .class )
784789 .hasMessageContaining (q );
785790 }
786791
0 commit comments