-
Notifications
You must be signed in to change notification settings - Fork 0
Integration with Spring
Since a GWT application usually deals with a backend server, you may be interested in using Spring to manage your server components, like RPC services. Some simple frameworks, like gwtrpc-spring could handle the glue code beetwen Spring and GWT remote services for you.
But you also might want to test your entire stack. That's why gwt-test-utils comes with some classes to do it very easily.
@ContextConfiguration(locations = {"classpath:applicationContext-test.xml"}, loader = GwtTestContextLoader.class)
@GwtModule("com.googlecode.gwt.test.sample.SpringSample")
public class DemoSpringTest extends GwtSpringTest {
@Autowired
private MyService myService;
// your test methods go here...
}- First, extend
GwtSpringTest, the base class for test with Spring. - Use the
ContextConfigurationannotation from spring-test to configure your test context. gwt-test-utils provides aGwtTestContextLoaderyou must declare as the custom context loader. - Like with
GwtTest, you have to set the module under test with the@GwtModuleannotation. - That's it !
Your GwtSpringTest subclasses can be injected with @Autowired beans, and hold a reference to the test ApplicationContext through the GwtSpringTest.getApplicationContext() protected method.
Also note that your RPC servlets will automatically be binded to their corresponding RemoteService interfaces !
If you want to write a CSV test scenario which should be integrated with Spring, just extend GwtSpringCsvTest instead of GwtSpringTest :-)
You can fork sample-spring and sample-spring-csv projects to see complete GWT + Spring applications and how to test them using gwt-test-utils.
TODO