@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2012 - 2023 the original author or authors .
* Copyright 2012 - 2024 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -145,15 +145,28 @@ class RestarterTests {
@@ -145,15 +145,28 @@ class RestarterTests {
}
@Test
@SuppressWarnings ( "rawtypes" )
void getOrAddAttributeWithExistingAttribute ( ) {
Restarter . getInstance ( ) . getOrAddAttribute ( "x" , ( ) - > "abc" ) ;
ObjectFactory objectFactory = mock ( ObjectFactory . class ) ;
ObjectFactory < ? > objectFactory = mock ( ObjectFactory . class ) ;
Object attribute = Restarter . getInstance ( ) . getOrAddAttribute ( "x" , objectFactory ) ;
assertThat ( attribute ) . isEqualTo ( "abc" ) ;
then ( objectFactory ) . shouldHaveNoInteractions ( ) ;
}
@Test
void getOrAddAttributeWithRecursion ( ) {
Restarter restarter = Restarter . getInstance ( ) ;
Object added = restarter . getOrAddAttribute ( "postgresContainer" , ( ) - > {
restarter . getOrAddAttribute ( "rabbitContainer" , ( ) - > "def" ) ;
return "abc" ;
} ) ;
ObjectFactory < ? > objectFactory = mock ( ObjectFactory . class ) ;
assertThat ( added ) . isEqualTo ( "abc" ) ;
assertThat ( restarter . getOrAddAttribute ( "postgresContainer" , objectFactory ) ) . isEqualTo ( "abc" ) ;
assertThat ( restarter . getOrAddAttribute ( "rabbitContainer" , objectFactory ) ) . isEqualTo ( "def" ) ;
then ( objectFactory ) . shouldHaveNoInteractions ( ) ;
}
@Test
void getThreadFactory ( ) throws Exception {
final ClassLoader parentLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ;