Search in sources :

Example 1 with RemoteService

use of com.google.gwt.user.client.rpc.RemoteService in project gwt-test-utils by gwt-test-utils.

the class TestRemoteServiceCreateHandler method instanciateRemoteServiceInstance.

@SuppressWarnings("unchecked")
private <T> T instanciateRemoteServiceInstance(Class<T> remoteServiceClass, String remoteServiceRelativePath) {
    String moduleName = GwtConfig.get().getTestedModuleName();
    Class<?> remoteServiceImplClass = ModuleData.get(moduleName).getRemoteServiceImplClass(remoteServiceRelativePath);
    if (remoteServiceImplClass == null) {
        return null;
    } else if (!remoteServiceClass.isAssignableFrom(remoteServiceImplClass)) {
        throw new GwtTestConfigurationException("The servlet class '" + remoteServiceImplClass.getName() + "' setup for path '" + remoteServiceRelativePath + "' does not implement RemoteService interface '" + remoteServiceClass.getName());
    } else {
        try {
            return (T) GwtReflectionUtils.instantiateClass(remoteServiceImplClass);
        } catch (Exception e) {
            throw new GwtTestConfigurationException("Error during the instanciation of " + RemoteService.class.getSimpleName() + " implementation for servlet path '" + remoteServiceRelativePath + "'", e);
        }
    }
}
Also used : RemoteService(com.google.gwt.user.client.rpc.RemoteService) GwtTestConfigurationException(com.googlecode.gwt.test.exceptions.GwtTestConfigurationException) GwtTestConfigurationException(com.googlecode.gwt.test.exceptions.GwtTestConfigurationException)

Aggregations

RemoteService (com.google.gwt.user.client.rpc.RemoteService)1 GwtTestConfigurationException (com.googlecode.gwt.test.exceptions.GwtTestConfigurationException)1