WebApplicationDeclaredRoles { public Set<String> getDeclaredRoles() { return declaredRoles; } WebApplicationDeclaredRoles(ServletContext servletContext); Set<String> getDeclaredRoles();  }
@Test public void parsesRolesFromWebXml() { ServletContext servletContext = mock(ServletContext.class); when(servletContext.getResourceAsStream("/WEB-INF/web.xml")).thenReturn(new ByteArrayInputStream(webXmlWithRoles.getBytes())); WebApplicationDeclaredRoles webApplicationDeclaredRoles = new WebApplicationDeclaredRoles(servletContext); assertEquals(new HashSet<>(Arrays.asList("user", "admin")), webApplicationDeclaredRoles.getDeclaredRoles()); }
@Test public void returnsEmptyRolesSetIfWebXmlNotFound() { ServletContext servletContext = mock(ServletContext.class); WebApplicationDeclaredRoles webApplicationDeclaredRoles = new WebApplicationDeclaredRoles(servletContext); assertTrue("Roles set must be empty", webApplicationDeclaredRoles.getDeclaredRoles().isEmpty()); }