org.springframework.test.annotation.ProfileValueUtils Java Examples
The following examples show how to use
org.springframework.test.annotation.ProfileValueUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProfileValueChecker.java From spring-analysis-note with MIT License | 6 votes |
/** * Determine if the test specified by arguments to the * {@linkplain #ProfileValueChecker constructor} is <em>enabled</em> in * the current environment, as configured via the {@link IfProfileValue * @IfProfileValue} annotation. * <p>If the test is not annotated with {@code @IfProfileValue} it is * considered enabled. * <p>If a test is not enabled, this method will abort further evaluation * of the execution chain with a failed assumption; otherwise, this method * will simply evaluate the next {@link Statement} in the execution chain. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Method, Class) * @throws AssumptionViolatedException if the test is disabled * @throws Throwable if evaluation of the next statement fails */ @Override public void evaluate() throws Throwable { if (this.testMethod == null) { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(this.testClass)) { Annotation ann = AnnotatedElementUtils.findMergedAnnotation(this.testClass, IfProfileValue.class); throw new AssumptionViolatedException(String.format( "Profile configured via [%s] is not enabled in this environment for test class [%s].", ann, this.testClass.getName())); } } else { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(this.testMethod, this.testClass)) { throw new AssumptionViolatedException(String.format( "Profile configured via @IfProfileValue is not enabled in this environment for test method [%s].", this.testMethod)); } } this.next.evaluate(); }
Example #2
Source File: ProfileValueChecker.java From java-technology-stack with MIT License | 6 votes |
/** * Determine if the test specified by arguments to the * {@linkplain #ProfileValueChecker constructor} is <em>enabled</em> in * the current environment, as configured via the {@link IfProfileValue * @IfProfileValue} annotation. * <p>If the test is not annotated with {@code @IfProfileValue} it is * considered enabled. * <p>If a test is not enabled, this method will abort further evaluation * of the execution chain with a failed assumption; otherwise, this method * will simply evaluate the next {@link Statement} in the execution chain. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Method, Class) * @throws AssumptionViolatedException if the test is disabled * @throws Throwable if evaluation of the next statement fails */ @Override public void evaluate() throws Throwable { if (this.testMethod == null) { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(this.testClass)) { Annotation ann = AnnotatedElementUtils.findMergedAnnotation(this.testClass, IfProfileValue.class); throw new AssumptionViolatedException(String.format( "Profile configured via [%s] is not enabled in this environment for test class [%s].", ann, this.testClass.getName())); } } else { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(this.testMethod, this.testClass)) { throw new AssumptionViolatedException(String.format( "Profile configured via @IfProfileValue is not enabled in this environment for test method [%s].", this.testMethod)); } } this.next.evaluate(); }
Example #3
Source File: ProfileValueChecker.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Determine if the test specified by arguments to the * {@linkplain #ProfileValueChecker constructor} is <em>enabled</em> in * the current environment, as configured via the {@link IfProfileValue * @IfProfileValue} annotation. * <p>If the test is not annotated with {@code @IfProfileValue} it is * considered enabled. * <p>If a test is not enabled, this method will abort further evaluation * of the execution chain with a failed assumption; otherwise, this method * will simply evaluate the next {@link Statement} in the execution chain. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Method, Class) * @see org.junit.Assume */ @Override public void evaluate() throws Throwable { if (this.testMethod == null) { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(this.testClass)) { // Invoke assumeTrue() with false to avoid direct reference to JUnit's // AssumptionViolatedException which exists in two packages as of JUnit 4.12. Annotation ann = AnnotationUtils.findAnnotation(this.testClass, IfProfileValue.class); Assume.assumeTrue(String.format( "Profile configured via [%s] is not enabled in this environment for test class [%s].", ann, this.testClass.getName()), false); } } else { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(this.testMethod, this.testClass)) { // Invoke assumeTrue() with false to avoid direct reference to JUnit's // AssumptionViolatedException which exists in two packages as of JUnit 4.12. Assume.assumeTrue(String.format( "Profile configured via @IfProfileValue is not enabled in this environment for test method [%s].", this.testMethod), false); } } this.next.evaluate(); }
Example #4
Source File: SpringJUnit4ClassRunner.java From spring-analysis-note with MIT License | 5 votes |
/** * Return a description suitable for an ignored test class if the test is * disabled via {@code @IfProfileValue} at the class-level, and * otherwise delegate to the parent implementation. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) */ @Override public Description getDescription() { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) { return Description.createSuiteDescription(getTestClass().getJavaClass()); } return super.getDescription(); }
Example #5
Source File: SpringJUnit4ParameterizedClassRunner.java From tds with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Returns a description suitable for an ignored test class if the test is * disabled via <code>@IfProfileValue</code> at the class-level, and * otherwise delegates to the parent implementation. * * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) */ @Override public Description getDescription() { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) { return Description.createSuiteDescription(getTestClass().getJavaClass()); } return super.getDescription(); }
Example #6
Source File: SpringJUnit4ClassRunner.java From java-technology-stack with MIT License | 5 votes |
/** * Return a description suitable for an ignored test class if the test is * disabled via {@code @IfProfileValue} at the class-level, and * otherwise delegate to the parent implementation. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) */ @Override public Description getDescription() { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) { return Description.createSuiteDescription(getTestClass().getJavaClass()); } return super.getDescription(); }
Example #7
Source File: SpringJUnit4ClassRunner.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Return a description suitable for an ignored test class if the test is * disabled via {@code @IfProfileValue} at the class-level, and * otherwise delegate to the parent implementation. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) */ @Override public Description getDescription() { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) { return Description.createSuiteDescription(getTestClass().getJavaClass()); } return super.getDescription(); }
Example #8
Source File: SpringJUnit4ClassRunner.java From spring-analysis-note with MIT License | 3 votes |
/** * Check whether the test is enabled in the current execution environment. * <p>This prevents classes with a non-matching {@code @IfProfileValue} * annotation from running altogether, even skipping the execution of * {@code prepareTestInstance()} methods in {@code TestExecutionListeners}. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) * @see org.springframework.test.annotation.IfProfileValue * @see org.springframework.test.context.TestExecutionListener */ @Override public void run(RunNotifier notifier) { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) { notifier.fireTestIgnored(getDescription()); return; } super.run(notifier); }
Example #9
Source File: SpringJUnit4ParameterizedClassRunner.java From tds with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Check whether the test is enabled in the first place. This prevents * classes with a non-matching <code>@IfProfileValue</code> annotation * from running altogether, even skipping the execution of * <code>prepareTestInstance()</code> <code>TestExecutionListener</code> * methods. * * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) * @see org.springframework.test.annotation.IfProfileValue * @see org.springframework.test.context.TestExecutionListener */ @Override public void run(RunNotifier notifier) { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) { notifier.fireTestIgnored(getDescription()); return; } super.run(notifier); }
Example #10
Source File: SpringJUnit4ClassRunner.java From java-technology-stack with MIT License | 3 votes |
/** * Check whether the test is enabled in the current execution environment. * <p>This prevents classes with a non-matching {@code @IfProfileValue} * annotation from running altogether, even skipping the execution of * {@code prepareTestInstance()} methods in {@code TestExecutionListeners}. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) * @see org.springframework.test.annotation.IfProfileValue * @see org.springframework.test.context.TestExecutionListener */ @Override public void run(RunNotifier notifier) { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) { notifier.fireTestIgnored(getDescription()); return; } super.run(notifier); }
Example #11
Source File: SpringJUnit4ClassRunner.java From spring4-understanding with Apache License 2.0 | 3 votes |
/** * Check whether the test is enabled in the current execution environment. * <p>This prevents classes with a non-matching {@code @IfProfileValue} * annotation from running altogether, even skipping the execution of * {@code prepareTestInstance()} methods in {@code TestExecutionListeners}. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class) * @see org.springframework.test.annotation.IfProfileValue * @see org.springframework.test.context.TestExecutionListener */ @Override public void run(RunNotifier notifier) { if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) { notifier.fireTestIgnored(getDescription()); return; } super.run(notifier); }
Example #12
Source File: SpringJUnit4ClassRunner.java From spring-analysis-note with MIT License | 2 votes |
/** * Return {@code true} if {@link Ignore @Ignore} is present for the supplied * {@linkplain FrameworkMethod test method} or if the test method is disabled * via {@code @IfProfileValue}. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Method, Class) */ protected boolean isTestMethodIgnored(FrameworkMethod frameworkMethod) { Method method = frameworkMethod.getMethod(); return (method.isAnnotationPresent(Ignore.class) || !ProfileValueUtils.isTestEnabledInThisEnvironment(method, getTestClass().getJavaClass())); }
Example #13
Source File: SpringJUnit4ParameterizedClassRunner.java From tds with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Returns <code>true</code> if {@link Ignore @Ignore} is present for * the supplied {@link FrameworkMethod test method} or if the test method is * disabled via <code>@IfProfileValue</code>. * * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Method, Class) */ protected boolean isTestMethodIgnored(FrameworkMethod frameworkMethod) { Method method = frameworkMethod.getMethod(); return (method.isAnnotationPresent(Ignore.class) || !ProfileValueUtils.isTestEnabledInThisEnvironment(method, getTestClass().getJavaClass())); }
Example #14
Source File: SpringJUnit4ClassRunner.java From java-technology-stack with MIT License | 2 votes |
/** * Return {@code true} if {@link Ignore @Ignore} is present for the supplied * {@linkplain FrameworkMethod test method} or if the test method is disabled * via {@code @IfProfileValue}. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Method, Class) */ protected boolean isTestMethodIgnored(FrameworkMethod frameworkMethod) { Method method = frameworkMethod.getMethod(); return (method.isAnnotationPresent(Ignore.class) || !ProfileValueUtils.isTestEnabledInThisEnvironment(method, getTestClass().getJavaClass())); }
Example #15
Source File: SpringJUnit4ClassRunner.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Return {@code true} if {@link Ignore @Ignore} is present for the supplied * {@linkplain FrameworkMethod test method} or if the test method is disabled * via {@code @IfProfileValue}. * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Method, Class) */ protected boolean isTestMethodIgnored(FrameworkMethod frameworkMethod) { Method method = frameworkMethod.getMethod(); return (method.isAnnotationPresent(Ignore.class) || !ProfileValueUtils.isTestEnabledInThisEnvironment(method, getTestClass().getJavaClass())); }