1313import org .junit .jupiter .api .extension .ExtensionContext .Store ;
1414import org .junit .jupiter .api .extension .ExtensionContext .Store .CloseableResource ;
1515import org .junit .platform .commons .support .AnnotationSupport ;
16- import org .junit .platform .commons .util . AnnotationUtils ;
17- import org .junit .platform .commons .util . Preconditions ;
18- import org .junit .platform .commons .util . ReflectionUtils ;
16+ import org .junit .platform .commons .support . HierarchyTraversalMode ;
17+ import org .junit .platform .commons .support . ModifierSupport ;
18+ import org .junit .platform .commons .support . ReflectionSupport ;
1919import org .testcontainers .DockerClientFactory ;
2020import org .testcontainers .lifecycle .Startable ;
2121import org .testcontainers .lifecycle .TestDescription ;
@@ -131,7 +131,7 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
131131 private Optional <Testcontainers > findTestcontainers (ExtensionContext context ) {
132132 Optional <ExtensionContext > current = Optional .of (context );
133133 while (current .isPresent ()) {
134- Optional <Testcontainers > testcontainers = AnnotationUtils .findAnnotation (
134+ Optional <Testcontainers > testcontainers = AnnotationSupport .findAnnotation (
135135 current .get ().getRequiredTestClass (),
136136 Testcontainers .class
137137 );
@@ -169,26 +169,26 @@ private Set<Object> collectParentTestInstances(final ExtensionContext context) {
169169 }
170170
171171 private List <StoreAdapter > findSharedContainers (Class <?> testClass ) {
172- return ReflectionUtils
173- .findFields (testClass , isSharedContainer (), ReflectionUtils . HierarchyTraversalMode .TOP_DOWN )
172+ return ReflectionSupport
173+ .findFields (testClass , isSharedContainer (), HierarchyTraversalMode .TOP_DOWN )
174174 .stream ()
175175 .map (f -> getContainerInstance (null , f ))
176176 .collect (Collectors .toList ());
177177 }
178178
179179 private Predicate <Field > isSharedContainer () {
180- return isContainer ().and (ReflectionUtils ::isStatic );
180+ return isContainer ().and (ModifierSupport ::isStatic );
181181 }
182182
183183 private Stream <StoreAdapter > findRestartContainers (Object testInstance ) {
184- return ReflectionUtils
185- .findFields (testInstance .getClass (), isRestartContainer (), ReflectionUtils . HierarchyTraversalMode .TOP_DOWN )
184+ return ReflectionSupport
185+ .findFields (testInstance .getClass (), isRestartContainer (), HierarchyTraversalMode .TOP_DOWN )
186186 .stream ()
187187 .map (f -> getContainerInstance (testInstance , f ));
188188 }
189189
190190 private Predicate <Field > isRestartContainer () {
191- return isContainer ().and (ReflectionUtils ::isNotStatic );
191+ return isContainer ().and (ModifierSupport ::isNotStatic );
192192 }
193193
194194 private static Predicate <Field > isContainer () {
@@ -211,10 +211,10 @@ private static Predicate<Field> isContainer() {
211211 private static StoreAdapter getContainerInstance (final Object testInstance , final Field field ) {
212212 try {
213213 field .setAccessible (true );
214- Startable containerInstance = Preconditions . notNull (
215- ( Startable ) field . get ( testInstance ),
216- "Container " + field .getName () + " needs to be initialized"
217- );
214+ Startable containerInstance = ( Startable ) field . get ( testInstance );
215+ if ( containerInstance == null ) {
216+ throw new ExtensionConfigurationException ( "Container " + field .getName () + " needs to be initialized" );
217+ }
218218 return new StoreAdapter (field .getDeclaringClass (), field .getName (), containerInstance );
219219 } catch (IllegalAccessException e ) {
220220 throw new ExtensionConfigurationException ("Can not access container defined in field " + field .getName ());
0 commit comments