Note that there are some explanatory texts on larger screens.

plurals
  1. POUnit Testing gwt-dispatch
    primarykey
    data
    text
    <p>I'm trying to write some unit tests for a gwt-dispatch service with JUnit. I'm getting the following error when stepping through the test with my debugger:</p> <blockquote> <p>Error in custom provider, com.google.inject.OutOfScopeException: Cannot access scoped object. Either we are not currently inside an HTTP Servlet request, or you may have forgotten to apply com.google.inject.servlet.GuiceFilter as a servlet filter for this request.</p> </blockquote> <p>I'm going to simplify the code a bit here -- hopefully I'm not stripping out anything necessary.</p> <pre><code>import junit.framework.TestCase; import net.customware.gwt.dispatch.client.standard.StandardDispatchService; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.servlet.ServletModule; ... public class LoggedInServiceTest extends TestCase { Injector i; StandardDispatchService service; protected com.google.inject.Injector getInjector() { return Guice.createInjector(new ServletModule(), new TestServletModule(), new ActionsHandlerModule(), new TestDispatchModule(), new OpenIdGuiceModule()); } public void setUp() throws Exception { i = getInjector(); service = i.getInstance(StandardDispatchService.class); } public void testNotLoggedIn() { try { GetProjectsResult result = (GetProjectsResult) service.execute(new GetProjectsAction()); result.getSizeOfResult(); } catch (Exception e) { fail(); } } } </code></pre> <p>The service request is indeed supposed to be going through a GuiceFilter, and it looks like that filter is not being set.</p> <p>Any ideas on what other setup needs to be done to register the filter?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload