Пример #1
0
 public ContentEntity createContent(
     String contentName,
     String categoryName,
     String languageCode,
     String ownerQualifiedName,
     String priority,
     Date created) {
   ContentEntity content = new ContentEntity();
   content.setLanguage(fixture.findLanguageByCode(languageCode));
   content.setCategory(fixture.findCategoryByName(categoryName));
   content.setOwner(fixture.findUserByName(ownerQualifiedName));
   content.setPriority(Integer.valueOf(priority));
   content.setCreatedAt(created); // Not-null field in database.
   content.setDeleted(false); // Not-null field in database.
   content.setName(contentName);
   return content;
 }
  @Test
  public void request_content_image_that_is_deleted() throws Exception {
    byte[] bytes = loadImage("Arn.JPG");
    ContentKey contentKey =
        createImageContent(
            "MyImage.jpg", 2, bytes, "ImageCategory", new DateTime(2011, 6, 27, 10, 0, 0, 0), null);
    ContentEntity content = fixture.findContentByKey(contentKey);
    content.setDeleted(true);

    String imageRequestPath = "_image/" + contentKey + ".jpg";
    setPathInfoAndRequestURI(httpServletRequest, imageRequestPath);
    httpServletRequest.setParameter("_background", "0xffffff");
    httpServletRequest.setParameter("_quality", "100");

    imageController.handleRequestInternal(httpServletRequest, httpServletResponse);
    assertEquals(HttpServletResponse.SC_NOT_FOUND, httpServletResponse.getStatus());
    assertTrue("Content Length", httpServletResponse.getContentLength() == 0);
  }