### Question:
WebContainerAuthorizer implements WebAuthorizer { public boolean isConstrained( final String url, final Role role ) { final Element root = m_webxml.getRootElement(); final Namespace jeeNs = Namespace.getNamespace( "j", J2EE_SCHEMA_25_NAMESPACE ); final String constrainsSelector = " final List< Element > constraints = XPathFactory.instance() .compile( constrainsSelector, Filters.element(), null, jeeNs ) .evaluate( root ); final String rolesSelector = " final List< Element > roles = XPathFactory.instance() .compile( rolesSelector, Filters.element(), null, jeeNs ) .evaluate( root ); if ( constraints.size() == 0 ) { return false; } if ( role.equals( Role.ALL ) ) { return true; } if ( roles.size() == 0 ) { return false; } for ( final Iterator< Element > c = constraints.iterator(); c.hasNext(); ) { final Element constraint = c.next(); for ( final Iterator< Element > r = roles.iterator(); r.hasNext(); ) { final Element roleConstraint = r.next(); if ( constraint.equals( roleConstraint ) ) { return true; } } } return false; } WebContainerAuthorizer(); @Override void initialize( final Engine engine, final Properties props ); @Override boolean isUserInRole( final HttpServletRequest request, final Principal role ); @Override boolean isUserInRole( final Session session, final Principal role ); @Override Principal findRole( final String role ); boolean isConstrained( final String url, final Role role ); boolean isContainerAuthorized(); @Override Principal[] getRoles();  }### Answer:
@Test public void testConstraints() throws Exception { Assertions.assertTrue( m_authorizer.isConstrained( "/Delete.jsp", new Role( "Admin" ) ) ); Assertions.assertTrue( m_authorizer.isConstrained( "/Login.jsp", Role.AUTHENTICATED ) ); Assertions.assertFalse( m_authorizer.isConstrained( "/UserPreferences.jsp", Role.AUTHENTICATED ) ); }