Re: [appengine-java] Re: How to use junit test in the newest SDK1.3.1
It's the same (attached) I used before update to 1.3.1. Thanks, Krishna 2010/2/11 Max Ross (Google) : > Subclassing LocalServiceTestHelper and overriding newEnvironment() should > work fine. What does your implementation of newEnvironment() look like? > > On Wed, Feb 10, 2010 at 7:35 PM, Krishna wrote: >> >> Ok! >> >> But when I'm using transactions I'm getting: >> >> java.lang.NullPointerException: No API environment is registered for >> this thread. >>at >> >> com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java: >> 67) >>at >> >> com.google.appengine.api.datastore.DatastoreServiceImpl.beginTransaction(DatastoreServiceImpl.java: >> 270) >> >> I've tried to extend LocalServiceTestHelper and overwrite >> newEnvironment() with my Environment (who returns appId) but it >> didn't work... >> >> What's wrong? >> >> Thanks, >> Krishna >> >> On Feb 10, 10:25 pm, "Ikai L (Google)" wrote: >> > We've got a more simple interface for you now. Take a look: >> > >> > http://code.google.com/appengine/docs/java/tools/localunittesting.html >> > >> > 2010/2/10 时空之蕊 >> > >> > >> > >> > >> > >> > > I found the class >> > > com.google.appengine.tools.development.ApiProxyLocalImpl is not >> > > public,but before 1.3.1 it's public! >> > > In the JUnit document: >> > >> > > import java.io.File; >> > > import com.google.appengine.tools.development.ApiProxyLocalImpl; >> > > import com.google.apphosting.api.ApiProxy; >> > >> > > ApiProxy.setDelegate(new ApiProxyLocalImpl(new File(".")){}); >> > >> > > So I can't new a ApiProxyLocalImpl instance! >> > > Any body know how to use JUnit? >> > > Thanks :) >> > >> > > -- >> > > You received this message because you are subscribed to the Google >> > > Groups >> > > "Google App Engine for Java" group. >> > > To post to this group, send email to >> > > google-appengine-j...@googlegroups.com. >> > > To unsubscribe from this group, send email to >> > > >> > > google-appengine-java+unsubscr...@googlegroups.com> > > unsubscr...@googlegroups.com> >> > > . >> > > For more options, visit this group at >> > >http://groups.google.com/group/google-appengine-java?hl=en. >> > >> > -- >> > Ikai Lan >> > Developer Programs Engineer, Google App >> > Enginehttp://googleappengine.blogspot.com|http://twitter.com/app_engine >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google App Engine for Java" group. >> To post to this group, send email to >> google-appengine-j...@googlegroups.com. >> To unsubscribe from this group, send email to >> google-appengine-java+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/google-appengine-java?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine for Java" group. > To post to this group, send email to google-appengine-j...@googlegroups.com. > To unsubscribe from this group, send email to > google-appengine-java+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en. TestEnvironment.java Description: Binary data
Re: [appengine-java] Re: How to use junit test in the newest SDK1.3.1
Ooops.. missed your question! It's just: @Override protected Environment newEnvironment() { return new TestEnvironment(); } Thanks, Krishna 2010/2/11 Max Ross (Google) : > Subclassing LocalServiceTestHelper and overriding newEnvironment() should > work fine. What does your implementation of newEnvironment() look like? > > On Wed, Feb 10, 2010 at 7:35 PM, Krishna wrote: >> >> Ok! >> >> But when I'm using transactions I'm getting: >> >> java.lang.NullPointerException: No API environment is registered for >> this thread. >>at >> >> com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java: >> 67) >>at >> >> com.google.appengine.api.datastore.DatastoreServiceImpl.beginTransaction(DatastoreServiceImpl.java: >> 270) >> >> I've tried to extend LocalServiceTestHelper and overwrite >> newEnvironment() with my Environment (who returns appId) but it >> didn't work... >> >> What's wrong? >> >> Thanks, >> Krishna >> >> On Feb 10, 10:25 pm, "Ikai L (Google)" wrote: >> > We've got a more simple interface for you now. Take a look: >> > >> > http://code.google.com/appengine/docs/java/tools/localunittesting.html >> > >> > 2010/2/10 时空之蕊 >> > >> > >> > >> > >> > >> > > I found the class >> > > com.google.appengine.tools.development.ApiProxyLocalImpl is not >> > > public,but before 1.3.1 it's public! >> > > In the JUnit document: >> > >> > > import java.io.File; >> > > import com.google.appengine.tools.development.ApiProxyLocalImpl; >> > > import com.google.apphosting.api.ApiProxy; >> > >> > > ApiProxy.setDelegate(new ApiProxyLocalImpl(new File(".")){}); >> > >> > > So I can't new a ApiProxyLocalImpl instance! >> > > Any body know how to use JUnit? >> > > Thanks :) >> > >> > > -- >> > > You received this message because you are subscribed to the Google >> > > Groups >> > > "Google App Engine for Java" group. >> > > To post to this group, send email to >> > > google-appengine-j...@googlegroups.com. >> > > To unsubscribe from this group, send email to >> > > >> > > google-appengine-java+unsubscr...@googlegroups.com> > > unsubscr...@googlegroups.com> >> > > . >> > > For more options, visit this group at >> > >http://groups.google.com/group/google-appengine-java?hl=en. >> > >> > -- >> > Ikai Lan >> > Developer Programs Engineer, Google App >> > Enginehttp://googleappengine.blogspot.com|http://twitter.com/app_engine >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google App Engine for Java" group. >> To post to this group, send email to >> google-appengine-j...@googlegroups.com. >> To unsubscribe from this group, send email to >> google-appengine-java+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/google-appengine-java?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine for Java" group. > To post to this group, send email to google-appengine-j...@googlegroups.com. > To unsubscribe from this group, send email to > google-appengine-java+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/google-appengine-java?hl=en. > -- You received this message because you are subscribed to the Google Groups "Google App Engine for Java" group. To post to this group, send email to google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.
Re: [appengine-java] Re: How to use junit test in the newest SDK1.3.1
You're right! I refactored my code and forget to annotate the new setUp method with @Before. Sorry for taking your time! It works now. Thanks, Krishna 2010/2/11 Max Ross (Google) : > Your code looks fine. Are you sure you're calling setUp() on the > LocalServiceTestHelper? > > On Thu, Feb 11, 2010 at 10:11 AM, Krishna Caldas > wrote: >> >> Ooops.. missed your question! >> It's just: >>@Override >>protected Environment newEnvironment() { >>return new TestEnvironment(); >>} >> >> Thanks, >> Krishna >> >> 2010/2/11 Max Ross (Google) : >> > Subclassing LocalServiceTestHelper and overriding newEnvironment() >> > should >> > work fine. What does your implementation of newEnvironment() look like? >> > >> > On Wed, Feb 10, 2010 at 7:35 PM, Krishna >> > wrote: >> >> >> >> Ok! >> >> >> >> But when I'm using transactions I'm getting: >> >> >> >> java.lang.NullPointerException: No API environment is registered for >> >> this thread. >> >>at >> >> >> >> >> >> com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java: >> >> 67) >> >>at >> >> >> >> >> >> com.google.appengine.api.datastore.DatastoreServiceImpl.beginTransaction(DatastoreServiceImpl.java: >> >> 270) >> >> >> >> I've tried to extend LocalServiceTestHelper and overwrite >> >> newEnvironment() with my Environment (who returns appId) but it >> >> didn't work... >> >> >> >> What's wrong? >> >> >> >> Thanks, >> >> Krishna >> >> >> >> On Feb 10, 10:25 pm, "Ikai L (Google)" wrote: >> >> > We've got a more simple interface for you now. Take a look: >> >> > >> >> > >> >> > http://code.google.com/appengine/docs/java/tools/localunittesting.html >> >> > >> >> > 2010/2/10 时空之蕊 >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > > I found the class >> >> > > com.google.appengine.tools.development.ApiProxyLocalImpl is not >> >> > > public,but before 1.3.1 it's public! >> >> > > In the JUnit document: >> >> > >> >> > > import java.io.File; >> >> > > import com.google.appengine.tools.development.ApiProxyLocalImpl; >> >> > > import com.google.apphosting.api.ApiProxy; >> >> > >> >> > > ApiProxy.setDelegate(new ApiProxyLocalImpl(new File(".")){}); >> >> > >> >> > > So I can't new a ApiProxyLocalImpl instance! >> >> > > Any body know how to use JUnit? >> >> > > Thanks :) >> >> > >> >> > > -- >> >> > > You received this message because you are subscribed to the Google >> >> > > Groups >> >> > > "Google App Engine for Java" group. >> >> > > To post to this group, send email to >> >> > > google-appengine-j...@googlegroups.com. >> >> > > To unsubscribe from this group, send email to >> >> > > >> >> > > >> >> > > google-appengine-java+unsubscr...@googlegroups.com> >> > > unsubscr...@googlegroups.com> >> >> > > . >> >> > > For more options, visit this group at >> >> > >http://groups.google.com/group/google-appengine-java?hl=en. >> >> > >> >> > -- >> >> > Ikai Lan >> >> > Developer Programs Engineer, Google App >> >> > >> >> > Enginehttp://googleappengine.blogspot.com|http://twitter.com/app_engine >> >> >> >> -- >> >> You received this message because you are subscribed to the Google >> >> Groups >> >> "Google App Engine for Java" group. >> >> To post to this group, send email to >> >> google-appengine-j...@googlegroups.com. >> >> To unsubscribe from this group, send email to >> >> google-appengine-java+unsubscr...@googlegroups.com. >> >> For more options, visit this group at >> >> http://groups.google.com/group/google-appengine-java?hl=en. >
Re: [appengine-java] Re: How to use junit test in the newest SDK1.3.1
Yes, I missed that method. Maybe add this little trick on tutorial for now!? Krishna 2010/2/11 Max Ross (Google) : > Great, glad to hear it! I forgot to add a method to LocalServiceTestHelper > to set a custom app id. My mistake. I'll make sure this gets added for the > next release so you don't need to provide your own Environment > implementation. > > Max > > On Thu, Feb 11, 2010 at 10:30 AM, Krishna Caldas > wrote: >> >> You're right! >> I refactored my code and forget to annotate the new setUp method with >> @Before. >> Sorry for taking your time! It works now. >> >> Thanks, >> Krishna >> >> >> 2010/2/11 Max Ross (Google) : >> > Your code looks fine. Are you sure you're calling setUp() on the >> > LocalServiceTestHelper? >> > >> > On Thu, Feb 11, 2010 at 10:11 AM, Krishna Caldas >> > >> > wrote: >> >> >> >> Ooops.. missed your question! >> >> It's just: >> >>@Override >> >>protected Environment newEnvironment() { >> >>return new TestEnvironment(); >> >>} >> >> >> >> Thanks, >> >> Krishna >> >> >> >> 2010/2/11 Max Ross (Google) : >> >> > Subclassing LocalServiceTestHelper and overriding newEnvironment() >> >> > should >> >> > work fine. What does your implementation of newEnvironment() look >> >> > like? >> >> > >> >> > On Wed, Feb 10, 2010 at 7:35 PM, Krishna >> >> > wrote: >> >> >> >> >> >> Ok! >> >> >> >> >> >> But when I'm using transactions I'm getting: >> >> >> >> >> >> java.lang.NullPointerException: No API environment is registered for >> >> >> this thread. >> >> >>at >> >> >> >> >> >> >> >> >> >> >> >> com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java: >> >> >> 67) >> >> >>at >> >> >> >> >> >> >> >> >> >> >> >> com.google.appengine.api.datastore.DatastoreServiceImpl.beginTransaction(DatastoreServiceImpl.java: >> >> >> 270) >> >> >> >> >> >> I've tried to extend LocalServiceTestHelper and overwrite >> >> >> newEnvironment() with my Environment (who returns appId) but it >> >> >> didn't work... >> >> >> >> >> >> What's wrong? >> >> >> >> >> >> Thanks, >> >> >> Krishna >> >> >> >> >> >> On Feb 10, 10:25 pm, "Ikai L (Google)" wrote: >> >> >> > We've got a more simple interface for you now. Take a look: >> >> >> > >> >> >> > >> >> >> > >> >> >> > http://code.google.com/appengine/docs/java/tools/localunittesting.html >> >> >> > >> >> >> > 2010/2/10 时空之蕊 >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > >> >> >> > > I found the class >> >> >> > > com.google.appengine.tools.development.ApiProxyLocalImpl is not >> >> >> > > public,but before 1.3.1 it's public! >> >> >> > > In the JUnit document: >> >> >> > >> >> >> > > import java.io.File; >> >> >> > > import com.google.appengine.tools.development.ApiProxyLocalImpl; >> >> >> > > import com.google.apphosting.api.ApiProxy; >> >> >> > >> >> >> > > ApiProxy.setDelegate(new ApiProxyLocalImpl(new File(".")){}); >> >> >> > >> >> >> > > So I can't new a ApiProxyLocalImpl instance! >> >> >> > > Any body know how to use JUnit? >> >> >> > > Thanks :) >> >> >> > >> >> >> > > -- >> >> >> > > You received this message because you are subscribed to the >> >> >> > > Google >> >> >> > > Groups >> >> >> > > "Google App Engine for Java&q