Package br.com.caelum.vraptor.observer.download

Examples of br.com.caelum.vraptor.observer.download.InputStreamDownload


    for (Entry<Object, Object> entry : entrySet) {
      sb.append(String.format("%-50s %s\n", entry.getKey(), entry.getValue()));
    }
    sb.append(String.format("%-50s %s\n", "Charset.defaultCharset()", Charset.defaultCharset()));

    return new InputStreamDownload(new ByteArrayInputStream(sb.toString().getBytes()), "text/plain", "log.log");
  }
View Full Code Here


    }
    LOG.debug("accessing file: " + file.getCanonicalPath());
    if (!file.exists()) {
      throw new IllegalStateException("file not found");
    }
    return new InputStreamDownload(new FileInputStream(file), "text/plain", "log.log");
  }
View Full Code Here

    when(response.getOutputStream()).thenReturn(socketStream);
  }

  @Test
  public void shouldFlushWholeStreamToHttpResponse() throws IOException {
    InputStreamDownload fd = new InputStreamDownload(inputStream, "type", "x.txt");
    fd.write(response);
   
    assertArrayEquals(bytes, outputStream.toByteArray());
  }
View Full Code Here

    assertArrayEquals(bytes, outputStream.toByteArray());
  }

  @Test
  public void shouldUseHeadersToHttpResponse() throws IOException {
    InputStreamDownload fd = new InputStreamDownload(inputStream, "type", "x.txt");
    fd.write(response);

    verify(response).setHeader("Content-type", "type");
    assertArrayEquals(bytes, outputStream.toByteArray());
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.observer.download.InputStreamDownload

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.