### Question:
TokenValidator extends AbstractValidator<HttpServletRequest> { @Override public void validateMethod(HttpServletRequest request) throws OAuthProblemException { String method = request.getMethod(); if (!OAuth.HttpMethod.GET.equals(method) && !OAuth.HttpMethod.POST.equals(method)) { throw OAuthProblemException.error(OAuthError.CodeResponse.INVALID_REQUEST) .description("Method not correct."); } } TokenValidator(); @Override void validateMethod(HttpServletRequest request); @Override void validateContentType(HttpServletRequest request);  }### Answer:
@Test public void testValidateMethod() throws Exception { HttpServletRequest request = createStrictMock(HttpServletRequest.class); expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.GET); replay(request); TokenValidator validator = new TokenValidator(); validator.validateMethod(request); verify(request); reset(request); request = createStrictMock(HttpServletRequest.class); expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.POST); replay(request); validator = new TokenValidator(); validator.validateMethod(request); verify(request); reset(request); request = createStrictMock(HttpServletRequest.class); expect(request.getMethod()).andStubReturn(OAuth.HttpMethod.DELETE); replay(request); validator = new TokenValidator(); try { validator.validateMethod(request); Assert.fail("Expected validation exception"); } catch (OAuthProblemException e) { } verify(request); }