Details

    • Type: Sub-task Sub-task
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.2 final
    • Component/s: Testing
    • Labels:
      None
    • Environment:
      Windows Vista
      Grails 1.1
      Maven 2.1.0

      Description

      I need to test my app which has domain classes as POJOs and when I try to use mockDomain with my POJO I get this error:

      java.lang.ClassCastException: br.com.litoraltextil.vc.entity.Transportadora cannot be cast to groovy.lang.GroovyObject
      at grails.test.MockUtils.mockDomain(MockUtils.groovy:432)

      The class Transportadora is a java class mapped by hibernate.cfg.xml, when running the app all dynamic methods works fine but using mockDomain I get that error. I know a java class isn't a GroovyObject and I can't make my pojo extends it.

      Transportadora.java

      @Entity
      @Table(name = "TRANSP")
      @SequenceGenerator(name = "SequenceTransportadora", sequenceName = "GEN_TRANSP",
          allocationSize = 1)
      public class Transportadora implements Serializable{
          @Id
          @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SequenceTransportadora")
          @Min(0)
          private int id;
          @Transient // I can't have version activated, because legacy app, and the mockDomain always searchs for this property
          private long version;
      

      Hibernate.cfg.xml:

      <hibernate-configuration>
          <session-factory>
              <mapping package="br.com.litoraltextil.vc.entity" />
              <mapping class="br.com.litoraltextil.vc.entity.Transportadora" />
          </session-factory>
      </hibernate-configuration>
      

      Because of it I can't test my services. Is there a workaround for this?

      The POJO support should be implemented.

        Activity

        Hide
        Peter Ledbrook added a comment -

        This needs a reproducible example attached so we can track down the issue. Inspection of the code doesn't show any requirement for the class to be a GroovyObject. Could you also please attach the full stack trace.

        Show
        Peter Ledbrook added a comment - This needs a reproducible example attached so we can track down the issue. Inspection of the code doesn't show any requirement for the class to be a GroovyObject . Could you also please attach the full stack trace.
        Hide
        Felipe Cypriano added a comment -

        Hello Peter,

        I've attached a sample project, just run grails test-app to see the error.

        Also remove the need to have the version attribute in the class, if possible.

        Show
        Felipe Cypriano added a comment - Hello Peter, I've attached a sample project, just run grails test-app to see the error. Also remove the need to have the version attribute in the class, if possible.
        Hide
        Felipe Cypriano added a comment -

        I forget to comment about but this in this test case there's no Maven, I'm using Mac OS X and Grails 1.1.1

        Just to update the environment.

        Show
        Felipe Cypriano added a comment - I forget to comment about but this in this test case there's no Maven, I'm using Mac OS X and Grails 1.1.1 Just to update the environment.
        Hide
        Scott Cleland added a comment -

        This appears to be fixed in 1.2. Thank you.

        Show
        Scott Cleland added a comment - This appears to be fixed in 1.2. Thank you.

          People

          • Assignee:
            Unassigned
            Reporter:
            Felipe Cypriano
          • Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Last Reviewed:

              Development