Class KiwiServletMocks


  • @Beta
    public final class KiwiServletMocks
    extends Object
    Static utilities to create Mockito-based mocks for servlet API code.
    • Method Detail

      • mockHttpServletRequestWithCertificate

        public static javax.servlet.http.HttpServletRequest mockHttpServletRequestWithCertificate​(String dn)
        Implementation Note:
        Don't inline the 'certificate' in the thenReturn() call on the mock request. For some reason that I have not fully investigated, Mockito gets really upset and throws a UnfinishedStubbingException.
      • mockHttpServletRequestWithNoCertificate

        public static javax.servlet.http.HttpServletRequest mockHttpServletRequestWithNoCertificate()
        Implementation Note:
        This is not strictly necessary since a Mockito mock will return null for methods that return a reference type if not provided any expectations. But, it makes test code more explicit about the intent of the code, so that's why this exists.
      • matchesExpectedCertBySubjectDN

        public static org.mockito.ArgumentMatcher<X509Certificate> matchesExpectedCertBySubjectDN​(String subjectDn)
        Argument matcher that matches a certificate having the given subject DN.
      • matchesExpectedCertByX500PrincipalName

        public static org.mockito.ArgumentMatcher<X509Certificate> matchesExpectedCertByX500PrincipalName​(String name)
        Argument matcher that matches a certificate having an X500Principal with the given name.