@Test public void testAfterFlushBufferIfBufferEmpty() throws IOException { MyResponse r = new MyResponse(c); r.buffer = new StringWriter(); PrintWriter p = r.getWriter(); p.write("asg"); r.flushBuffer(); StringWriter s = new StringWriter(); String str1 = new String(); String str2 = new String(); r.buffer.write(str1); s.write(str2); assertEquals(str1, str2); assertTrue(r.isCommitted()); }
@Test public void testreset() { MyContainer t = new MyContainer(); String args[] = new String[3]; args[0] = "/Users/karthikalle/Desktop/CIS 555/Homeworks/ms2/src/hw1/WEB-INF/web.xml"; args[1] = "GET"; args[2] = "cookie1"; att.put("requestVersion", "HTTP/1.1"); try { t.initialize(args[0], null); t.doWork(args, sock, att); } catch (Exception e1) { e1.printStackTrace(); } r.buffer = new StringWriter(); r.reset(); try { r.flushBuffer(); } catch (IOException e) { e.printStackTrace(); } }
@Test public void testIsCommitted() throws IOException { MyResponse r = new MyResponse(c); r.flushBuffer(); assertTrue(r.isCommitted()); }