Issue Type: Bug Bug
Affects Versions: 2.5.0-rc1, 2.4.0
Assignee: Unassigned
Created: 17/Aug/12 11:12 AM
Description:

the util getInstance() method generated by the gwt:generateAsync target is not compatible with Mock objects, generated for instance with the com.googlecode.gwt.test.Mock annotation.

when test frameworks generate a mock instance of the interface, it doesn't necessarily subclass ServiceDefTarget, making the line
ServiceDefTarget target = (ServiceDefTarget) instance;
a class cast error.

How to reproduce:

  • Add dependency to gwt-test-utils and easymock:
    <dependency>
          <groupId>com.googlecode.gwt-test-utils</groupId>
          <artifactId>gwt-test-utils</artifactId>
          <version>0.38</version>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.easymock</groupId>
          <artifactId>easymock</artifactId>
          <version>3.0</version>
          <scope>test</scope>
        </dependency>
  • Create a test class:
    public class MockTest extends GwtTestWithEasyMock {
          @Mock
          private DataServiceAsync service;
    
          @Override
          public String getModuleName() {
            return "com.example";
          }
    
          @Test
          public void test() throws DaoException {
              // the mock implementation is returned instead by
              // GWT.create, causing a wrong cast
              DataServiceAsync.Util.getInstance();
          }
        }
  • run the test (mvn test)

Proposed solution:
Check before casting.
The setServiceEntryPoint call will not be necessary in case the instance is not actually a remote service.

Environment: gwt-test-utils
easymock
Project: Maven GWT Plugin
Priority: Major Major
Reporter: Samuele Arcidiacono
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to