Hi,
I wrote some lines of code in order to demonstrate my idea for BC tests.


The idea is:
- use Maven Resolver to download code
- create a ClassLoader which loads classes from such downloaded artifacts
- use a scripting language, like Groovy (which is loosely typed) to write
tests (Groovy is really like Java so it is very easy for a Java programmer
to write Java code  and let Groovy run it)

Using separate classloaders lets us to have completely different versions
of the same code, like a JavaEE container works.



This is an example

https://github.com/eolivelli/mavendemo/blob/master/src/test/groovy/resolver/demo/ResolverJavaExampleTest.groovy

Code of tests will look like this:

    @Test
    public void hello() throws Exception {
        ProgramVersion program410 =
ProgramVersion.resolve("org.apache.bookkeeper:bookkeeper-server:4.1.0");
        def clientconfig410 =
program410.newInstance("org.apache.bookkeeper.conf.ClientConfiguration");
        def bkc410 =
program410.newInstance("org.apache.bookkeeper.client.BookKeeper",
clientconfig);
        System.out.println("bkc410:" + bkc410);


        ProgramVersion program451 =
ProgramVersion.resolve("org.apache.bookkeeper:bookkeeper-server:4.5.1");
        def clientconfig451 =
program451.newInstance("org.apache.bookkeeper.conf.ClientConfiguration");
        def bkc451 =
program451.newInstance("org.apache.bookkeeper.client.BookKeeper",
clientconfig);
        System.out.println("bkc451:" + bkc451);
}

I you like the idea I can make a real test cases


Enrico

Reply via email to