Пример #1
0
  @Test
  public void testUnicodeCharacters() throws Exception {
    response.add("\uba80\uba81\uba82\uba83");
    response.closeAll();

    assertSubString("\uba80\uba81\uba82\uba83", buffer.toString());
  }
Пример #2
0
 @Test
 public void testCantAddZeroLengthBytes() throws Exception {
   int originalLength = buffer.length();
   response.add("");
   assertEquals(originalLength, buffer.length());
   response.closeAll();
 }
Пример #3
0
 @Test
 public void testTrailingHeaders() throws Exception {
   response.closeChunks();
   buffer = new StringBuffer();
   response.addTrailingHeader("Some-Header", "someValue");
   assertEquals("Some-Header: someValue\r\n", buffer.toString());
   response.closeTrailer();
   response.close();
   assertTrue(closed);
 }
Пример #4
0
 @Test
 public void xmlHeaders() throws Exception {
   response = new ChunkedResponse("xml");
   response.readyToSend(this);
   assertTrue(response.isReadyToSend());
   assertTrue(response.isReadyToSend());
   String text = buffer.toString();
   assertHasRegexp("Transfer-Encoding: chunked", text);
   assertTrue(text.startsWith("HTTP/1.1 200 OK\r\n"));
   assertHasRegexp("Content-Type: text/xml", text);
 }
Пример #5
0
 @Test
 public void testClosingInSteps() throws Exception {
   assertFalse(closed);
   buffer = new StringBuffer();
   response.closeChunks();
   assertEquals("0\r\n", buffer.toString());
   assertFalse(closed);
   buffer = new StringBuffer();
   response.closeTrailer();
   assertEquals("\r\n", buffer.toString());
   assertFalse(closed);
   response.close();
   assertTrue(closed);
 }
Пример #6
0
  @Before
  public void setUp() throws Exception {
    buffer = new StringBuffer();

    response = new ChunkedResponse("html");
    response.readyToSend(this);
  }
Пример #7
0
  @Test
  public void testOneChunk() throws Exception {
    buffer = new StringBuffer();
    response.add("some more text");

    String text = buffer.toString();
    assertEquals("e\r\nsome more text\r\n", text);
  }
Пример #8
0
 @Test
 public void testSimpleClosing() throws Exception {
   assertFalse(closed);
   buffer = new StringBuffer();
   response.closeAll();
   String text = buffer.toString();
   assertEquals("0\r\n\r\n", text);
   assertTrue(closed);
 }
Пример #9
0
  @Test
  public void testTwoChunks() throws Exception {
    buffer = new StringBuffer();
    response.add("one");
    response.add("two");

    String text = buffer.toString();
    assertEquals("3\r\none\r\n3\r\ntwo\r\n", text);
  }
Пример #10
0
 @Test
 public void testNoNullPointerException() throws Exception {
   String s = null;
   try {
     response.add(s);
   } catch (Exception e) {
     fail("should not throw exception");
   }
 }
Пример #11
0
 @After
 public void tearDown() throws Exception {
   response.closeAll();
 }
Пример #12
0
 @Test
 public void testContentSize() throws Exception {
   response.add("12345");
   response.closeAll();
   assertEquals(5, response.getContentSize());
 }