diff --git a/bom/pom.xml b/bom/pom.xml
index 8d019685f02..f6fcf1a56db 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -983,6 +983,11 @@
helidon-microprofile-testing-common
${helidon.version}
+
+ io.helidon.microprofile.testing
+ helidon-microprofile-testing-validator
+ ${helidon.version}
+
io.helidon.microprofile.testing
helidon-microprofile-testing-jaxrs
diff --git a/microprofile/testing/junit5/pom.xml b/microprofile/testing/junit5/pom.xml
index fbb9a8fe411..9e6dfddc376 100644
--- a/microprofile/testing/junit5/pom.xml
+++ b/microprofile/testing/junit5/pom.xml
@@ -65,6 +65,10 @@
io.helidon.microprofile.testing
helidon-microprofile-testing-common
+
+ io.helidon.microprofile.testing
+ helidon-microprofile-testing-validator
+
diff --git a/microprofile/testing/junit5/src/main/java/io/helidon/microprofile/testing/junit5/HelidonJunitExtension.java b/microprofile/testing/junit5/src/main/java/io/helidon/microprofile/testing/junit5/HelidonJunitExtension.java
index c38707cb61a..3babdbb9340 100644
--- a/microprofile/testing/junit5/src/main/java/io/helidon/microprofile/testing/junit5/HelidonJunitExtension.java
+++ b/microprofile/testing/junit5/src/main/java/io/helidon/microprofile/testing/junit5/HelidonJunitExtension.java
@@ -33,7 +33,6 @@
import io.helidon.config.mp.MpConfigSources;
import io.helidon.config.yaml.mp.YamlMpConfigSource;
-import io.helidon.microprofile.testing.common.JaxRsValidator;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Dependent;
@@ -139,7 +138,8 @@ public void beforeAll(ExtensionContext context) {
}
validatePerClass();
- JaxRsValidator.validate(testClass);
+ JunitJaxRsValidator junitJaxRsValidator = new JunitJaxRsValidator();
+ junitJaxRsValidator.validate(testClass);
configure(classLevelConfigMeta);
diff --git a/microprofile/testing/junit5/src/main/java/io/helidon/microprofile/testing/junit5/JunitJaxRsValidator.java b/microprofile/testing/junit5/src/main/java/io/helidon/microprofile/testing/junit5/JunitJaxRsValidator.java
new file mode 100644
index 00000000000..fbd03ed35f6
--- /dev/null
+++ b/microprofile/testing/junit5/src/main/java/io/helidon/microprofile/testing/junit5/JunitJaxRsValidator.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.helidon.microprofile.testing.junit5;
+
+import io.helidon.microprofile.testing.validator.JaxRsValidator;
+
+/**
+ * An implementation for JaxRs Validator for Junit.
+ */
+public class JunitJaxRsValidator extends JaxRsValidator {
+
+ @Override
+ public void validate(Class> testClass) throws RuntimeException {
+ if (checkAddJaxRs(testClass)){
+ DisableDiscovery disableDiscovery = testClass.getAnnotation(DisableDiscovery.class);
+ if (disableDiscovery == null) {
+ throw new RuntimeException("@AddJaxRs annotation may only be used with @DisableDiscovery annotation");
+ }
+ }
+ }
+}
diff --git a/microprofile/testing/junit5/src/main/java/module-info.java b/microprofile/testing/junit5/src/main/java/module-info.java
index edd016b6c59..133ec17ebcf 100644
--- a/microprofile/testing/junit5/src/main/java/module-info.java
+++ b/microprofile/testing/junit5/src/main/java/module-info.java
@@ -23,6 +23,7 @@
requires io.helidon.config.yaml.mp;
requires io.helidon.microprofile.cdi;
requires io.helidon.microprofile.testing.common;
+ requires io.helidon.microprofile.testing.validator;
requires jakarta.inject;
requires org.junit.jupiter.api;
diff --git a/microprofile/testing/pom.xml b/microprofile/testing/pom.xml
index 9917f6c070f..158712afd7d 100644
--- a/microprofile/testing/pom.xml
+++ b/microprofile/testing/pom.xml
@@ -37,5 +37,6 @@
junit5
testng
jaxrs
+ validator
diff --git a/microprofile/testing/testng/pom.xml b/microprofile/testing/testng/pom.xml
index 9022071e36c..8eb1b1ec50a 100644
--- a/microprofile/testing/testng/pom.xml
+++ b/microprofile/testing/testng/pom.xml
@@ -56,6 +56,10 @@
io.helidon.microprofile.testing
helidon-microprofile-testing-jaxrs
+
+ io.helidon.microprofile.testing
+ helidon-microprofile-testing-validator
+
\ No newline at end of file
diff --git a/microprofile/testing/testng/src/main/java/io/helidon/microprofile/testing/testng/HelidonTestNgListener.java b/microprofile/testing/testng/src/main/java/io/helidon/microprofile/testing/testng/HelidonTestNgListener.java
index 8002af45fc4..ad8e9df0a1f 100644
--- a/microprofile/testing/testng/src/main/java/io/helidon/microprofile/testing/testng/HelidonTestNgListener.java
+++ b/microprofile/testing/testng/src/main/java/io/helidon/microprofile/testing/testng/HelidonTestNgListener.java
@@ -33,7 +33,6 @@
import io.helidon.config.mp.MpConfigSources;
import io.helidon.config.yaml.mp.YamlMpConfigSource;
-import io.helidon.microprofile.testing.common.JaxRsValidator;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Dependent;
@@ -130,7 +129,8 @@ public void onBeforeClass(ITestClass iTestClass) {
}
validatePerClass();
- JaxRsValidator.validate(testClass);
+ TestNgJaxRsValidator testNgJaxRsValidator = new TestNgJaxRsValidator();
+ testNgJaxRsValidator.validate(testClass);
configure(classLevelConfigMeta);
diff --git a/microprofile/testing/testng/src/main/java/io/helidon/microprofile/testing/testng/TestNgJaxRsValidator.java b/microprofile/testing/testng/src/main/java/io/helidon/microprofile/testing/testng/TestNgJaxRsValidator.java
new file mode 100644
index 00000000000..b93045ea26f
--- /dev/null
+++ b/microprofile/testing/testng/src/main/java/io/helidon/microprofile/testing/testng/TestNgJaxRsValidator.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.helidon.microprofile.testing.testng;
+
+import io.helidon.microprofile.testing.validator.JaxRsValidator;
+
+/**
+ * An implementation for JaxRs Validator for Junit.
+ */
+public class TestNgJaxRsValidator extends JaxRsValidator {
+
+ @Override
+ public void validate(Class> testClass) throws RuntimeException {
+ if (checkAddJaxRs(testClass)){
+ DisableDiscovery disableDiscovery = testClass.getAnnotation(DisableDiscovery.class);
+ if (disableDiscovery == null) {
+ throw new RuntimeException("@AddJaxRs annotation may only be used with @DisableDiscovery annotation");
+ }
+ }
+ }
+}
diff --git a/microprofile/testing/testng/src/main/java/module-info.java b/microprofile/testing/testng/src/main/java/module-info.java
index faeb80bbcb1..5e70711f0d1 100644
--- a/microprofile/testing/testng/src/main/java/module-info.java
+++ b/microprofile/testing/testng/src/main/java/module-info.java
@@ -25,6 +25,7 @@
requires io.helidon.config.yaml.mp;
requires io.helidon.microprofile.testing.common;
requires io.helidon.microprofile.testing.jaxrs;
+ requires io.helidon.microprofile.testing.validator;
requires jakarta.cdi;
requires jakarta.inject;
requires jakarta.ws.rs;
diff --git a/microprofile/testing/validator/pom.xml b/microprofile/testing/validator/pom.xml
new file mode 100644
index 00000000000..3fd34a68ecb
--- /dev/null
+++ b/microprofile/testing/validator/pom.xml
@@ -0,0 +1,36 @@
+
+
+
+
+ 4.0.0
+
+ io.helidon.microprofile.testing
+ helidon-microprofile-testing-project
+ 4.0.0-SNAPSHOT
+ ../pom.xml
+
+
+ helidon-microprofile-testing-validator
+ Helidon Microprofile Testing JUnit5
+
+
+ Common validation for Helidon Testing
+
+
+
diff --git a/microprofile/testing/common/src/main/java/io/helidon/microprofile/testing/common/JaxRsValidator.java b/microprofile/testing/validator/src/main/java/io/helidon/microprofile/testing/validator/JaxRsValidator.java
similarity index 62%
rename from microprofile/testing/common/src/main/java/io/helidon/microprofile/testing/common/JaxRsValidator.java
rename to microprofile/testing/validator/src/main/java/io/helidon/microprofile/testing/validator/JaxRsValidator.java
index 9ccdeaec404..12d2e9265ee 100644
--- a/microprofile/testing/common/src/main/java/io/helidon/microprofile/testing/common/JaxRsValidator.java
+++ b/microprofile/testing/validator/src/main/java/io/helidon/microprofile/testing/validator/JaxRsValidator.java
@@ -14,33 +14,26 @@
* limitations under the License.
*/
-package io.helidon.microprofile.testing.common;
+package io.helidon.microprofile.testing.validator;
+
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
+
/**
* Validator for JAX-RS annotation usage.
*/
-public class JaxRsValidator {
-
- private JaxRsValidator() {
- }
+public abstract class JaxRsValidator implements TestValidator {
- /**
- * Perform validation. Runtime exception is thrown if something is wrong.
- * @param testClass the annotated test class
- */
- public static void validate(Class> testClass){
+ protected boolean checkAddJaxRs(Class> testClass){
Set testClassAnnotations = Arrays.stream(testClass.getDeclaredAnnotations())
.map(Annotation::annotationType)
.map(Class::getName)
.collect(Collectors.toSet());
- if (testClassAnnotations.stream().anyMatch(i -> i.contains("AddJaxRs"))
- && testClassAnnotations.stream().noneMatch(i -> i.contains("DisableDiscovery"))){
- throw new RuntimeException("@AddJaxRs annotation should be used only with @DisableDiscovery annotation.");
- }
+ //FIXME:THIS IS VERY BAD!
+ return testClassAnnotations.stream().anyMatch(i -> i.contains("AddJaxRs"));
}
}
diff --git a/microprofile/testing/validator/src/main/java/io/helidon/microprofile/testing/validator/TestValidator.java b/microprofile/testing/validator/src/main/java/io/helidon/microprofile/testing/validator/TestValidator.java
new file mode 100644
index 00000000000..3f667b1c5d4
--- /dev/null
+++ b/microprofile/testing/validator/src/main/java/io/helidon/microprofile/testing/validator/TestValidator.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.helidon.microprofile.testing.validator;
+
+/**
+ * Validator for test class.
+ */
+public interface TestValidator {
+
+ /**
+ * Perform Validation.
+ * @param testClass for verification.
+ */
+ void validate(Class> testClass) throws RuntimeException;
+}
diff --git a/microprofile/testing/validator/src/main/java/io/helidon/microprofile/testing/validator/package-info.java b/microprofile/testing/validator/src/main/java/io/helidon/microprofile/testing/validator/package-info.java
new file mode 100644
index 00000000000..e9ad98ded1d
--- /dev/null
+++ b/microprofile/testing/validator/src/main/java/io/helidon/microprofile/testing/validator/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Common Validation for Helidon Testing.
+ */
+package io.helidon.microprofile.testing.validator;
diff --git a/microprofile/testing/validator/src/main/java/module-info.java b/microprofile/testing/validator/src/main/java/module-info.java
new file mode 100644
index 00000000000..ea7a8672970
--- /dev/null
+++ b/microprofile/testing/validator/src/main/java/module-info.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2023 Oracle and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Tests validators.
+ */
+module io.helidon.microprofile.testing.validator {
+
+ exports io.helidon.microprofile.testing.validator;
+
+}