My test class
package com.avpanasovich.client;
import com.avpanasovich.model.ItemType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.Timer;
import org.junit.Test;
/**
*
* @author Panason
*/
public class GwtTestMyFirstTestCase extends GWTTestCase {
ItemTypeServiceAsync itemTypeServiceAsync ;
AsyncCallback<Long> callback;
@Override
public String getModuleName() {
return "com.avpanasovich.itemManager";
// return null;
}
@Override
public void gwtSetUp() {
itemTypeServiceAsync = GWT.create(ItemTypeService.class);
callback = new AsyncCallback<Long>() {
@Override
public void onFailure(Throwable caught) {
GWT.log(caught.getMessage());
}
@Override
public void onSuccess(Long result) {
GWT.log("###############"+result);
}
};
}
@Test
public void testSomething() {
String moduleBaseURL = GWT.getModuleBaseURL();
Timer timer = new Timer() {
public void run()
{
ItemType itemType=new ItemType();
itemType.setNameItemType("dcccccccccccc");
itemTypeServiceAsync.create(itemType, callback);
finishTest();
}
};
timer.schedule(200);
delayTestFinish(10000);
}
}
My ItemManager.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.2.0//
EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.2.0/distro-
source/core/src/gwt-module.dtd">
<module rename-to="itemManager">
<inherits name="com.google.gwt.user.User"/>
<inherits name="com.google.gwt.user.theme.standard.Standard"/>
<inherits name="com.google.gwt.junit.JUnit"/>
<source path="client"/>
<source path="model"/>
<servlet class="com.avpanasovich.web.ItemTypeServiceImpl" path="/
itemType"/>
<entry-point class="com.avpanasovich.client.ItemManager"/>
</module>
Getting error
logging for HtmlUnit thread
[WARN] Expected content type of 'application/javascript' or
'application/ecmascript' for remotely loaded JavaScript element at
'http://192.168.241.1:53571/com.avpanasovich.itemManager.JUnit/
com.avpanasovich.itemManager.JUnit.nocache.js', but got 'application/x-
javascript'.
Starting Jetty on port 0
[WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method
'public abstract java.lang.Long
com.avpanasovich.model.ItemTypes.create(com.avpanasovich.model.ItemType)'
threw an unexpected exception: java.lang.NullPointerException: No API
environment is registered for this thread.
at
com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:
385)
at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
588)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:
208)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:
248)
at
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:
62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
487)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
362)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
181)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
405)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at
org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:
49)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
505)
at org.mortbay.jetty.HttpConnection
$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
395)
at org.mortbay.thread.QueuedThreadPool
$PoolThread.run(QueuedThreadPool.java:488)
Caused by: java.lang.NullPointerException: No API environment is
registered for this thread.
at
com.google.appengine.api.datastore.DatastoreApiHelper.getCurrentAppId(DatastoreApiHelper.java:
108)
at
com.google.appengine.api.datastore.BaseDatastoreServiceImpl.beginTransactionInternal(BaseDatastoreServiceImpl.java:
121)
at
com.google.appengine.api.datastore.DatastoreServiceImpl.beginTransaction(DatastoreServiceImpl.java:
222)
at
org.datanucleus.store.appengine.RuntimeExceptionWrappingDatastoreService.beginTransaction(RuntimeExceptionWrappingDatastoreService.java:
210)
at
org.datanucleus.store.appengine.jpa.DatastoreEntityTransactionImpl.begin(DatastoreEntityTransactionImpl.java:
49)
at
com.avpanasovich.server.ItemTypeRepository.create(ItemTypeRepository.java:
26)
at
com.avpanasovich.web.ItemTypeServiceImpl.create(ItemTypeServiceImpl.java:
32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
569)
... 22 more
[ERROR] 500 - POST /com.avpanasovich.itemManager.JUnit/itemType
(192.168.241.1) 57 bytes
Separate testing JPA is successful
package com.avpanasovich;
import com.google.appengine.api.datastore.dev.LocalDatastoreService;
import com.google.appengine.tools.development.ApiProxyLocal;
import com.google.apphosting.api.ApiProxy;
public class LocalDatastoreTestCase extends LocalServiceTestCase {
@Override
public void setUp() throws Exception {
super.setUp();
ApiProxyLocal proxy = (ApiProxyLocal) ApiProxy.getDelegate();
proxy.setProperty(LocalDatastoreService.NO_STORAGE_PROPERTY,
Boolean.TRUE.toString());
}
@Override
public void tearDown() throws Exception {
ApiProxyLocal proxy = (ApiProxyLocal) ApiProxy.getDelegate();
LocalDatastoreService datastoreService =
(LocalDatastoreService) proxy.getService("datastore_v3");
datastoreService.clearProfiles();
super.tearDown();
}
}
package com.avpanasovich;
import com.avpanasovich.model.ItemType;
import com.avpanasovich.server.ItemTypeRepository;
import java.util.Collection;
import org.apache.log4j.Logger;
import org.junit.Ignore;
import org.junit.Test;
public class ContactInfoDAOTestCase extends LocalDatastoreTestCase {
private Logger
logger=Logger.getLogger(ContactInfoDAOTestCase.class);
@Test
public void testgetAllItemType() {
ItemType itemType=new ItemType();
itemType.setNameItemType("gggg");
ItemTypeRepository itemTypeRepository=new ItemTypeRepository();
Long iLong=itemTypeRepository.create(itemType);
assertNotNull(iLong);
Collection<ItemType> itemtypes = itemTypeRepository.getAll();
assertNotNull(itemtypes);
logger.info(itemtypes);
}
}
How to test together GWT and persistence?
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment