Announcement Announcement Module
Collapse
No announcement yet.
Testing in SpringDM Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Testing in SpringDM

    I am trying to execute a TestNG test case in a SpringDM bundle which uses the Spring TestContext framework to test an OSGi service exposed by another bundle. My issue is that the @ContextConfiguration directive does not work as expected and the service dependency is not injected. I even try to invoke a local bean, something which works outside of springDM, and that does not work either. It seems as if @ContextConfiguration has problems in SpringDM. Is it supposed to work and has anyone tried it?

    I have attached my sample provider and sample consumer bundles, based on examples provided by Spring source. The TestExecutionComponent class is @Component, which launches TestNG in the @PostConstruct method. The test class is launches is TeamAdminServiceTests. There are three context files under META-INF/spring: module-context.xml, osgi-context.xml, and test-context.xml.

    I have also attached the trace files.

    If I point the @ContextConfiguration annotation in TeamAdminServiceTests to test-context.xml, nothing is injected. If I point it to module-context.xml or osgi-context.xml, it tells me the bindings for the XML file could not be found.

    Any ideas would be very appreciated, as I have been stuck on this for a few days and starting to wonder if the TestContext framework is supposedto work at all in SpringDM.

    Thanks!

    Thanks

  • #2
    Are you using Spring DM standalone, or within dm Server? I tried to take a look at the zips that you've attached to figure this out, but I couldn't extract either of them, I wonder if they're corrupted?

    Comment


    • #3
      Originally posted by drudman View Post
      I have been stuck on this for a few days and starting to wonder if the TestContext framework is supposedto work at all in SpringDM.
      In short: No, the TestContext framework does not work in conjunction with Spring DM.

      Costin is, however, planning on adding JDK 5-style testing support to Spring DM. Perhaps that new Spring DM support will work with the TestContext framework, but that's merely speculation.

      For SpringSource dm Server 1.0.2, I wrote a testing framework that launches dm Server and allows you to use the Spring TestContext Framework to write integration tests for OSGi-based applications. But this framework was never officially released. In the interim, the dm Server team has worked on an integration testing framework that does not incorporate the TestContext framework.

      For details on what the future holds in store, we will have to rely on feedback from Rob, Andy, and Costin.

      Regards,

      Sam

      Comment


      • #4
        Originally posted by Andy Wilkinson View Post
        Are you using Spring DM standalone, or within dm Server? I tried to take a look at the zips that you've attached to figure this out, but I couldn't extract either of them, I wonder if they're corrupted?
        I am using SpringDM Server 1.0.2.

        Sorry about the zip's, they are actually rar's, since the forum doesn't allow me to attach rar's I renamed them to zip's. Reattached now as real zip. Really appreciate you having a look. Please let me know if I can clear up anything on the contents.

        Thanks!

        Comment


        • #5
          Thanks Sam, this explanation is really helpful and much appreciated.

          Originally posted by Sam Brannen View Post
          In short: No, the TestContext framework does not work in conjunction with Spring DM.
          I am trying to understand the reason for this and any workarounds. What is the underlying reason that @ContextConfiguration cannot load the app context, I guess it has to do with bundle classpath? Wondering if there is any easy way to mimic the behavior of @ContextConfiguration but make it work in the bundle.

          Originally posted by Sam Brannen View Post
          For SpringSource dm Server 1.0.2, I wrote a testing framework that launches dm Server and allows you to use the Spring TestContext Framework to write integration tests for OSGi-based applications. But this framework was never officially released. In the interim, the dm Server team has worked on an integration testing framework that does not incorporate the TestContext framework.
          Any way I can take a look at this testing framework you wrote, this sounds like exactly what we need. It would be great to reuse your work, even unofficially or at least get an idea of how you did it.

          Thanks

          Comment

          Working...
          X