diff --git a/core/src/test/java/org/fuin/objects4j/core/PropertiesContainValidatorTest.java b/core/src/test/java/org/fuin/objects4j/core/PropertiesContainValidatorTest.java index 013b862..a162e94 100644 --- a/core/src/test/java/org/fuin/objects4j/core/PropertiesContainValidatorTest.java +++ b/core/src/test/java/org/fuin/objects4j/core/PropertiesContainValidatorTest.java @@ -20,7 +20,9 @@ import jakarta.validation.Validation; import jakarta.validation.Validator; import jakarta.validation.ValidatorFactory; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -36,8 +38,21 @@ public final class PropertiesContainValidatorTest { private PropertiesContain constraintAnnotation; + private static ValidatorFactory validatorFactory; + private Validator validator; + @BeforeAll + public static void beforeAll() { + validatorFactory = Validation.buildDefaultValidatorFactory(); + } + + @AfterAll + public static void afterAll() { + validatorFactory.close(); + validatorFactory = null; + } + @BeforeEach public final void setUp() { testee = new PropertiesContainValidator(); @@ -46,9 +61,7 @@ public final void setUp() { expect(constraintAnnotation.value()).andReturn(expected); replay(constraintAnnotation); testee.initialize(constraintAnnotation); - try (final ValidatorFactory factory = Validation.buildDefaultValidatorFactory()) { - validator = factory.getValidator(); - } + validator = validatorFactory.getValidator(); } @AfterEach