git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-csv-import-widget@84038 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b66368a498
commit
daf8743685
|
@ -0,0 +1,83 @@
|
||||||
|
package org.gcube.portlets.user.td.csvimportwidget.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
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 GwtTestCSVImportWizardTD extends GWTTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must refer to a valid module that sources this class.
|
||||||
|
*/
|
||||||
|
public String getModuleName() {
|
||||||
|
return "org.gcube.portlets.user.csvimportWizard.CSVImportWizardTDJUnit";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test will send a request to the server
|
||||||
|
*/
|
||||||
|
public void testResource() {
|
||||||
|
// Create the service that we will test.
|
||||||
|
TDGWTServiceAsync tdGXTService = GWT.create(TDGWTService.class);
|
||||||
|
ServiceDefTarget target = (ServiceDefTarget) tdGXTService;
|
||||||
|
System.out.println(GWT.getModuleBaseURL() + "TDGXTService");
|
||||||
|
target.setServiceEntryPoint(GWT.getModuleBaseURL() + "TDGXTService");
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// Send a request to the server.
|
||||||
|
tdGXTService.getTabularResources(new AsyncCallback<List<TabResource>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
// The request resulted in an unexpected error.
|
||||||
|
fail("Request failure: " + caught.getMessage());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<TabResource> result) {
|
||||||
|
// Shows the first three resources.
|
||||||
|
int i=0;
|
||||||
|
for(TabResource tr:result){
|
||||||
|
i++;
|
||||||
|
System.out.println(tr.toString());
|
||||||
|
if(i>3){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(result.size()>0);
|
||||||
|
|
||||||
|
// Now that we have received a response, we need to tell the test runner
|
||||||
|
// that the test is complete. You must call finishTest() after an
|
||||||
|
// asynchronous test finishes successfully, or the test will time out.
|
||||||
|
finishTest();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue