Ignore:
Timestamp:
Sep 24, 2014, 9:34:21 PM (11 years ago)
Author:
dmik
Message:

icedtea-web: Merge version 1.5.1 from vendor to trunk.

Location:
trunk/icedtea-web/tests/junit-runner
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/icedtea-web/tests/junit-runner/CommandLine.java

    r418 r429  
    2727    public static void runMainAndExit(JUnitSystem system, String... args) {
    2828        new CommandLine().runMain(system, args);
    29         system.exit(0);
     29        System.exit(0);
    3030    }
    3131
    32     @Override
    3332    public Result runMain(JUnitSystem system, String... args) {
    3433        List<Class<?>> classes = new ArrayList<Class<?>>();
     
    4746        RunListener listener = new LessVerboseTextListener(system);
    4847        addListener(listener);
    49         Result result = run(classes.toArray(new Class[0]));
     48        Result result = run(classes.toArray(new Class<?>[0]));
    5049        for (Failure each : missingClasses) {
    5150            result.getFailures().add(each);
  • trunk/icedtea-web/tests/junit-runner/JunitLikeXmlOutputListener.java

    r418 r429  
    2121import java.util.Map.Entry;
    2222import java.util.Set;
     23import java.util.Arrays;
    2324import java.util.concurrent.TimeUnit;
    2425import net.sourceforge.jnlp.annotations.Bug;
    2526import net.sourceforge.jnlp.annotations.KnownToFail;
     27import net.sourceforge.jnlp.annotations.Remote;
     28import net.sourceforge.jnlp.browsertesting.Browsers;
    2629
    2730
     
    5053    private static final String BUG = "bug";
    5154    private static final String K2F = "known-to-fail";
     55    private static final String REMOTE = "remote";
    5256    private static final String TEST_NAME_ATTRIBUTE = "name";
    5357    private static final String TEST_TIME_ATTRIBUTE = "time";
     
    7781    private class ClassStat {
    7882
    79         Class c;
     83        Class<?> c;
    8084        int total;
    8185        int failed;
     
    173177        testDone(description, testTime, testTimeSeconds, false);
    174178    }
    175 
     179   
     180
     181    @SuppressWarnings("unchecked")
    176182    private void testDone(Description description, long testTime, double testTimeSeconds, boolean ignored) throws Exception {
    177         Class testClass = null;
     183        Class<?> testClass = null;
    178184        Method testMethod = null;
    179185        try {
     
    198204            testcaseAtts.put(TEST_IGNORED_ATTRIBUTE, Boolean.TRUE.toString());
    199205        }
    200         KnownToFail k2f=null;
    201         try {
    202             if (testClass != null && testMethod != null) {
    203                 k2f = testMethod.getAnnotation(KnownToFail.class);
    204                 if (k2f != null) {
    205                     testcaseAtts.put(K2F, Boolean.TRUE.toString());
    206                 }
    207             }
    208         } catch (Exception ex) {
    209             ex.printStackTrace();
     206        KnownToFail k2f = LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), KnownToFail.class);
     207        boolean thisTestIsK2F = false;
     208        Remote remote =  LessVerboseTextListener.getAnnotation(testClass, testMethod.getName(), Remote.class);
     209        if (k2f != null) {
     210            //determine if k2f in the current browser
     211            //??
     212            Browsers[] br = k2f.failsIn();
     213            if(0 == br.length){//the KnownToFail annotation without optional parameter
     214                thisTestIsK2F = true;
     215            }else{
     216                for(Browsers b : br){
     217                    if(description.toString().contains(b.toString())){
     218                        thisTestIsK2F = true;
     219                    }
     220                }
     221            }
     222        }
     223        if( thisTestIsK2F ) testcaseAtts.put(K2F, Boolean.TRUE.toString());
     224        if (remote != null) {
     225            testcaseAtts.put(REMOTE, Boolean.TRUE.toString());
     226
    210227        }
    211228        openElement(TEST_ELEMENT, testcaseAtts);
    212229        if (testFailed != null) {
    213             if (k2f != null) {
     230            if (thisTestIsK2F) {
    214231                failedK2F++;
    215232            }
     
    226243            writeElement(TEST_ERROR_ELEMENT, testFailed.getTrace(), errorAtts);
    227244        } else {
    228             if (k2f != null) {
     245            if (thisTestIsK2F) {
    229246                if (ignored) {
    230247                    ignoredK2F++;
     
    265282        }
    266283        classStat.total++;
    267         if (k2f != null) {
     284        if (thisTestIsK2F) {
    268285            classStat.totalK2F++;
    269286        }
     
    272289            if (ignored) {
    273290                classStat.ignored++;
    274                 if (k2f != null) {
     291                if (thisTestIsK2F) {
    275292                    classStat.ignoredK2F++;
    276293                }
    277294            } else {
    278295                classStat.passed++;
    279                 if (k2f != null) {
     296                if (thisTestIsK2F) {
    280297                    classStat.passedK2F++;
    281298                }
     
    283300        } else {
    284301            classStat.failed++;
    285             if (k2f != null) {
     302            if (thisTestIsK2F) {
    286303                classStat.failedK2F++;
    287304            }
     
    290307
    291308    @Override
     309    @SuppressWarnings("unchecked")
    292310    public void testRunFinished(Result result) throws Exception {
    293311
     
    320338                Bug b = null;
    321339                if (entry.getValue().c != null) {
    322                     b = (Bug) entry.getValue().c.getAnnotation(Bug.class);
     340                    b = entry.getValue().c.getAnnotation(Bug.class);
    323341                }
    324342                if (b != null) {
  • trunk/icedtea-web/tests/junit-runner/LessVerboseTextListener.java

    r418 r429  
    77 */
    88import java.io.PrintStream;
     9import java.lang.annotation.Annotation;
    910import java.lang.reflect.Method;
    1011import net.sourceforge.jnlp.annotations.KnownToFail;
     12import net.sourceforge.jnlp.annotations.Remote;
     13import net.sourceforge.jnlp.browsertesting.Browsers;
    1114
    1215import org.junit.internal.JUnitSystem;
     
    3841        writer.println("Ignored: " + description.getClassName() + "." + description.getMethodName());
    3942        printK2F(writer, null, description);
     43        printRemote(writer, description);
    4044    }
    4145
     
    4650        writer.println("FAILED: " + failure.getTestHeader() + " " + failure.getMessage());
    4751        printK2F(writer,true,failure.getDescription());
     52        printRemote(writer, failure.getDescription());
    4853    }
    4954
     
    5358            writer.println("Passed: " + description.getClassName() + "." + description.getMethodName());
    5459            printK2F(writer,false,description);
     60            printRemote(writer, description);
    5561        }
    5662    }
     
    7076        try {
    7177            KnownToFail k2f = getK2F(description);
    72             if (k2f != null) {
     78            boolean thisTestIsK2F = false;
     79            if (k2f != null){
     80                //determine if k2f in the current browser
     81                Browsers[] br = k2f.failsIn();
     82                if(0 == br.length){ //@KnownToFail with default optional parameter failsIn={}
     83                    thisTestIsK2F = true;
     84                }else{
     85                    for(Browsers b : br){
     86                        if(description.toString().contains(b.toString())){
     87                            thisTestIsK2F = true;
     88                        }
     89                    }
     90                }
     91            }
     92
     93            if( thisTestIsK2F ){
    7394                totalK2F++;
    7495                if (failed != null) {
     
    94115    }
    95116
    96     public static  KnownToFail getK2F(Description description) {
     117
     118    @SuppressWarnings("unchecked")
     119    public static <T extends Annotation> T getAnnotation(Class<?> q, String methodName, Class<T> a) {
    97120        try {
    98             Class q = description.getTestClass();
    99121            if (q != null) {
    100                 String qs = description.getMethodName();
     122                T rem = q.getAnnotation(a);
     123                if (rem != null) {
     124                    return rem;
     125                }
     126                String qs = methodName;
    101127                if (qs.contains(" - ")) {
    102128                    qs = qs.replaceAll(" - .*", "");
     
    104130                Method qm = q.getMethod(qs);
    105131                if (qm != null) {
    106                     KnownToFail k2f = qm.getAnnotation(KnownToFail.class);
    107                     return k2f;
     132                    rem = qm.getAnnotation(a);
     133                    return rem;
    108134
    109135                }
     
    115141    }
    116142
     143    public static KnownToFail getK2F(Description description) {
     144        return getAnnotation(description.getTestClass(), description.getMethodName(), KnownToFail.class);
     145    }
     146
     147    public static Remote getRemote(Description description) {
     148        return getAnnotation(description.getTestClass(), description.getMethodName(), Remote.class);
     149
     150    }
     151
     152    private void printRemote(PrintStream writer, Description description) {
     153        try {
     154            Remote rem = getRemote(description);
     155            if (rem != null) {
     156                writer.println(" - This test is running remote content, note that failures may be caused by broken target application or connection");
     157            }
     158        } catch (Exception ex) {
     159            ex.printStackTrace();
     160        }
     161    }
    117162}
Note: See TracChangeset for help on using the changeset viewer.