Ejemplo n.º 1
0
  @Test
  public void testDownload() throws Exception {
    this.request.setEndpointPath("/_/attachment/download/123456/logo.png");

    final PortalResponse res = this.handler.handle(this.request);
    assertNotNull(res);
    assertEquals(HttpStatus.OK, res.getStatus());
    assertEquals(MediaType.PNG, res.getContentType());
    assertEquals("attachment; filename=logo.png", res.getHeaders().get("Content-Disposition"));
    assertSame(this.mediaBytes, res.getBody());
  }
Ejemplo n.º 2
0
  @Test
  public void getContentFound() throws Exception {
    setupContentAndSite();
    setupTemplates();

    final PortalResponse portalResponse =
        PortalResponse.create()
            .body("component rendered")
            .header("some-header", "some-value")
            .status(HttpStatus.OK)
            .build();

    setRendererResult(portalResponse);

    this.request.setContentPath(ContentPath.from("/site/somepath/content"));

    final PortalResponse res = this.handler.handle(this.request);
    assertNotNull(res);
    assertEquals(HttpStatus.OK, res.getStatus());
    assertEquals(MediaType.PLAIN_TEXT_UTF_8, res.getContentType());
    assertEquals("some-value", res.getHeaders().get("some-header"));
    assertEquals("component rendered", res.getBody());
  }