[icedtea-web] RFC: add unit tests for the jnlp parser

Dr Andrew John Hughes ahughes at redhat.com
Wed Mar 30 15:08:57 PDT 2011


On 14:20 Wed 30 Mar     , Omair Majid wrote:
> On 03/30/2011 12:21 PM, Dr Andrew John Hughes wrote:
> > On 12:49 Fri 25 Mar     , Omair Majid wrote:
> >
> > snip...
> >
> >>> >  >
> >>> >  >  I seem to recall that there was an option to alter JUnit output by implementing
> >>> >  >  some class but my information is pretty out of date.
> >>> >  >
> >> >
> >> >  That's pretty much what I needed up doing. The only problem is
> >> >  licensing. What license is that code under? JUnit is under Common Public
> >> >  License and my custom code (attached) includes a few lines from JUnit
> >> >  itself.
> >> >
> > Oh, something that still uses CPL.
> >
> > There is a brief summary on Wikipedia:https://secure.wikimedia.org/wikipedia/en/wiki/Common_Public_License
> >
> > Basically, it's the predecessor to EPL, the license Eclipse is under.
> >
> > IANAL, but I don't see the problem with this.  The code is independent
> > from everything else in the codebase, isn't it?  So GPL
> > incompatibility isn't an issue (and we have the Classpath exception
> > anyway).  And it's a FOSS license so we can certainly include the
> > code.
> >
> 
> Ah, ok. I thought we wanted to only include code which is GPL-friendly 
> in IcedTea. If we are ok with adding independent code under other 
> license, it certainly makes this a non-issue.
> 

It has to be FOSS.  I don't see a reason for GPL compatibility in
completely independent chunks of code; that's quite a strong
requirement OpenJDK itself is a hodge-podge of stuff, allowed by the
ASSEMBLY_EXCEPTION.

> > What JUnit code is included?  Is it marked?
> >
> 
> Please see the attached patch. I havent marked it, but almost all the 
> code in CommandLine.java is based on JUnit code. The 
> LessVerboseTextListener.java implements JUnit interfaces, but it is 
> written from scratch.
> 

There does need to be something in there such as:

// Based on code from X (C) Y

You're also lacking license headers.

snip...

> 
> >> >  I would like to see less things in-tree (/me is looking at NanoXML), not
> >> >  more.
> >> >
> > How is the NanoXML issue progressing?  It would be good to have a status update
> > on things and the progress towards the various releases of IcedTea-Web now 1.0
> > is done.
> >
> 
> Sorry, I must have forgotten to make a note of this. Generally I try and 
> keep http://icedtea.classpath.org/wiki/IcedTea-Web#Release_Plans 
> updated. 

I don't check the wiki regularly anyway. I'd expect stuff to be discussed on the
mailing list then documented on the wiki.

> Anyway, it's mostly done. I wrote these parser unit tests to 
> test that my NanoXML changes did not break anything. I will clean up 
> that patch and post it after these unit tests are committed (so we can 
> see any regressions). Assuming Deepak is fine with it, it can go in 
> before 1.1 is released.
> 

Yeah I think we (mainly Deepak as maintainer) need to define clearly where we draw
a line under 1.1.

snip..
> 
> I should have elaborated more. JUnit/TestNG (and possibly others) are 
> just fine for developers. The problem here is that we want to generate 
> buildbot-readable test results. We can do that by writing a custom 
> junit-output formatter (like in the attached patch), by transforming 
> testng's xml output or by transforming junit's xml output. Unfortunately 
> the only way of getting junit to create xml output is through ant. Junit 
> itself has no option (at least nothing that I could see) that generates 
> output in xml format. If it is okay to use the custom junit output 
> formatter, than we dont need ant. Actually, if we dont care about the 
> buildbot, then we dont need the custom output formatter or any xml 
> processing at all.
> 

Ok, so whoever wrote the JUnit XML outputter introduced some odd Ant dependency
that's unnecessary.  Got you.

