yes, this is just an example, and I have borrowed Arquillian stuff, but it is really easy to use directly Maven Resolver API, I am using it in production (but now I am at home in vacation, so I have not access to my work laptop)
most interesting parts: - make it configurable to use local repo - make it configurable to set the remote repo - add a whitelist of groupIds, to prevent tests to download and execute code in user space without any minimal control Enrico Enrico 2018-01-03 15:39 GMT+01:00 Ivan Kelly <iv...@apache.org>: > Does the Maven resolver download missing dependencies? > > -Ivan > > On Wed, Jan 3, 2018 at 3:35 PM, Ivan Kelly <iv...@apache.org> wrote: > > heh, look at what I just pushed to https://github.com/apache/ > bookkeeper/pull/930 > > > > -Ivan > > > > On Wed, Jan 3, 2018 at 3:34 PM, Enrico Olivelli <eolive...@gmail.com> > wrote: > >> 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 >