use of javax.servlet.FilterConfig in project sonarqube by SonarSource.
the class MasterServletFilterTest method filters_should_be_optional.
@Test
public void filters_should_be_optional() throws Exception {
FilterConfig config = mock(FilterConfig.class);
MasterServletFilter filters = new MasterServletFilter();
filters.init(config, Collections.emptyList());
ServletRequest request = mock(HttpServletRequest.class);
ServletResponse response = mock(HttpServletResponse.class);
FilterChain chain = mock(FilterChain.class);
filters.doFilter(request, response, chain);
verify(chain).doFilter(request, response);
}
use of javax.servlet.FilterConfig in project sonarqube by SonarSource.
the class RootFilterTest method initialize.
@Before
public void initialize() throws Exception {
FilterConfig filterConfig = mock(FilterConfig.class);
ServletContext context = mock(ServletContext.class);
when(context.getContextPath()).thenReturn("/context");
when(filterConfig.getServletContext()).thenReturn(context);
chain = mock(FilterChain.class);
filter = new RootFilter();
filter.init(filterConfig);
}
use of javax.servlet.FilterConfig in project OpenAM by OpenRock.
the class XUIFilterTest method setUp.
@BeforeMethod
public void setUp() {
XUIState xuiState = mock(XUIState.class);
when(xuiState.isXUIEnabled()).thenReturn(true);
filter = new XUIFilter(xuiState);
FilterConfig filterConfig = mock(FilterConfig.class);
ServletContext servletContext = mock(ServletContext.class);
when(filterConfig.getServletContext()).thenReturn(servletContext);
when(servletContext.getContextPath()).thenReturn(CONTEXT);
filter.init(filterConfig);
}
use of javax.servlet.FilterConfig in project OpenAM by OpenRock.
the class CORSFilterTest method shouldThrowExceptionWhenMaxAgeIsNaN.
@Test(expectedExceptions = ServletException.class)
public void shouldThrowExceptionWhenMaxAgeIsNaN() throws ServletException {
//given
FilterConfig config = mock(FilterConfig.class);
given(config.getInitParameter(CORSConstants.ORIGINS_KEY)).willReturn("www.google.com");
given(config.getInitParameter(CORSConstants.METHODS_KEY)).willReturn("GET,POST");
given(config.getInitParameter(CORSConstants.MAX_AGE_KEY)).willReturn("words");
//when
testFilter.init(config);
//then
}
use of javax.servlet.FilterConfig in project OpenAM by OpenRock.
the class AMSetupFilterTest method initShouldNotSetEncryptionPasswordIfConfigured.
@Test
public void initShouldNotSetEncryptionPasswordIfConfigured() throws Exception {
//Given
FilterConfig config = mock(FilterConfig.class);
ServletContext context = mock(ServletContext.class);
given(config.getServletContext()).willReturn(context);
systemIsConfigured();
//When
setupFilter.init(config);
//Then
verifyZeroInteractions(context);
}
Aggregations