> > Ant massively overcomplicates things, but I have no idea of the availability
> > of the various dependencies for testng or their licenses.
> >
> > Can you provide some of this info?
> >
> 
> Sure. TestNG is licensed under Apache 2.0. Its dependencies are QDox 
> (Apache 2.0) and Bean Shell (Sun Public License or LGPL).
> 
> TestNG (and its dependencies) are available in a number of Linux 
> distributions, including Debian (squeeze, wheezy and sid), Fedora (>= 
> 13), Gentoo (java-experimental overlay), Mageia, Mandriva (, openSUSE 
> (>= 11.2), and Ubuntu (>= 9.10). It's not available in Arch Linux, and 
> Slackware (and possibly other distributions).
> 

It's in Gentoo's java-overlay tree (the same place I develop IcedTea ebuilds
and have commit access to), and this is the hideous dependency tree it has:

[ebuild  N     ] dev-java/commons-logging-1.1.1  USE="-avalon-framework -avalon-logkit -doc -log4j -servletapi -source -test" 187 kB [0]
[ebuild  N     ] dev-java/ant-apache-log4j-1.8.1  0 kB [0]
[ebuild  N     ] dev-java/ant-swing-1.8.1  0 kB [0]
[ebuild  N     ] dev-java/ant-apache-bcel-1.8.1  0 kB [0]
[ebuild  N     ] dev-java/ant-apache-resolver-1.8.1  0 kB [0]
[ebuild  N     ] dev-java/ant-apache-oro-1.8.1  0 kB [0]
[ebuild  N     ] dev-java/jdepend-2.9-r4  USE="-doc -source" 296 kB [0]
[ebuild  N     ] dev-java/jzlib-1.0.7-r1  USE="-doc -source" 50 kB [0]
[ebuild  N     ] dev-java/commons-net-1.4.1-r1  USE="-doc -examples -source" 224 kB [0]
[ebuild  N     ] dev-java/jakarta-regexp-1.4-r1  USE="-doc -source" 135 kB [0]
[ebuild  N     ] dev-java/sun-jaf-1.1.1  USE="-doc -source" 123 kB [0]
[ebuild  N     ] java-virtuals/jaf-1.1-r1  0 kB [0]
[ebuild  N     ] dev-java/ant-commons-logging-1.8.1  0 kB [0]
[ebuild  N     ] dev-java/ant-apache-regexp-1.8.1  0 kB [0]
[ebuild  N     ] dev-java/ant-commons-net-1.8.1  0 kB [0]
[ebuild  N     ] dev-java/ant-jdepend-1.8.1  0 kB [0]
[ebuild  N     ] dev-java/jsch-0.1.44  USE="zlib -doc -examples -source" 278 kB [0]
[ebuild  N     ] dev-java/bsf-2.4.0-r1  USE="javascript python -doc -examples -source -tcl" 293 kB [0]
[ebuild  N     ] dev-java/sun-javamail-1.4.3  USE="-doc -source" 1,148 kB [0]
[ebuild  N     ] dev-java/ant-apache-bsf-1.8.1  USE="javascript python -tcl" 0 kB [0]
[ebuild  N     ] dev-java/ant-jsch-1.8.1  0 kB [0]
[ebuild  N     ] java-virtuals/javamail-1.0-r1  0 kB [0]
[ebuild  N     ] dev-java/ant-javamail-1.8.1  0 kB [0]
[ebuild  N     ] dev-java/ant-1.8.1  USE="X antlr bcel bsf commonslogging commonsnet javamail jdepend jsch log4j oro regexp resolver -jai -jmf -testutil" 0 kB [0]
[ebuild  N     ] dev-java/testng-5.2  USE="-doc -source" 2,605 kB [1]

I think most of that is due to a bad dependency on the whole of Ant though.  Not sure how much
of Ant it actually needs.

> JUnit is licensed under Common Public License v.10.
> 
> JUnit is available in all the distributions listed above - including 
> Arch Linux and Slackware.
> 
> >> >  My custom runner:
> >> >  Passed: net.sourceforge.jnlp.ParserBasic.testResourcesJar
> >> >  Passed: net.sourceforge.jnlp.ParserBasic.testResourcesExtensions
> >> >  Passed: net.sourceforge.jnlp.ParserBasic.testResourcesProperty
> >> >  [snip]
> >> >  FAILED: testUnquotedAttributes(net.sourceforge.jnlp.ParserMalformedXml)
> >> >  Invalid XML document syntax.
> >> >  Test results: passed: 23; failed: 4; ignored: 0
> >> >
> >> >  I suppose using plain JUnit is fine; it just wont have pretty output
> >> >  suitable for buildbot.
> >> >
> > The custom runner looks fine.  What's the problem?
> >
> 
> Other than my licensing concerns (CPL in a GPL-friendly repository), 
> nothing.
> 

Great.

I await the new patch.

> Thanks,
> Omair

> diff -r d3edae4807f0 tests/junit-runner/CommandLine.java
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/tests/junit-runner/CommandLine.java	Tue Mar 08 18:12:16 2011 -0500
> @@ -0,0 +1,42 @@
> +import java.util.ArrayList;
> +import java.util.List;
> +
> +import org.junit.internal.JUnitSystem;
> +import org.junit.internal.RealSystem;
> +import org.junit.runner.JUnitCore;
> +import org.junit.runner.Result;
> +import org.junit.runner.notification.Failure;
> +import org.junit.runner.notification.RunListener;
> +
> +public class CommandLine extends JUnitCore {
> +
> +    public static void main(String... args) {
> +        runMainAndExit(new RealSystem(), args);
> +    }
> +
> +    public static void runMainAndExit(JUnitSystem system, String... args) {
> +        new CommandLine().runMain(system, args);
> +        system.exit(0);
> +    }
> +
> +    @Override
> +    public Result runMain(JUnitSystem system, String... args) {
> +        List<Class<?>> classes= new ArrayList<Class<?>>();
> +        List<Failure> missingClasses= new ArrayList<Failure>();
> +        for (String each : args) {
> +            try {
> +                classes.add(Class.forName(each));
> +            } catch (ClassNotFoundException e) {
> +                system.out().println("ERROR: Could not find class: " + each);
> +            }
> +        }
> +        RunListener listener= new LessVerboseTextListener(system);
> +        addListener(listener);
> +        Result result= run(classes.toArray(new Class[0]));
> +        for (Failure each : missingClasses) {
> +            result.getFailures().add(each);
> +        }
> +        return result;
> +    }
> +
> +}
> diff -r d3edae4807f0 tests/junit-runner/LessVerboseTextListener.java
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/tests/junit-runner/LessVerboseTextListener.java	Tue Mar 08 18:12:16 2011 -0500
> @@ -0,0 +1,44 @@
> +import java.io.PrintStream;
> +
> +import org.junit.internal.JUnitSystem;
> +import org.junit.runner.Description;
> +import org.junit.runner.Result;
> +import org.junit.runner.notification.Failure;
> +import org.junit.runner.notification.RunListener;
> +
> +public class LessVerboseTextListener extends RunListener {
> +
> +    private PrintStream writer;
> +    private boolean testFailed = false;
> +
> +    public LessVerboseTextListener(JUnitSystem system) {
> +        writer= system.out();
> +    }
> +
> +    @Override
> +    public void testStarted(Description description) throws Exception {
> +        testFailed = false;
> +    }
> +
> +    @Override
> +    public void testFailure(Failure failure) {
> +        testFailed = true;
> +        writer.println("FAILED: " + failure.getTestHeader() + " " + failure.getMessage());
> +    }
> +
> +    @Override
> +    public void testFinished(org.junit.runner.Description description) throws Exception {
> +        if (!testFailed) {
> +            writer.println("Passed: " + description.getClassName() + "." + description.getMethodName());
> +        }
> +    }
> +
> +    @Override
> +    public void testRunFinished(Result result) throws Exception {
> +        int passed = result.getRunCount() - result.getFailureCount() - result.getIgnoreCount();
> +        int failed = result.getFailureCount();
> +        int ignored = result.getIgnoreCount();
> +        writer.println("Test results: passed: " + passed + "; failed: " + failed + "; ignored: " + ignored);
> +    }
> +
> +}


-- 
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and IcedTea
http://www.gnu.org/software/classpath
http://icedtea.classpath.org
PGP Key: F5862A37 (https://keys.indymedia.org/)
Fingerprint = EA30 D855 D50F 90CD F54D  0698 0713 C3ED F586 2A37



More information about the distro-pkg-dev mailing list