This commit is contained in:
Giancarlo Panichi 2013-10-24 12:10:08 +00:00
parent e5dc250d19
commit b15538906e
1 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,76 @@
package org.gcube.portlets.user.td.gwtservice.client;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTService;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.TabResource;
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.rpc.ServiceDefTarget;
/**
* GWT JUnit <b>integration</b> tests must extend GWTTestCase. Using
* <code>"GwtTest*"</code> naming pattern exclude them from running with
* surefire during the test phase.
*
* If you run the tests using the Maven command line, you will have to navigate
* with your browser to a specific url given by Maven. See
* http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html for
* details.
*/
public class GwtTestGWTService extends GWTTestCase {
/**
* Must refer to a valid module that sources this class.
*/
public String getModuleName() {
return "org.gcube.portlets.user.td.gxtservice.GXTServiceJUnit";
}
/**
* This test will send a request to the server
*/
public void testCreateTabResource() {
// Create the service that we will test.
TDGWTServiceAsync tdGWTService = GWT.create(TDGWTService.class);
ServiceDefTarget target = (ServiceDefTarget) tdGWTService;
System.out.println(GWT.getModuleBaseURL() + "TDGWTService");
target.setServiceEntryPoint(GWT.getModuleBaseURL() + "TDGWTService");
// Since RPC calls are asynchronous, we will need to wait for a response
// after this test method returns. This line tells the test runner to
// wait
// up to 7 seconds before timing out.
delayTestFinish(7000);
TabResource tabResource=new TabResource();
tabResource.setName("TestTabularResource");
tabResource.setAgency("FAO");
tabResource.setDescription("Tabular Resource Test");
tabResource.setRight("");
// Send a request to the server.
TDGWTServiceAsync.INSTANCE.createTabularResource(tabResource,new AsyncCallback<TabResource>() {
@Override
public void onFailure(Throwable caught) {
// The request resulted in an unexpected error.
fail("Request failure: " + caught.getMessage());
}
@Override
public void onSuccess(TabResource result) {
assertTrue(result != null);
System.out.println(result);
finishTest();
}
});
}
}