Created
October 4, 2011 22:51
-
-
Save eishay/1263088 to your computer and use it in GitHub Desktop.
Test Guice can init all bounded servlets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.mockito.Mockito.mock; | |
import static org.mockito.Mockito.when; | |
import com.google.inject.Binding; | |
import com.google.inject.Injector; | |
import com.google.inject.servlet.GuiceFilter; | |
... | |
public static void assertInit(Injector injector) { | |
GuiceFilter filter = injector.getInstance(GuiceFilter.class); | |
FilterConfig filterConfig = mock(FilterConfig.class); | |
ServletContext context = mock(ServletContext.class); | |
when(filterConfig.getServletContext()).thenReturn(context); | |
try { | |
filter.init(filterConfig); | |
} catch (ServletException e) { | |
throw new RuntimeException(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment