Announcement Announcement Module
No announcement yet.
Spring 3: Why is AbstractJpaTests deprecated? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 3: Why is AbstractJpaTests deprecated?

    I'm a confused about the AbstractJpaTests class and why it has been marked as deprecated in Spring 3.

    The apidocs say one should use "the listener-based test context framework (AbstractJUnit38SpringContextTests)".

    How can I write JPA integration tests and how do I get the Entity Manager? I read in the documentation that since Spring 3 one can use @PersistenceUnit directly in the tests.

    What about this classloader issues that are addresses win AbstractJpaTests with the shadowing class loader, are they solved in Spring 3 or even Spring 2.5 at all?

    Hope someone can explain to me how to write transactional JPA tests without using AbstractJpaTests.

  • #2
    Because that whole hierarchy is deprecated.

    How to write it, well follow the instructions..

    public class YourTestClass {
      @Autowired (or @PersistenceUnit)
      private EntityManager entityManager;
      public void yourTestMethod() {
        //do your tests
    For more info I suggest the test chapter.


    • #3
      Thanks, that looks easy!

      So there are no pitfalls with JPA and testing any more, since AbstractJpaTests uses a shadowing class loader and does some extended magic? Has this been only a problem in Spring 2.0?


      • #4
        I haven't had any issues, I suggest simply try it...


        • #5
          I have tried this but indeed I get the error "Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent" since there is no base class which is injecting a shadowing load time weaver. This weaver does not appear to be advertised as a standalone is there any way to replicate the AbstractJpaTests behavior w/ JUnit4 and TestContext?


          • #6
            duplicate post deleted