aboutsummaryrefslogtreecommitdiffstats
path: root/tests/junit-runner
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2012-12-20 17:10:38 +0100
committerJiri Vanek <[email protected]>2012-12-20 17:10:38 +0100
commita0b5dd482361349be15b1787103eda7930e59adb (patch)
tree13869516a83e0936b4ba0be7e25e3019d1a3f34c /tests/junit-runner
parentdbff9e3460157d99cfa83c5cdb39753dbae1228d (diff)
Added and applied Remote annotation, added Remote tests.
Diffstat (limited to 'tests/junit-runner')
-rw-r--r--tests/junit-runner/JunitLikeXmlOutputListener.java21
-rw-r--r--tests/junit-runner/LessVerboseTextListener.java38
2 files changed, 44 insertions, 15 deletions
diff --git a/tests/junit-runner/JunitLikeXmlOutputListener.java b/tests/junit-runner/JunitLikeXmlOutputListener.java
index fe17f19..24cfb30 100644
--- a/tests/junit-runner/JunitLikeXmlOutputListener.java
+++ b/tests/junit-runner/JunitLikeXmlOutputListener.java
@@ -23,6 +23,7 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import net.sourceforge.jnlp.annotations.Bug;
import net.sourceforge.jnlp.annotations.KnownToFail;
+import net.sourceforge.jnlp.annotations.Remote;
import org.junit.internal.JUnitSystem;
@@ -49,6 +50,7 @@ public class JunitLikeXmlOutputListener extends RunListener {
private static final String BUGS = "bugs";
private static final String BUG = "bug";
private static final String K2F = "known-to-fail";
+ private static final String REMOTE = "remote";
private static final String TEST_NAME_ATTRIBUTE = "name";
private static final String TEST_TIME_ATTRIBUTE = "time";
private static final String TEST_IGNORED_ATTRIBUTE = "ignored";
@@ -172,6 +174,7 @@ public class JunitLikeXmlOutputListener extends RunListener {
double testTimeSeconds = ((double) testTime) / 1000d;
testDone(description, testTime, testTimeSeconds, false);
}
+
private void testDone(Description description, long testTime, double testTimeSeconds, boolean ignored) throws Exception {
Class testClass = null;
@@ -197,16 +200,14 @@ public class JunitLikeXmlOutputListener extends RunListener {
if (ignored){
testcaseAtts.put(TEST_IGNORED_ATTRIBUTE, Boolean.TRUE.toString());
}
- KnownToFail k2f=null;
- try {
- if (testClass != null && testMethod != null) {
- k2f = testMethod.getAnnotation(KnownToFail.class);
- if (k2f != null) {
- testcaseAtts.put(K2F, Boolean.TRUE.toString());
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
+ KnownToFail k2f = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), KnownToFail.class);
+ Remote remote = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), Remote.class);
+ if (k2f != null) {
+ testcaseAtts.put(K2F, Boolean.TRUE.toString());
+ }
+ if (remote != null) {
+ testcaseAtts.put(REMOTE, Boolean.TRUE.toString());
+
}
openElement(TEST_ELEMENT, testcaseAtts);
if (testFailed != null) {
diff --git a/tests/junit-runner/LessVerboseTextListener.java b/tests/junit-runner/LessVerboseTextListener.java
index 828722b..8b2ccce 100644
--- a/tests/junit-runner/LessVerboseTextListener.java
+++ b/tests/junit-runner/LessVerboseTextListener.java
@@ -6,8 +6,10 @@
* http://www.eclipse.org/legal/cpl-v10.html
*/
import java.io.PrintStream;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import net.sourceforge.jnlp.annotations.KnownToFail;
+import net.sourceforge.jnlp.annotations.Remote;
import org.junit.internal.JUnitSystem;
import org.junit.runner.Description;
@@ -37,6 +39,7 @@ public class LessVerboseTextListener extends RunListener {
public void testIgnored(Description description) throws Exception {
writer.println("Ignored: " + description.getClassName() + "." + description.getMethodName());
printK2F(writer, null, description);
+ printRemote(writer, description);
}
@@ -45,6 +48,7 @@ public class LessVerboseTextListener extends RunListener {
testFailed = true;
writer.println("FAILED: " + failure.getTestHeader() + " " + failure.getMessage());
printK2F(writer,true,failure.getDescription());
+ printRemote(writer, failure.getDescription());
}
@Override
@@ -52,6 +56,7 @@ public class LessVerboseTextListener extends RunListener {
if (!testFailed) {
writer.println("Passed: " + description.getClassName() + "." + description.getMethodName());
printK2F(writer,false,description);
+ printRemote(writer, description);
}
}
@@ -93,18 +98,22 @@ public class LessVerboseTextListener extends RunListener {
}
}
- public static KnownToFail getK2F(Description description) {
+
+ public static <T extends Annotation> T getAnnotation(Class q, String methodName, Class<T> a) {
try {
- Class q = description.getTestClass();
if (q != null) {
- String qs = description.getMethodName();
+ T rem = (T) q.getAnnotation(a);
+ if (rem != null) {
+ return rem;
+ }
+ String qs = methodName;
if (qs.contains(" - ")) {
qs = qs.replaceAll(" - .*", "");
}
Method qm = q.getMethod(qs);
if (qm != null) {
- KnownToFail k2f = qm.getAnnotation(KnownToFail.class);
- return k2f;
+ rem = qm.getAnnotation(a);
+ return rem;
}
}
@@ -114,4 +123,23 @@ public class LessVerboseTextListener extends RunListener {
return null;
}
+ public static KnownToFail getK2F(Description description) {
+ return (KnownToFail) getAnnotation(description.getTestClass(), description.getMethodName(), KnownToFail.class);
+ }
+
+ public static Remote getRemote(Description description) {
+ return (Remote) getAnnotation(description.getTestClass(), description.getMethodName(), Remote.class);
+
+ }
+
+ private void printRemote(PrintStream writer, Description description) {
+ try {
+ Remote rem = getRemote(description);
+ if (rem != null) {
+ writer.println(" - This test is running remote content, note that failures may be caused by broken taget application or connection");
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
}