コード例 #1
0
 @Test
 public void httpHeaderNameCasingIsPreserved() throws Exception {
   String headerName = "Header1";
   request.addHeader(headerName, "value1");
   Enumeration<String> requestHeaders = request.getHeaderNames();
   assertNotNull(requestHeaders);
   assertEquals(
       "HTTP header casing not being preserved", headerName, requestHeaders.nextElement());
 }
コード例 #2
0
  public void shouldImmediatelyReturnIfNoRobotInfoFound() throws Exception {
    // given
    when(mockCombinatorStrategy.combine(testMethod)).thenReturn(Collections.<RobotInfo>emptyList());

    // when
    final boolean result = interceptor.preHandle(mockRequest, mockResponse, mockHandlerMethod);

    // then
    assertTrue("Interceptor should always return true", result);
    assertNull(
        "Request attribute should not be set",
        mockRequest.getAttribute(RepInterceptor.ROBOTS_REQUEST_ATTRIBUTE));
    assertFalse("No headers should be added", mockRequest.getHeaderNames().hasMoreElements());

    verify(mockCombinatorStrategy).combine(testMethod);
  }