From 7683acb0083a00172fc582dcc22b82426d9d6ec8 Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Thu, 10 Jan 2019 18:55:22 +0100 Subject: [PATCH] Scheduler - validate cron() and every() expressions - also rename BuildShouldFailWith to ShouldFail and assert startup failures - resolves #462 --- ...ConfigPropertyInjectionValidationTest.java | 4 +- .../InterceptorNoBindingsTest.java | 4 +- .../deployment/SchedulerProcessor.java | 44 +++++++++++++++- .../test/InvalidCronExpressionTest.java | 52 +++++++++++++++++++ .../test/InvalidEveryExpressionTest.java | 52 +++++++++++++++++++ .../test/MissingConfigCronExpressionTest.java | 48 +++++++++++++++++ .../scheduler/test/NoExpressionTest.java | 52 +++++++++++++++++++ .../scheduler/runtime/QuartzScheduler.java | 20 +++---- .../scheduler/runtime/ScheduledLiteral.java | 9 ++++ .../PersistenceAndShamrockConfigTest.java | 8 +-- .../jboss/shamrock/test/ShamrockUnitTest.java | 27 ++++++---- ...ildShouldFailWith.java => ShouldFail.java} | 11 ++-- 12 files changed, 296 insertions(+), 35 deletions(-) create mode 100644 extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/InvalidCronExpressionTest.java create mode 100644 extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/InvalidEveryExpressionTest.java create mode 100644 extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/MissingConfigCronExpressionTest.java create mode 100644 extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/NoExpressionTest.java rename test-framework/junit/src/main/java/org/jboss/shamrock/test/{BuildShouldFailWith.java => ShouldFail.java} (80%) diff --git a/extensions/arc/deployment/src/test/java/org/jboss/shamrock/arc/test/config/ConfigPropertyInjectionValidationTest.java b/extensions/arc/deployment/src/test/java/org/jboss/shamrock/arc/test/config/ConfigPropertyInjectionValidationTest.java index 32979024b528b..db714d41202d7 100644 --- a/extensions/arc/deployment/src/test/java/org/jboss/shamrock/arc/test/config/ConfigPropertyInjectionValidationTest.java +++ b/extensions/arc/deployment/src/test/java/org/jboss/shamrock/arc/test/config/ConfigPropertyInjectionValidationTest.java @@ -23,7 +23,7 @@ import javax.inject.Inject; import org.eclipse.microprofile.config.inject.ConfigProperty; -import org.jboss.shamrock.test.BuildShouldFailWith; +import org.jboss.shamrock.test.ShouldFail; import org.jboss.shamrock.test.Deployment; import org.jboss.shamrock.test.ShamrockUnitTest; import org.jboss.shrinkwrap.api.ShrinkWrap; @@ -34,7 +34,7 @@ @RunWith(ShamrockUnitTest.class) public class ConfigPropertyInjectionValidationTest { - @BuildShouldFailWith(DeploymentException.class) + @ShouldFail(DeploymentException.class) @Deployment public static JavaArchive deploy() { return ShrinkWrap.create(JavaArchive.class) diff --git a/extensions/arc/deployment/src/test/java/org/jboss/shamrock/arc/test/interceptor/InterceptorNoBindingsTest.java b/extensions/arc/deployment/src/test/java/org/jboss/shamrock/arc/test/interceptor/InterceptorNoBindingsTest.java index c61ea58866683..059871f1b028a 100644 --- a/extensions/arc/deployment/src/test/java/org/jboss/shamrock/arc/test/interceptor/InterceptorNoBindingsTest.java +++ b/extensions/arc/deployment/src/test/java/org/jboss/shamrock/arc/test/interceptor/InterceptorNoBindingsTest.java @@ -22,7 +22,7 @@ import javax.interceptor.Interceptor; import javax.interceptor.InvocationContext; -import org.jboss.shamrock.test.BuildShouldFailWith; +import org.jboss.shamrock.test.ShouldFail; import org.jboss.shamrock.test.Deployment; import org.jboss.shamrock.test.ShamrockUnitTest; import org.jboss.shrinkwrap.api.ShrinkWrap; @@ -33,7 +33,7 @@ @RunWith(ShamrockUnitTest.class) public class InterceptorNoBindingsTest { - @BuildShouldFailWith(DefinitionException.class) + @ShouldFail(DefinitionException.class) @Deployment public static JavaArchive deploy() { return ShrinkWrap.create(JavaArchive.class) diff --git a/extensions/scheduler/deployment/src/main/java/org/jboss/shamrock/scheduler/deployment/SchedulerProcessor.java b/extensions/scheduler/deployment/src/main/java/org/jboss/shamrock/scheduler/deployment/SchedulerProcessor.java index c6d79ab185fe6..31b33c21bc58c 100644 --- a/extensions/scheduler/deployment/src/main/java/org/jboss/shamrock/scheduler/deployment/SchedulerProcessor.java +++ b/extensions/scheduler/deployment/src/main/java/org/jboss/shamrock/scheduler/deployment/SchedulerProcessor.java @@ -17,6 +17,8 @@ import static org.jboss.shamrock.annotations.ExecutionTime.STATIC_INIT; +import java.text.ParseException; +import java.time.Duration; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -40,6 +42,7 @@ import org.jboss.protean.arc.processor.AnnotationStore; import org.jboss.protean.arc.processor.AnnotationsTransformer; import org.jboss.protean.arc.processor.BeanDeploymentValidator; +import org.jboss.protean.arc.processor.BeanDeploymentValidator.ValidationContext; import org.jboss.protean.arc.processor.BeanInfo; import org.jboss.protean.arc.processor.DotNames; import org.jboss.protean.arc.processor.ScopeInfo; @@ -62,8 +65,10 @@ import org.jboss.shamrock.scheduler.api.Scheduleds; import org.jboss.shamrock.scheduler.runtime.QuartzScheduler; import org.jboss.shamrock.scheduler.runtime.ScheduledInvoker; +import org.jboss.shamrock.scheduler.runtime.ScheduledLiteral; import org.jboss.shamrock.scheduler.runtime.SchedulerConfiguration; import org.jboss.shamrock.scheduler.runtime.SchedulerDeploymentTemplate; +import org.quartz.CronExpression; import org.quartz.simpl.CascadingClassLoadHelper; import org.quartz.simpl.RAMJobStore; import org.quartz.simpl.SimpleThreadPool; @@ -167,8 +172,11 @@ public void validate(ValidationContext validationContext) { if (!method.returnType().kind().equals(Type.Kind.VOID)) { throw new IllegalStateException(String.format("Scheduled business method must return void [method: %s, bean:%s", method.returnType(), method, bean)); } + // Validate cron() and every() expressions + for (AnnotationInstance scheduled : schedules) { + validateScheduled(validationContext, scheduled); + } scheduledBusinessMethods.produce(new ScheduledBusinessMethodItem(bean, method, schedules)); - // TODO: validate cron and period expressions LOGGER.debugf("Found scheduled business method %s declared on %s", method, bean); } } @@ -260,6 +268,40 @@ private Object getValue(AnnotationValue annotationValue) { } } + private void validateScheduled(ValidationContext validationContext, AnnotationInstance schedule) { + AnnotationValue cronValue = schedule.value("cron"); + if (cronValue != null && !cronValue.asString().trim().isEmpty()) { + String cron = cronValue.asString().trim(); + if (ScheduledLiteral.isConfigValue(cron)) { + // Don't validate config property + return; + } + try { + new CronExpression(cron); + } catch (ParseException e) { + validationContext.addDeploymentProblem(new IllegalStateException("Invalid cron() expression on: " + schedule, e)); + } + } else { + AnnotationValue everyValue = schedule.value("every"); + if (everyValue != null && !everyValue.asString().trim().isEmpty()) { + String every = everyValue.asString().trim(); + if (ScheduledLiteral.isConfigValue(every)) { + return; + } + if (Character.isDigit(every.charAt(0))) { + every = "PT" + every; + } + try { + Duration.parse(every); + } catch (Exception e) { + validationContext.addDeploymentProblem(new IllegalStateException("Invalid every() expression on: " + schedule, e)); + } + } else { + validationContext.addDeploymentProblem(new IllegalStateException("@Scheduled must declare either cron() or every(): " + schedule)); + } + } + } + static final class ProcessorClassOutput implements ClassOutput { private final BuildProducer producer; diff --git a/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/InvalidCronExpressionTest.java b/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/InvalidCronExpressionTest.java new file mode 100644 index 0000000000000..8225706cee86e --- /dev/null +++ b/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/InvalidCronExpressionTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2018 Red Hat, Inc. + * + * 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 org.jboss.shamrock.scheduler.test; + +import javax.enterprise.inject.spi.DeploymentException; + +import org.jboss.shamrock.scheduler.api.Scheduled; +import org.jboss.shamrock.test.ShouldFail; +import org.jboss.shamrock.test.Deployment; +import org.jboss.shamrock.test.ShamrockUnitTest; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(ShamrockUnitTest.class) +public class InvalidCronExpressionTest { + + @ShouldFail(DeploymentException.class) + @Deployment + public static JavaArchive deploy() { + return ShrinkWrap.create(JavaArchive.class) + .addClasses(InvalidBean.class); + } + + @Test + public void test() throws InterruptedException { + } + + static class InvalidBean { + + + @Scheduled(cron="0 0 0 ????") + void wrong() { + } + + } + +} diff --git a/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/InvalidEveryExpressionTest.java b/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/InvalidEveryExpressionTest.java new file mode 100644 index 0000000000000..250f1b826f1b4 --- /dev/null +++ b/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/InvalidEveryExpressionTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2018 Red Hat, Inc. + * + * 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 org.jboss.shamrock.scheduler.test; + +import javax.enterprise.inject.spi.DeploymentException; + +import org.jboss.shamrock.scheduler.api.Scheduled; +import org.jboss.shamrock.test.ShouldFail; +import org.jboss.shamrock.test.Deployment; +import org.jboss.shamrock.test.ShamrockUnitTest; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(ShamrockUnitTest.class) +public class InvalidEveryExpressionTest { + + @ShouldFail(DeploymentException.class) + @Deployment + public static JavaArchive deploy() { + return ShrinkWrap.create(JavaArchive.class) + .addClasses(InvalidBean.class); + } + + @Test + public void test() throws InterruptedException { + } + + static class InvalidBean { + + + @Scheduled(every="call me every other day") + void wrong() { + } + + } + +} diff --git a/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/MissingConfigCronExpressionTest.java b/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/MissingConfigCronExpressionTest.java new file mode 100644 index 0000000000000..78067c11a2585 --- /dev/null +++ b/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/MissingConfigCronExpressionTest.java @@ -0,0 +1,48 @@ +/* + * Copyright 2018 Red Hat, Inc. + * + * 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 org.jboss.shamrock.scheduler.test; + +import org.jboss.shamrock.scheduler.api.Scheduled; +import org.jboss.shamrock.test.Deployment; +import org.jboss.shamrock.test.ShamrockUnitTest; +import org.jboss.shamrock.test.ShouldFail; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(ShamrockUnitTest.class) +public class MissingConfigCronExpressionTest { + + @ShouldFail(IllegalStateException.class) + @Deployment + public static JavaArchive deploy() { + return ShrinkWrap.create(JavaArchive.class).addClasses(InvalidBean.class); + } + + @Test + public void test() throws InterruptedException { + } + + static class InvalidBean { + + @Scheduled(cron = "{my.cron}") + void wrong() { + } + + } + +} diff --git a/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/NoExpressionTest.java b/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/NoExpressionTest.java new file mode 100644 index 0000000000000..65d4ad6ccb9e3 --- /dev/null +++ b/extensions/scheduler/deployment/src/test/java/org/jboss/shamrock/scheduler/test/NoExpressionTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2018 Red Hat, Inc. + * + * 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 org.jboss.shamrock.scheduler.test; + +import javax.enterprise.inject.spi.DeploymentException; + +import org.jboss.shamrock.scheduler.api.Scheduled; +import org.jboss.shamrock.test.ShouldFail; +import org.jboss.shamrock.test.Deployment; +import org.jboss.shamrock.test.ShamrockUnitTest; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(ShamrockUnitTest.class) +public class NoExpressionTest { + + @ShouldFail(DeploymentException.class) + @Deployment + public static JavaArchive deploy() { + return ShrinkWrap.create(JavaArchive.class) + .addClasses(InvalidBean.class); + } + + @Test + public void test() throws InterruptedException { + } + + static class InvalidBean { + + + @Scheduled + void wrong() { + } + + } + +} diff --git a/extensions/scheduler/runtime/src/main/java/org/jboss/shamrock/scheduler/runtime/QuartzScheduler.java b/extensions/scheduler/runtime/src/main/java/org/jboss/shamrock/scheduler/runtime/QuartzScheduler.java index e720df151aa71..31cfeddba424e 100644 --- a/extensions/scheduler/runtime/src/main/java/org/jboss/shamrock/scheduler/runtime/QuartzScheduler.java +++ b/extensions/scheduler/runtime/src/main/java/org/jboss/shamrock/scheduler/runtime/QuartzScheduler.java @@ -171,21 +171,21 @@ public Job newJob(TriggerFiredBundle bundle, org.quartz.Scheduler scheduler) thr .usingJobData(SchedulerDeploymentTemplate.INVOKER_KEY, entry.getKey()); ScheduleBuilder scheduleBuilder; - String cron = scheduled.cron(); + String cron = scheduled.cron().trim(); if (!cron.isEmpty()) { try { - if (cron.startsWith("{") && cron.endsWith("}")) { - cron = config.getValue(cron.substring(1, cron.length() - 1), String.class); + if (ScheduledLiteral.isConfigValue(cron)) { + cron = config.getValue(ScheduledLiteral.getConfigProperty(cron), String.class); } scheduleBuilder = CronScheduleBuilder.cronSchedule(cron); } catch (RuntimeException e) { - LOGGER.warnf(e, "Invalid CRON expression: %s", cron); - continue; + // This should only happen for config-based expressions + throw new IllegalStateException("Invalid cron() expression on: " + scheduled, e); } } else if (!scheduled.every().isEmpty()) { - String every = scheduled.every(); - if (every.startsWith("{") && every.endsWith("}")) { - every = config.getValue(every.substring(1, every.length() - 1), String.class); + String every = scheduled.every().trim(); + if (ScheduledLiteral.isConfigValue(every)) { + every = config.getValue(ScheduledLiteral.getConfigProperty(every), String.class); } if (Character.isDigit(every.charAt(0))) { every = "PT" + every; @@ -194,8 +194,8 @@ public Job newJob(TriggerFiredBundle bundle, org.quartz.Scheduler scheduler) thr try { duration = Duration.parse(every); } catch (Exception e) { - LOGGER.warnf(e, "Invalid period expression: %s", scheduled.every()); - continue; + // This should only happen for config-based expressions + throw new IllegalStateException("Invalid every() expression on: " + scheduled, e); } scheduleBuilder = SimpleScheduleBuilder.simpleSchedule().withIntervalInMilliseconds(duration.toMillis()).repeatForever(); } else { diff --git a/extensions/scheduler/runtime/src/main/java/org/jboss/shamrock/scheduler/runtime/ScheduledLiteral.java b/extensions/scheduler/runtime/src/main/java/org/jboss/shamrock/scheduler/runtime/ScheduledLiteral.java index 760513fb59770..fd99d1b034685 100644 --- a/extensions/scheduler/runtime/src/main/java/org/jboss/shamrock/scheduler/runtime/ScheduledLiteral.java +++ b/extensions/scheduler/runtime/src/main/java/org/jboss/shamrock/scheduler/runtime/ScheduledLiteral.java @@ -105,4 +105,13 @@ Scheduled build() { } + public static boolean isConfigValue(String val) { + val = val.trim(); + return val.startsWith("{") && val.endsWith("}"); + } + + public static String getConfigProperty(String val) { + return val.substring(1, val.length() - 1); + } + } \ No newline at end of file diff --git a/integration-tests/jpa/src/test/java/org/shamrock/jpa/tests/configurationless/PersistenceAndShamrockConfigTest.java b/integration-tests/jpa/src/test/java/org/shamrock/jpa/tests/configurationless/PersistenceAndShamrockConfigTest.java index afc884507db8b..1586f67605748 100644 --- a/integration-tests/jpa/src/test/java/org/shamrock/jpa/tests/configurationless/PersistenceAndShamrockConfigTest.java +++ b/integration-tests/jpa/src/test/java/org/shamrock/jpa/tests/configurationless/PersistenceAndShamrockConfigTest.java @@ -1,23 +1,23 @@ package org.shamrock.jpa.tests.configurationless; +import static org.junit.Assert.fail; + import org.jboss.shamrock.deployment.configuration.ConfigurationError; -import org.jboss.shamrock.test.BuildShouldFailWith; import org.jboss.shamrock.test.Deployment; import org.jboss.shamrock.test.ShamrockUnitTest; +import org.jboss.shamrock.test.ShouldFail; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.fail; - /** * @author Emmanuel Bernard emmanuel@hibernate.org */ @RunWith(ShamrockUnitTest.class) public class PersistenceAndShamrockConfigTest { @Deployment - @BuildShouldFailWith(ConfigurationError.class) + @ShouldFail(ConfigurationError.class) public static JavaArchive deploy() { return ShrinkWrap.create(JavaArchive.class) .addClasses(Gift.class, CRUDResource.class, ConfigurationlessApp.class) diff --git a/test-framework/junit/src/main/java/org/jboss/shamrock/test/ShamrockUnitTest.java b/test-framework/junit/src/main/java/org/jboss/shamrock/test/ShamrockUnitTest.java index 85654dfb69021..13b6e101f228a 100644 --- a/test-framework/junit/src/main/java/org/jboss/shamrock/test/ShamrockUnitTest.java +++ b/test-framework/junit/src/main/java/org/jboss/shamrock/test/ShamrockUnitTest.java @@ -18,6 +18,7 @@ import static org.jboss.shamrock.test.PathTestHelper.getTestClassesLocation; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.io.File; @@ -58,7 +59,7 @@ public class ShamrockUnitTest extends BlockJUnit4ClassRunner { // It will do as long as we keep the test execution sequential and don't parallelize things. private static RuntimeRunner runtimeRunner; private static Path deploymentDir; - private static BuildShouldFailWith buildShouldFailWith; + private static ShouldFail shouldFail; public ShamrockUnitTest(Class klass) throws InitializationError { // We need to do it this way as we need to refresh the class once Shamrock is started @@ -75,7 +76,7 @@ protected Object createTest() throws Exception { protected void runChild(final FrameworkMethod method, RunNotifier notifier) { if (started) { super.runChild(method, notifier); - } else if (buildShouldFailWith != null) { + } else if (shouldFail != null) { notifier.fireTestFinished(describeChild(method)); } else { notifier.fireTestIgnored(describeChild(method)); @@ -93,7 +94,7 @@ private static Class doSetup(Class testClass) { try { deploymentDir = Files.createTempDirectory("shamrock-unit-test"); Method deploymentMethod = getDeploymentMethod(testClass); - buildShouldFailWith = deploymentMethod.getAnnotation(BuildShouldFailWith.class); + shouldFail = deploymentMethod.getAnnotation(ShouldFail.class); exportArchive(deploymentDir, testClass, deploymentMethod); @@ -102,20 +103,24 @@ private static Class doSetup(Class testClass) { try { runtimeRunner.run(); - if (buildShouldFailWith != null) { - fail("Build did not fail"); + if (shouldFail != null) { + fail("Test deployment did not fail"); } started = true; } catch (Exception e) { started = false; - if (buildShouldFailWith != null) { + if (shouldFail != null) { if (e instanceof RuntimeException) { Throwable cause = e.getCause(); - if (cause != null && cause instanceof BuildException) { - assertEquals("Build failed with wrong exception", buildShouldFailWith.value(), - cause.getCause().getClass()); - } else { - fail("Build did not fail with build exception: " + e); + if (cause instanceof BuildException) { + cause = cause.getCause(); + } else if(cause instanceof RuntimeException) { + // Startup failure + cause = cause.getCause(); + } + if (cause != null) { + assertTrue(cause.getClass() + " is not assignable to the expected: " + shouldFail.value(), shouldFail.value() + .isAssignableFrom(cause.getClass())); } } else { fail("Unable to unwrap build exception from: " + e); diff --git a/test-framework/junit/src/main/java/org/jboss/shamrock/test/BuildShouldFailWith.java b/test-framework/junit/src/main/java/org/jboss/shamrock/test/ShouldFail.java similarity index 80% rename from test-framework/junit/src/main/java/org/jboss/shamrock/test/BuildShouldFailWith.java rename to test-framework/junit/src/main/java/org/jboss/shamrock/test/ShouldFail.java index bfa83075581b8..69a5f0aa94fd3 100644 --- a/test-framework/junit/src/main/java/org/jboss/shamrock/test/BuildShouldFailWith.java +++ b/test-framework/junit/src/main/java/org/jboss/shamrock/test/ShouldFail.java @@ -21,18 +21,19 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.jboss.builder.BuildException; +import org.jboss.shamrock.runner.RuntimeRunner; /** - * Annotation that is used to assert a build failure. + * Annotation that is used to assert a boot failure. *

* This method should be used together with {@link Deployment}. * - * @see BuildException + * @see RuntimeRunner#run() */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) -public @interface BuildShouldFailWith { +public @interface ShouldFail { - Class value() default Exception.class; + Class value() default Throwable.class; + }