Announcement Announcement Module
Collapse
No announcement yet.
integration test with app-engine and gorm-jpa Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • integration test with app-engine and gorm-jpa

    Hi all,
    I am using grails 1.3.5 and the latest app-engine and gorm-jpa
    plugins. I created a User class and a UserIntegrationTest to test it.
    However, I am getting below error in the reports. This is blocking me in implementation since I really want to be able to test JPA domain classes before writing gsp codes.
    ****
    Could not open JPA EntityManager for transaction; nested exception is
    java.lang.NullPointerException: No API environment is registered for
    this thread.
    org.springframework.transaction.CannotCreateTransa ctionException:
    Could not open JPA EntityManager for transaction; nested exception is
    java.lang.NullPointerException: No API environment is registered for
    this thread.
    Caused by: java.lang.NullPointerException: No API environment is
    registered for this thread.
    at
    com.google.appengine.api.datastore.DatastoreApiHel per.getCurrentAppId(Datas toreApiHelper.java:
    108)
    at
    com.google.appengine.api.datastore.BaseDatastoreSe rvice.beginTransaction(Ba seDatastoreService.java:
    125)
    at
    org.datanucleus.store.appengine.RuntimeExceptionWr appingDatastoreService.be ginTransaction(RuntimeExceptionWrappingDatastoreSe rvice.java:
    209)
    at
    org.datanucleus.store.appengine.jpa.DatastoreEntit yTransactionImpl.begin(Da tastoreEntityTransactionImpl.java:
    49)
    at _GrailsTest_groovy$_run_closure4.doCall(_GrailsTes t_groovy:
    269)
    at _GrailsTest_groovy$_run_closure4.call(_GrailsTest_ groovy)
    at _GrailsTest_groovy$_run_closure2.doCall(_GrailsTes t_groovy:
    226)
    at _GrailsTest_groovy
    $_run_closure1_closure21.doCall(_GrailsTest_groovy :185)
    at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTes t_groovy:
    172)
    at TestApp$_run_closure1.doCall(TestApp.groovy:101)
    at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:38 1)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:41 5)
    at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
    at gant.Gant.withBuildListeners(Gant.groovy:427)
    at gant.Gant.this$2$withBuildListeners(Gant.groovy)
    at gant.Gant$this$2$withBuildListeners.callCurrent(Un known
    Source)
    at gant.Gant.dispatch(Gant.groovy:415)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.executeTargets(Gant.groovy:590)
    at gant.Gant.executeTargets(Gant.groovy:589)
    ****
    Domain class is defined as:
    package com.jothub
    import javax.persistence.*;
    // import com.google.appengine.api.datastore.Key;
    @Entity
    class User implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    Long id
    static constraints = { id visible:false }
    @Basic
    String emailAddress;
    @Basic
    String password;
    }

    The Test is defined as:
    package com.jothub
    import grails.test.*
    class UserIntegrationTests extends GrailsUnitTestCase {
    protected void setUp() {
    super.setUp()
    }
    protected void tearDown() {
    super.tearDown()
    }
    void testFirstSave() {
    User user = new User(emailAddress: 't...@abc.com', password:
    'secret')
    assertNotNull user.save()
    assertNotNull user.id
    User foundUser = User.get(user.id)
    assertEquals 't...@abc.com', foundUser.emailAddress
    }
Working...
X