Results 1 to 3 of 3

Thread: Unit testing spring data DAOs

  1. #1
    Join Date
    Nov 2007
    Posts
    177

    Default Unit testing spring data DAOs

    Hello,
    I would like to know if there are patterns or tips for unit testing spring data methods using the @Query annotation such as the one below (taken from a "spring data" dao interface):
    Code:
      @Modifying
      @Transactional
      @Query("UPDATE Account a SET a.accountActivated = true WHERE a.accountToken = ?1")
      int reactivateAccountFromToken(String accountToken);
    By unit testing I mean using some sort of mock maybe but not hitting the database of course.
    Regards,
    Julien.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    Then what would you test not the query as that gets translated/converted by the EntityManager which you could mock but that doesn't give you much.

    I would create an integration test with maybe an in memory (H2, HSQLDB, Derby) database, but propably only for the complex queries the rest I would test with system tests.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Nov 2007
    Posts
    177

    Default

    Thanks Marten

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •