Added Test Example
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-widget-common-event@85383 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9eba1033bc
commit
af6e77091e
8
pom.xml
8
pom.xml
|
@ -104,7 +104,7 @@
|
||||||
<version>3.0.1</version>
|
<version>3.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- LOGGING -->
|
<!-- LOGGING -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -141,7 +141,9 @@
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.16</version>
|
<version>2.16</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<skipTests>true</skipTests>
|
<excludes>
|
||||||
|
<exclude>**/GwtTest*.java</exclude>
|
||||||
|
</excludes>
|
||||||
</configuration>
|
</configuration>
|
||||||
<!-- TODO check if needed -->
|
<!-- TODO check if needed -->
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -161,6 +163,7 @@
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
<goal>resources</goal>
|
<goal>resources</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
|
@ -169,6 +172,7 @@
|
||||||
<runTarget>WidgetCommonEvent.html</runTarget>
|
<runTarget>WidgetCommonEvent.html</runTarget>
|
||||||
<hostedWebapp>${webappDirectory}</hostedWebapp>
|
<hostedWebapp>${webappDirectory}</hostedWebapp>
|
||||||
<module>org.gcube.portlets.user.td.widgetcommonevent.WidgetCommonEvent</module>
|
<module>org.gcube.portlets.user.td.widgetcommonevent.WidgetCommonEvent</module>
|
||||||
|
<includes>**/GwtTest*.java</includes>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,7 @@
|
||||||
<web-app>
|
<web-app>
|
||||||
|
|
||||||
<!-- Servlets -->
|
<!-- Servlets -->
|
||||||
<servlet>
|
|
||||||
<servlet-name>TDGWTService</servlet-name>
|
|
||||||
<servlet-class>org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl</servlet-class>
|
|
||||||
</servlet>
|
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>jUnitHostImpl</servlet-name>
|
<servlet-name>jUnitHostImpl</servlet-name>
|
||||||
|
@ -17,19 +14,15 @@
|
||||||
</servlet>
|
</servlet>
|
||||||
|
|
||||||
<!-- Servlets Mapping -->
|
<!-- Servlets Mapping -->
|
||||||
<servlet-mapping>
|
|
||||||
<servlet-name>TDGWTService</servlet-name>
|
|
||||||
<url-pattern>tdgwtservice/TDGWTService</url-pattern>
|
|
||||||
</servlet-mapping>
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>jUnitHostImpl</servlet-name>
|
<servlet-name>jUnitHostImpl</servlet-name>
|
||||||
<url-pattern>TDInformationManagerWidgets/junithost/*</url-pattern>
|
<url-pattern>WidgetCommonEvent/junithost/*</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
|
||||||
<!-- Default page to serve -->
|
<!-- Default page to serve -->
|
||||||
<welcome-file-list>
|
<welcome-file-list>
|
||||||
<welcome-file>Information.html</welcome-file>
|
<welcome-file>WidgetCommonEvent.html</welcome-file>
|
||||||
</welcome-file-list>
|
</welcome-file-list>
|
||||||
|
|
||||||
</web-app>
|
</web-app>
|
||||||
|
|
|
@ -1,20 +1,18 @@
|
||||||
package org.gcube.portlets.user.td.widgetcommonevent.client;
|
package org.gcube.portlets.user.td.widgetcommonevent.client;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ImportTableEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ImportTableType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.google.gwt.junit.client.GWTTestCase;
|
import com.google.gwt.junit.client.GWTTestCase;
|
||||||
|
import com.google.web.bindery.event.shared.SimpleEventBus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GWT JUnit <b>integration</b> tests must extend GWTTestCase.
|
* Test Event
|
||||||
* 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
|
* @author "Giancarlo Panichi"
|
||||||
* navigate with your browser to a specific url given by Maven.
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
* See http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html
|
*
|
||||||
* for details.
|
|
||||||
*/
|
*/
|
||||||
public class GwtTestWidgetCommonEvent extends GWTTestCase {
|
public class GwtTestWidgetCommonEvent extends GWTTestCase {
|
||||||
|
|
||||||
|
@ -23,62 +21,54 @@ public class GwtTestWidgetCommonEvent extends GWTTestCase {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() {
|
public String getModuleName() {
|
||||||
return "org.gcube.portlets.user.td.widgetcommonevent.test.WidgetCommonEventJUnit";
|
return "org.gcube.portlets.user.td.widgetcommonevent.WidgetCommonEventJUnit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test will send a request to the server
|
* Test Events fire
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEvents() {
|
public void testEvents() {
|
||||||
// Create the service that we will test.
|
|
||||||
//TDGWTServiceAsync tdGXTService = GWT.create(TDGWTService.class);
|
|
||||||
//ServiceDefTarget target = (ServiceDefTarget) tdGXTService;
|
|
||||||
//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 10 seconds before timing out.
|
|
||||||
//delayTestFinish(2000);
|
|
||||||
//finishTest();
|
|
||||||
|
|
||||||
// Send a request to the server.
|
SimpleEventBus eventBus=new SimpleEventBus();
|
||||||
/*try {
|
|
||||||
TDGXTServiceAsync.INSTANCE.getTabResource(
|
eventBus.addHandler(ImportTableEvent.TYPE,
|
||||||
new AsyncCallback<TabResource>() {
|
new ImportTableEvent.ImportTableHandler() {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(TabResource result) {
|
|
||||||
assertTrue(result!=null);
|
|
||||||
System.out.println(result);
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onImportTable(ImportTableEvent event) {
|
||||||
// The request resulted in an unexpected error.
|
doImportTable(event.getImportType());
|
||||||
fail("Request failure: " + caught.getMessage());
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
eventBus.fireEvent(new ImportTableEvent(ImportTableType.SDMX));
|
||||||
|
eventBus.fireEvent(new ImportTableEvent(ImportTableType.CSV));
|
||||||
|
eventBus.fireEvent(new ImportTableEvent(ImportTableType.JSON));
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
} catch (TDGXTServiceException e) {
|
|
||||||
System.out.println("Error in comunications: "+e.getLocalizedMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doImportTable(ImportTableType importType) {
|
||||||
|
System.out.println("doImportTable importType: " + importType);
|
||||||
|
try {
|
||||||
|
switch (importType) {
|
||||||
|
case SDMX:
|
||||||
|
System.out.println("Start Import SDMX");
|
||||||
|
break;
|
||||||
|
case CSV:
|
||||||
|
System.out.println("Start Import CSV");
|
||||||
|
break;
|
||||||
|
case JSON:
|
||||||
|
System.out.println("Start Import JSON");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("doImportTable Error : " + e.getLocalizedMessage()
|
||||||
|
+ " \n " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module rename-to="WidgetCommonEventJUnit">
|
<module rename-to="GwtTestWidgetCommonEventJUnit">
|
||||||
<!-- Inherit our applications main module. -->
|
<!-- Inherit our applications main module. -->
|
||||||
|
|
||||||
<!-- <inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' /> -->
|
<!-- <inherits name='org.gcube.portlets.user.td.gwtservice.TDGWTService' /> -->
|
||||||
|
|
||||||
<!-- Specify the path to any remote services. -->
|
<!-- Specify the path to any remote services. -->
|
||||||
<!-- <servlet path="/TDGWTService"
|
<!-- <servlet path="/TDGWTService"
|
||||||
class="org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl" /> -->
|
class="org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl" /> -->
|
||||||
|
@ -10,5 +10,4 @@
|
||||||
|
|
||||||
<!-- Specify the paths for translatable code -->
|
<!-- Specify the paths for translatable code -->
|
||||||
<source path='client' />
|
<source path='client' />
|
||||||
<source path='test' />
|
|
||||||
</module>
|
</module>
|
Loading…
Reference in New Issue