Re: Issue with Junit5 test framework. Any idea?

2021-04-10 Thread Emmanuel Lécharny
Hi! FTR, I now have all tests passing on core-integration (and every module before this one). I have some failure on Protocol Kerberos tests, but this is not related. Keep going... On 04/04/2021 11:47, Emmanuel Lécharny wrote: Hi ! I'm fighting with a piece of our test framework that

Re: Issue with Junit5 test framework. Any idea?

2021-04-05 Thread Emmanuel Lécharny
Okie, super, I have my first couple of tests working ! There is a lot of refactoring to do yet, but at least, I'm not blocked anymore :-) Thanks Stefan, you were super helpful ! On 05/04/2021 06:42, Emmanuel Lécharny wrote: On 04/04/2021 23:17, Emmanuel Lécharny wrote: Hmmm, I think

Re: Issue with Junit5 test framework. Any idea?

2021-04-04 Thread Emmanuel Lécharny
On 04/04/2021 23:17, Emmanuel Lécharny wrote: Hmmm, I think there must be a side effect. The following line : testClass.getField( "service" )... can't return the reference of the service field, which is not present in the LdapConnectionTest class, but is present in the

Re: Issue with Junit5 test framework. Any idea?

2021-04-04 Thread Emmanuel Lécharny
I would add that in my case, when the beforeAll callback is called, we don't have yet an instance of the test class, which leads to a NPE later when we try to set the field's value - which is expected -. FTR here is the extension I'm using: /* * Licensed to the Apache Software Foundation

Re: Issue with Junit5 test framework. Any idea?

2021-04-04 Thread Emmanuel Lécharny
Hmmm, I think there must be a side effect. The following line : testClass.getField( "service" )... can't return the reference of the service field, which is not present in the LdapConnectionTest class, but is present in the AbstractLdapTestUnit parent class. And getField() does not return

Re: Issue with Junit5 test framework. Any idea?

2021-04-04 Thread Stefan Seelmann
Here is a quick and dirty demo which "works on my machine" ;) https://github.com/apache/directory-server/commit/d10cf254dca9317b54dd39489ed249098a984436 On 4/4/21 6:56 PM, Emmanuel Lécharny wrote: > Sadly, that does not work :/ > > The test class is not yet existing when we call

Re: Issue with Junit5 test framework. Any idea?

2021-04-04 Thread Emmanuel Lécharny
Sadly, that does not work :/ The test class is not yet existing when we call testClass.getField( "service" ).set( null, new DefaultDirectoryService() ) so I get a NPE on the set. There seems to be a internal Junit5 mechanism that allow you to get the field to set but you can't inject some

Re: Issue with Junit5 test framework. Any idea?

2021-04-04 Thread Emmanuel Lécharny
Ah, cool, have'nt thought about this solution. Will try that ! Thanks Stefan! On 04/04/2021 14:00, Stefan Seelmann wrote: Actually with the BeforeAllCallback we can get the test class from the ExtensionContext and set the static fields via reflection: public class BeforeAllInjector

Re: Issue with Junit5 test framework. Any idea?

2021-04-04 Thread Stefan Seelmann
Actually with the BeforeAllCallback we can get the test class from the ExtensionContext and set the static fields via reflection: public class BeforeAllInjector implements BeforeAllCallback { @Override public void beforeAll( ExtensionContext context ) throws Exception { Class

Re: Issue with Junit5 test framework. Any idea?

2021-04-04 Thread Stefan Seelmann
Instead of BeforeAll it seems we can use TestInstancePostProcessor which postProcessTestInstance() method signature includes the test instance: public class BeforeAllInjector implements TestInstancePostProcessor { @Override public void postProcessTestInstance( Object testInstance,

Issue with Junit5 test framework. Any idea?

2021-04-04 Thread Emmanuel Lécharny
Hi ! I'm fighting with a piece of our test framework that worked well with Junit4, not so much with Junit5. In Junit4, we were using Rule and ClassRule to declare some DirectoryService used in tests (typically, if we want to test some features, we start with a DS creation that will be