Git Product home page Git Product logo

Comments (15)

timothyjward avatar timothyjward commented on June 3, 2024

Are you able to provide more of an example? How/where is the annotation being used?

from osgi-test.

laeubi avatar laeubi commented on June 3, 2024
public TestClass {
  
 @Test
 @WithFactoryConfiguration(factoryPid = "org.eclipse.daanse.ws.server.ServerRuntime", name="testme", properties = {
  @Property(key="Hello", value="World")
  })
  public void testMe() {

  }
}

from osgi-test.

timothyjward avatar timothyjward commented on June 3, 2024

Aren't you missing the

@ExtendWith(ConfigurationExtension.class)
public TestClass {
...
}

from osgi-test.

laeubi avatar laeubi commented on June 3, 2024

I don't miss it personally and @WithFactoryConfiguration is annotated with @ExtendWith(ConfigurationExtension.class) and @Inherited already.

But even if someone is missing that, it should clearly state that in the error message and not run into a NPE...

from osgi-test.

laeubi avatar laeubi commented on June 3, 2024

Also https://junit.org/junit5/docs/current/user-guide/#extensions-keeping-state says:

Usually, an extension is instantiated only once. So the question becomes relevant: How do you keep the state from one invocation of an extension to the next? The ExtensionContext API provides a Store exactly for this purpose.

so using a static singleton seems wrong here anyways.

from osgi-test.

timothyjward avatar timothyjward commented on June 3, 2024

But even if someone is missing that, it should clearly state that in the error message and not run into a NPE...

Absolutely - I just want to be sure that the tests work if you do add the extension directly, or whether there's a more serious issue with the extension. I've found that sometimes the @ExtendWith is necessary (with other extensions too) as the lifecycle for the location (in this case a method) is discovered too late for some of the processing that is needed.

from osgi-test.

laeubi avatar laeubi commented on June 3, 2024

Yes it works when I manually add the annotation, but as far as I understand @Inherited was meant to not require this. But as this access the method and is supposed to clear the created config after method exit, I also don't see why such a global context would be required and the extension seems to be called. It is just that beforeAll is not called (obviously because it is method scoped). So blockinghandler might be extracted from the context, so if the parent has already one use that and if not create a local one?

from osgi-test.

timothyjward avatar timothyjward commented on June 3, 2024

Yes it works when I manually add the annotation

That's good, so it's not a total showstopper.

It is just that beforeAll is not called (obviously because it is method scoped). So blockinghandler might be extracted from the context, so if the parent has already one use that and if not create a local one?

That sounds reasonable, but we should check with @stbischof who created this component in case there is a reason.

from osgi-test.

stbischof avatar stbischof commented on June 3, 2024

The code is done at a point where functionality of putting an Extention like@ExtendWith(ConfigurationExtension.class) on a annotation like@WithFactoryConfiguration was not existing in junit 5. It came some weeks later an so it wans properly implemented from me.

also the documentation, and that we try to reset the configs after each test is not well documented

from osgi-test.

github-actions avatar github-actions commented on June 3, 2024

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

from osgi-test.

laeubi avatar laeubi commented on June 3, 2024

Still an issue...

from osgi-test.

timothyjward avatar timothyjward commented on June 3, 2024

Can you re-test this now #777 has been merged

from osgi-test.

timothyjward avatar timothyjward commented on June 3, 2024

My tests indicate that this is now solved, but it would be good to get confirmation from @laeubi

from osgi-test.

timothyjward avatar timothyjward commented on June 3, 2024

Can we close this issue?

from osgi-test.

laeubi avatar laeubi commented on June 3, 2024

@timothyjward yes if you think it is fixed, I'll probabbly open another one if I still find issues.

from osgi-test.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.