You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by km...@apache.org on 2010/07/10 05:58:58 UTC
svn commit: r962754 - in
/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules:
InvokeMethod.java Keys.java ValidationRunner.java
Author: kmalhi
Date: Sat Jul 10 03:58:58 2010
New Revision: 962754
URL: http://svn.apache.org/viewvc?rev=962754&view=rev
Log:
Added support to run tests which do not want to throw any ValidationFailureException i.e. sometimes you want to test and make sure that there is no validation failure. You can achieve this now by writing a test and annotating it with an empty @Keys.
Modified:
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvokeMethod.java
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/Keys.java
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/ValidationRunner.java
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvokeMethod.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvokeMethod.java?rev=962754&r1=962753&r2=962754&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvokeMethod.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvokeMethod.java Sat Jul 10 03:58:58 2010
@@ -29,6 +29,7 @@ import org.apache.openejb.assembler.clas
import org.apache.openejb.assembler.classic.TransactionServiceInfo;
import org.apache.openejb.config.ConfigurationFactory;
import org.apache.openejb.config.ValidationFailedException;
+import org.apache.openejb.config.ValidationFailure;
import org.apache.openejb.jee.EjbJar;
import org.apache.openejb.util.Join;
import org.junit.runners.model.FrameworkMethod;
@@ -65,9 +66,18 @@ public class InvokeMethod extends Statem
EjbJar ejbJar = (EjbJar) obj;
try {
assembler.createApplication(config.configureApplication(ejbJar));
- fail("A ValidationFailedException should have been thrown");
+ if (!expectedKeys.isEmpty()) {
+ fail("A ValidationFailedException should have been thrown");
+ }
} catch (ValidationFailedException vfe) {
- assertFailures(expectedKeys, vfe);
+ if (!expectedKeys.isEmpty()) {
+ assertFailures(expectedKeys, vfe);
+ } else {
+ for (ValidationFailure failure : vfe.getFailures()) {
+ System.out.println("failure = " + failure.getMessageKey());
+ }
+ fail("There should be no validation failures");
+ }
}
}
tearDown();
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/Keys.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/Keys.java?rev=962754&r1=962753&r2=962754&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/Keys.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/Keys.java Sat Jul 10 03:58:58 2010
@@ -27,5 +27,5 @@ import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Keys {
- Key[] value();
+ Key[] value() default {};
}
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/ValidationRunner.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/ValidationRunner.java?rev=962754&r1=962753&r2=962754&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/ValidationRunner.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/ValidationRunner.java Sat Jul 10 03:58:58 2010
@@ -35,7 +35,8 @@ import org.junit.runners.model.Statement
* the application 6. This will kick off validation and this Runner will catch ValidationFailureException and make sure that all the keys specified in the @Keys annotation show up
* in the ValidationFailureException 7. If the keys listed in the @Keys annotation match the keys found in the ValidationFailureException, the test passes, else the test fails. 8.
* This Runner also validates that the keys specified in the @Keys annotation are also available in the org.apache.openejb.config.rules.Messages.properties file. If the key is not
- * found, then the Runner throws and exception resulting in your test case not being allowed to run.
+ * found, then the Runner throws and exception resulting in your test case not being allowed to run. Sometimes you want to write a test where you do not want any
+ * ValidationFailureException to be thrown, in those scenarios, simply annotate your test with @Keys and do not specify any @Key in it
*/
public class ValidationRunner extends BlockJUnit4ClassRunner {
public ValidationRunner(Class<?> klass) throws InitializationError {