|
|
|
@ -59,18 +59,26 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
OnCommittedResponseWrapperTests.this.committed = true; |
|
|
|
OnCommittedResponseWrapperTests.this.committed = true; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void givenGetWriterThenReturn() throws IOException { |
|
|
|
given(this.delegate.getWriter()).willReturn(this.writer); |
|
|
|
given(this.delegate.getWriter()).willReturn(this.writer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void givenGetOutputStreamThenReturn() throws IOException { |
|
|
|
given(this.delegate.getOutputStream()).willReturn(this.out); |
|
|
|
given(this.delegate.getOutputStream()).willReturn(this.out); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterHashCode() throws Exception { |
|
|
|
public void printWriterHashCode() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
int expected = this.writer.hashCode(); |
|
|
|
int expected = this.writer.hashCode(); |
|
|
|
assertThat(this.response.getWriter().hashCode()).isEqualTo(expected); |
|
|
|
assertThat(this.response.getWriter().hashCode()).isEqualTo(expected); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterCheckError() throws Exception { |
|
|
|
public void printWriterCheckError() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
boolean expected = true; |
|
|
|
boolean expected = true; |
|
|
|
given(this.writer.checkError()).willReturn(expected); |
|
|
|
given(this.writer.checkError()).willReturn(expected); |
|
|
|
assertThat(this.response.getWriter().checkError()).isEqualTo(expected); |
|
|
|
assertThat(this.response.getWriter().checkError()).isEqualTo(expected); |
|
|
|
@ -78,6 +86,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterWriteInt() throws Exception { |
|
|
|
public void printWriterWriteInt() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
int expected = 1; |
|
|
|
int expected = 1; |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
verify(this.writer).write(expected); |
|
|
|
verify(this.writer).write(expected); |
|
|
|
@ -85,6 +94,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterWriteCharIntInt() throws Exception { |
|
|
|
public void printWriterWriteCharIntInt() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char[] buff = new char[0]; |
|
|
|
char[] buff = new char[0]; |
|
|
|
int off = 2; |
|
|
|
int off = 2; |
|
|
|
int len = 3; |
|
|
|
int len = 3; |
|
|
|
@ -94,6 +104,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterWriteChar() throws Exception { |
|
|
|
public void printWriterWriteChar() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char[] buff = new char[0]; |
|
|
|
char[] buff = new char[0]; |
|
|
|
this.response.getWriter().write(buff); |
|
|
|
this.response.getWriter().write(buff); |
|
|
|
verify(this.writer).write(buff); |
|
|
|
verify(this.writer).write(buff); |
|
|
|
@ -101,6 +112,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterWriteStringIntInt() throws Exception { |
|
|
|
public void printWriterWriteStringIntInt() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String s = ""; |
|
|
|
String s = ""; |
|
|
|
int off = 2; |
|
|
|
int off = 2; |
|
|
|
int len = 3; |
|
|
|
int len = 3; |
|
|
|
@ -110,6 +122,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterWriteString() throws Exception { |
|
|
|
public void printWriterWriteString() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String s = ""; |
|
|
|
String s = ""; |
|
|
|
this.response.getWriter().write(s); |
|
|
|
this.response.getWriter().write(s); |
|
|
|
verify(this.writer).write(s); |
|
|
|
verify(this.writer).write(s); |
|
|
|
@ -117,6 +130,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintBoolean() throws Exception { |
|
|
|
public void printWriterPrintBoolean() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
boolean b = true; |
|
|
|
boolean b = true; |
|
|
|
this.response.getWriter().print(b); |
|
|
|
this.response.getWriter().print(b); |
|
|
|
verify(this.writer).print(b); |
|
|
|
verify(this.writer).print(b); |
|
|
|
@ -124,6 +138,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintChar() throws Exception { |
|
|
|
public void printWriterPrintChar() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char c = 1; |
|
|
|
char c = 1; |
|
|
|
this.response.getWriter().print(c); |
|
|
|
this.response.getWriter().print(c); |
|
|
|
verify(this.writer).print(c); |
|
|
|
verify(this.writer).print(c); |
|
|
|
@ -131,6 +146,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintInt() throws Exception { |
|
|
|
public void printWriterPrintInt() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
int i = 1; |
|
|
|
int i = 1; |
|
|
|
this.response.getWriter().print(i); |
|
|
|
this.response.getWriter().print(i); |
|
|
|
verify(this.writer).print(i); |
|
|
|
verify(this.writer).print(i); |
|
|
|
@ -138,6 +154,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintLong() throws Exception { |
|
|
|
public void printWriterPrintLong() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
long l = 1; |
|
|
|
long l = 1; |
|
|
|
this.response.getWriter().print(l); |
|
|
|
this.response.getWriter().print(l); |
|
|
|
verify(this.writer).print(l); |
|
|
|
verify(this.writer).print(l); |
|
|
|
@ -145,6 +162,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintFloat() throws Exception { |
|
|
|
public void printWriterPrintFloat() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
float f = 1; |
|
|
|
float f = 1; |
|
|
|
this.response.getWriter().print(f); |
|
|
|
this.response.getWriter().print(f); |
|
|
|
verify(this.writer).print(f); |
|
|
|
verify(this.writer).print(f); |
|
|
|
@ -152,6 +170,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintDouble() throws Exception { |
|
|
|
public void printWriterPrintDouble() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
double x = 1; |
|
|
|
double x = 1; |
|
|
|
this.response.getWriter().print(x); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
verify(this.writer).print(x); |
|
|
|
verify(this.writer).print(x); |
|
|
|
@ -159,6 +178,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintCharArray() throws Exception { |
|
|
|
public void printWriterPrintCharArray() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char[] x = new char[0]; |
|
|
|
char[] x = new char[0]; |
|
|
|
this.response.getWriter().print(x); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
verify(this.writer).print(x); |
|
|
|
verify(this.writer).print(x); |
|
|
|
@ -166,6 +186,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintString() throws Exception { |
|
|
|
public void printWriterPrintString() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String x = "1"; |
|
|
|
String x = "1"; |
|
|
|
this.response.getWriter().print(x); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
verify(this.writer).print(x); |
|
|
|
verify(this.writer).print(x); |
|
|
|
@ -173,6 +194,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintObject() throws Exception { |
|
|
|
public void printWriterPrintObject() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
Object x = "1"; |
|
|
|
Object x = "1"; |
|
|
|
this.response.getWriter().print(x); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
verify(this.writer).print(x); |
|
|
|
verify(this.writer).print(x); |
|
|
|
@ -180,12 +202,14 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintln() throws Exception { |
|
|
|
public void printWriterPrintln() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
this.response.getWriter().println(); |
|
|
|
this.response.getWriter().println(); |
|
|
|
verify(this.writer).println(); |
|
|
|
verify(this.writer).println(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintlnBoolean() throws Exception { |
|
|
|
public void printWriterPrintlnBoolean() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
boolean b = true; |
|
|
|
boolean b = true; |
|
|
|
this.response.getWriter().println(b); |
|
|
|
this.response.getWriter().println(b); |
|
|
|
verify(this.writer).println(b); |
|
|
|
verify(this.writer).println(b); |
|
|
|
@ -193,6 +217,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintlnChar() throws Exception { |
|
|
|
public void printWriterPrintlnChar() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char c = 1; |
|
|
|
char c = 1; |
|
|
|
this.response.getWriter().println(c); |
|
|
|
this.response.getWriter().println(c); |
|
|
|
verify(this.writer).println(c); |
|
|
|
verify(this.writer).println(c); |
|
|
|
@ -200,6 +225,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintlnInt() throws Exception { |
|
|
|
public void printWriterPrintlnInt() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
int i = 1; |
|
|
|
int i = 1; |
|
|
|
this.response.getWriter().println(i); |
|
|
|
this.response.getWriter().println(i); |
|
|
|
verify(this.writer).println(i); |
|
|
|
verify(this.writer).println(i); |
|
|
|
@ -207,6 +233,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintlnLong() throws Exception { |
|
|
|
public void printWriterPrintlnLong() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
long l = 1; |
|
|
|
long l = 1; |
|
|
|
this.response.getWriter().println(l); |
|
|
|
this.response.getWriter().println(l); |
|
|
|
verify(this.writer).println(l); |
|
|
|
verify(this.writer).println(l); |
|
|
|
@ -214,6 +241,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintlnFloat() throws Exception { |
|
|
|
public void printWriterPrintlnFloat() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
float f = 1; |
|
|
|
float f = 1; |
|
|
|
this.response.getWriter().println(f); |
|
|
|
this.response.getWriter().println(f); |
|
|
|
verify(this.writer).println(f); |
|
|
|
verify(this.writer).println(f); |
|
|
|
@ -221,6 +249,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintlnDouble() throws Exception { |
|
|
|
public void printWriterPrintlnDouble() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
double x = 1; |
|
|
|
double x = 1; |
|
|
|
this.response.getWriter().println(x); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
verify(this.writer).println(x); |
|
|
|
verify(this.writer).println(x); |
|
|
|
@ -228,6 +257,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintlnCharArray() throws Exception { |
|
|
|
public void printWriterPrintlnCharArray() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char[] x = new char[0]; |
|
|
|
char[] x = new char[0]; |
|
|
|
this.response.getWriter().println(x); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
verify(this.writer).println(x); |
|
|
|
verify(this.writer).println(x); |
|
|
|
@ -235,6 +265,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintlnString() throws Exception { |
|
|
|
public void printWriterPrintlnString() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String x = "1"; |
|
|
|
String x = "1"; |
|
|
|
this.response.getWriter().println(x); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
verify(this.writer).println(x); |
|
|
|
verify(this.writer).println(x); |
|
|
|
@ -242,6 +273,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintlnObject() throws Exception { |
|
|
|
public void printWriterPrintlnObject() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
Object x = "1"; |
|
|
|
Object x = "1"; |
|
|
|
this.response.getWriter().println(x); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
verify(this.writer).println(x); |
|
|
|
verify(this.writer).println(x); |
|
|
|
@ -249,6 +281,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintfStringObjectVargs() throws Exception { |
|
|
|
public void printWriterPrintfStringObjectVargs() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String format = "format"; |
|
|
|
String format = "format"; |
|
|
|
Object[] args = new Object[] { "1" }; |
|
|
|
Object[] args = new Object[] { "1" }; |
|
|
|
this.response.getWriter().printf(format, args); |
|
|
|
this.response.getWriter().printf(format, args); |
|
|
|
@ -257,6 +290,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterPrintfLocaleStringObjectVargs() throws Exception { |
|
|
|
public void printWriterPrintfLocaleStringObjectVargs() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
Locale l = Locale.US; |
|
|
|
Locale l = Locale.US; |
|
|
|
String format = "format"; |
|
|
|
String format = "format"; |
|
|
|
Object[] args = new Object[] { "1" }; |
|
|
|
Object[] args = new Object[] { "1" }; |
|
|
|
@ -266,6 +300,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterFormatStringObjectVargs() throws Exception { |
|
|
|
public void printWriterFormatStringObjectVargs() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String format = "format"; |
|
|
|
String format = "format"; |
|
|
|
Object[] args = new Object[] { "1" }; |
|
|
|
Object[] args = new Object[] { "1" }; |
|
|
|
this.response.getWriter().format(format, args); |
|
|
|
this.response.getWriter().format(format, args); |
|
|
|
@ -274,6 +309,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterFormatLocaleStringObjectVargs() throws Exception { |
|
|
|
public void printWriterFormatLocaleStringObjectVargs() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
Locale l = Locale.US; |
|
|
|
Locale l = Locale.US; |
|
|
|
String format = "format"; |
|
|
|
String format = "format"; |
|
|
|
Object[] args = new Object[] { "1" }; |
|
|
|
Object[] args = new Object[] { "1" }; |
|
|
|
@ -283,6 +319,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterAppendCharSequence() throws Exception { |
|
|
|
public void printWriterAppendCharSequence() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String x = "a"; |
|
|
|
String x = "a"; |
|
|
|
this.response.getWriter().append(x); |
|
|
|
this.response.getWriter().append(x); |
|
|
|
verify(this.writer).append(x); |
|
|
|
verify(this.writer).append(x); |
|
|
|
@ -290,6 +327,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterAppendCharSequenceIntInt() throws Exception { |
|
|
|
public void printWriterAppendCharSequenceIntInt() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String x = "abcdef"; |
|
|
|
String x = "abcdef"; |
|
|
|
int start = 1; |
|
|
|
int start = 1; |
|
|
|
int end = 3; |
|
|
|
int end = 3; |
|
|
|
@ -299,6 +337,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterAppendChar() throws Exception { |
|
|
|
public void printWriterAppendChar() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char x = 1; |
|
|
|
char x = 1; |
|
|
|
this.response.getWriter().append(x); |
|
|
|
this.response.getWriter().append(x); |
|
|
|
verify(this.writer).append(x); |
|
|
|
verify(this.writer).append(x); |
|
|
|
@ -307,12 +346,14 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
// servletoutputstream
|
|
|
|
// servletoutputstream
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamHashCode() throws Exception { |
|
|
|
public void outputStreamHashCode() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
int expected = this.out.hashCode(); |
|
|
|
int expected = this.out.hashCode(); |
|
|
|
assertThat(this.response.getOutputStream().hashCode()).isEqualTo(expected); |
|
|
|
assertThat(this.response.getOutputStream().hashCode()).isEqualTo(expected); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamWriteInt() throws Exception { |
|
|
|
public void outputStreamWriteInt() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
int expected = 1; |
|
|
|
int expected = 1; |
|
|
|
this.response.getOutputStream().write(expected); |
|
|
|
this.response.getOutputStream().write(expected); |
|
|
|
verify(this.out).write(expected); |
|
|
|
verify(this.out).write(expected); |
|
|
|
@ -320,6 +361,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamWriteByte() throws Exception { |
|
|
|
public void outputStreamWriteByte() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
byte[] expected = new byte[0]; |
|
|
|
byte[] expected = new byte[0]; |
|
|
|
this.response.getOutputStream().write(expected); |
|
|
|
this.response.getOutputStream().write(expected); |
|
|
|
verify(this.out).write(expected); |
|
|
|
verify(this.out).write(expected); |
|
|
|
@ -327,6 +369,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamWriteByteIntInt() throws Exception { |
|
|
|
public void outputStreamWriteByteIntInt() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
int start = 1; |
|
|
|
int start = 1; |
|
|
|
int end = 2; |
|
|
|
int end = 2; |
|
|
|
byte[] expected = new byte[0]; |
|
|
|
byte[] expected = new byte[0]; |
|
|
|
@ -336,6 +379,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintBoolean() throws Exception { |
|
|
|
public void outputStreamPrintBoolean() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
boolean b = true; |
|
|
|
boolean b = true; |
|
|
|
this.response.getOutputStream().print(b); |
|
|
|
this.response.getOutputStream().print(b); |
|
|
|
verify(this.out).print(b); |
|
|
|
verify(this.out).print(b); |
|
|
|
@ -343,6 +387,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintChar() throws Exception { |
|
|
|
public void outputStreamPrintChar() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
char c = 1; |
|
|
|
char c = 1; |
|
|
|
this.response.getOutputStream().print(c); |
|
|
|
this.response.getOutputStream().print(c); |
|
|
|
verify(this.out).print(c); |
|
|
|
verify(this.out).print(c); |
|
|
|
@ -350,6 +395,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintInt() throws Exception { |
|
|
|
public void outputStreamPrintInt() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
int i = 1; |
|
|
|
int i = 1; |
|
|
|
this.response.getOutputStream().print(i); |
|
|
|
this.response.getOutputStream().print(i); |
|
|
|
verify(this.out).print(i); |
|
|
|
verify(this.out).print(i); |
|
|
|
@ -357,6 +403,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintLong() throws Exception { |
|
|
|
public void outputStreamPrintLong() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
long l = 1; |
|
|
|
long l = 1; |
|
|
|
this.response.getOutputStream().print(l); |
|
|
|
this.response.getOutputStream().print(l); |
|
|
|
verify(this.out).print(l); |
|
|
|
verify(this.out).print(l); |
|
|
|
@ -364,6 +411,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintFloat() throws Exception { |
|
|
|
public void outputStreamPrintFloat() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
float f = 1; |
|
|
|
float f = 1; |
|
|
|
this.response.getOutputStream().print(f); |
|
|
|
this.response.getOutputStream().print(f); |
|
|
|
verify(this.out).print(f); |
|
|
|
verify(this.out).print(f); |
|
|
|
@ -371,6 +419,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintDouble() throws Exception { |
|
|
|
public void outputStreamPrintDouble() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
double x = 1; |
|
|
|
double x = 1; |
|
|
|
this.response.getOutputStream().print(x); |
|
|
|
this.response.getOutputStream().print(x); |
|
|
|
verify(this.out).print(x); |
|
|
|
verify(this.out).print(x); |
|
|
|
@ -378,6 +427,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintString() throws Exception { |
|
|
|
public void outputStreamPrintString() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
String x = "1"; |
|
|
|
String x = "1"; |
|
|
|
this.response.getOutputStream().print(x); |
|
|
|
this.response.getOutputStream().print(x); |
|
|
|
verify(this.out).print(x); |
|
|
|
verify(this.out).print(x); |
|
|
|
@ -385,12 +435,14 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintln() throws Exception { |
|
|
|
public void outputStreamPrintln() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
this.response.getOutputStream().println(); |
|
|
|
this.response.getOutputStream().println(); |
|
|
|
verify(this.out).println(); |
|
|
|
verify(this.out).println(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintlnBoolean() throws Exception { |
|
|
|
public void outputStreamPrintlnBoolean() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
boolean b = true; |
|
|
|
boolean b = true; |
|
|
|
this.response.getOutputStream().println(b); |
|
|
|
this.response.getOutputStream().println(b); |
|
|
|
verify(this.out).println(b); |
|
|
|
verify(this.out).println(b); |
|
|
|
@ -398,6 +450,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintlnChar() throws Exception { |
|
|
|
public void outputStreamPrintlnChar() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
char c = 1; |
|
|
|
char c = 1; |
|
|
|
this.response.getOutputStream().println(c); |
|
|
|
this.response.getOutputStream().println(c); |
|
|
|
verify(this.out).println(c); |
|
|
|
verify(this.out).println(c); |
|
|
|
@ -405,6 +458,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintlnInt() throws Exception { |
|
|
|
public void outputStreamPrintlnInt() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
int i = 1; |
|
|
|
int i = 1; |
|
|
|
this.response.getOutputStream().println(i); |
|
|
|
this.response.getOutputStream().println(i); |
|
|
|
verify(this.out).println(i); |
|
|
|
verify(this.out).println(i); |
|
|
|
@ -412,6 +466,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintlnLong() throws Exception { |
|
|
|
public void outputStreamPrintlnLong() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
long l = 1; |
|
|
|
long l = 1; |
|
|
|
this.response.getOutputStream().println(l); |
|
|
|
this.response.getOutputStream().println(l); |
|
|
|
verify(this.out).println(l); |
|
|
|
verify(this.out).println(l); |
|
|
|
@ -419,6 +474,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintlnFloat() throws Exception { |
|
|
|
public void outputStreamPrintlnFloat() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
float f = 1; |
|
|
|
float f = 1; |
|
|
|
this.response.getOutputStream().println(f); |
|
|
|
this.response.getOutputStream().println(f); |
|
|
|
verify(this.out).println(f); |
|
|
|
verify(this.out).println(f); |
|
|
|
@ -426,6 +482,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintlnDouble() throws Exception { |
|
|
|
public void outputStreamPrintlnDouble() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
double x = 1; |
|
|
|
double x = 1; |
|
|
|
this.response.getOutputStream().println(x); |
|
|
|
this.response.getOutputStream().println(x); |
|
|
|
verify(this.out).println(x); |
|
|
|
verify(this.out).println(x); |
|
|
|
@ -433,6 +490,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void outputStreamPrintlnString() throws Exception { |
|
|
|
public void outputStreamPrintlnString() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
String x = "1"; |
|
|
|
String x = "1"; |
|
|
|
this.response.getOutputStream().println(x); |
|
|
|
this.response.getOutputStream().println(x); |
|
|
|
verify(this.out).println(x); |
|
|
|
verify(this.out).println(x); |
|
|
|
@ -443,6 +501,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
// gh-3823
|
|
|
|
// gh-3823
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterWriteNullCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterWriteNullCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String expected = null; |
|
|
|
String expected = null; |
|
|
|
this.response.setContentLength(String.valueOf(expected).length() + 1); |
|
|
|
this.response.setContentLength(String.valueOf(expected).length() + 1); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
@ -453,6 +512,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterWriteIntCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterWriteIntCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
int expected = 1; |
|
|
|
int expected = 1; |
|
|
|
this.response.setContentLength(String.valueOf(expected).length()); |
|
|
|
this.response.setContentLength(String.valueOf(expected).length()); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
@ -461,6 +521,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterWriteIntMultiDigitCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterWriteIntMultiDigitCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
int expected = 10000; |
|
|
|
int expected = 10000; |
|
|
|
this.response.setContentLength(String.valueOf(expected).length()); |
|
|
|
this.response.setContentLength(String.valueOf(expected).length()); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
@ -469,6 +530,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPlus1PrintWriterWriteIntMultiDigitCommits() throws Exception { |
|
|
|
public void contentLengthPlus1PrintWriterWriteIntMultiDigitCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
int expected = 10000; |
|
|
|
int expected = 10000; |
|
|
|
this.response.setContentLength(String.valueOf(expected).length() + 1); |
|
|
|
this.response.setContentLength(String.valueOf(expected).length() + 1); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
@ -479,6 +541,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterWriteCharIntIntCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterWriteCharIntIntCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char[] buff = new char[0]; |
|
|
|
char[] buff = new char[0]; |
|
|
|
int off = 2; |
|
|
|
int off = 2; |
|
|
|
int len = 3; |
|
|
|
int len = 3; |
|
|
|
@ -489,6 +552,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterWriteCharCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterWriteCharCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char[] buff = new char[4]; |
|
|
|
char[] buff = new char[4]; |
|
|
|
this.response.setContentLength(buff.length); |
|
|
|
this.response.setContentLength(buff.length); |
|
|
|
this.response.getWriter().write(buff); |
|
|
|
this.response.getWriter().write(buff); |
|
|
|
@ -497,6 +561,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterWriteStringIntIntCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterWriteStringIntIntCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String s = ""; |
|
|
|
String s = ""; |
|
|
|
int off = 2; |
|
|
|
int off = 2; |
|
|
|
int len = 3; |
|
|
|
int len = 3; |
|
|
|
@ -507,6 +572,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterWriteStringCommits() throws IOException { |
|
|
|
public void contentLengthPrintWriterWriteStringCommits() throws IOException { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String body = "something"; |
|
|
|
String body = "something"; |
|
|
|
this.response.setContentLength(body.length()); |
|
|
|
this.response.setContentLength(body.length()); |
|
|
|
this.response.getWriter().write(body); |
|
|
|
this.response.getWriter().write(body); |
|
|
|
@ -515,6 +581,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterWriteStringContentLengthCommits() throws IOException { |
|
|
|
public void printWriterWriteStringContentLengthCommits() throws IOException { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String body = "something"; |
|
|
|
String body = "something"; |
|
|
|
this.response.getWriter().write(body); |
|
|
|
this.response.getWriter().write(body); |
|
|
|
this.response.setContentLength(body.length()); |
|
|
|
this.response.setContentLength(body.length()); |
|
|
|
@ -523,6 +590,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void printWriterWriteStringDoesNotCommit() throws IOException { |
|
|
|
public void printWriterWriteStringDoesNotCommit() throws IOException { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String body = "something"; |
|
|
|
String body = "something"; |
|
|
|
this.response.getWriter().write(body); |
|
|
|
this.response.getWriter().write(body); |
|
|
|
assertThat(this.committed).isFalse(); |
|
|
|
assertThat(this.committed).isFalse(); |
|
|
|
@ -530,6 +598,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintBooleanCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintBooleanCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
boolean b = true; |
|
|
|
boolean b = true; |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.getWriter().print(b); |
|
|
|
this.response.getWriter().print(b); |
|
|
|
@ -538,6 +607,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintCharCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintCharCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char c = 1; |
|
|
|
char c = 1; |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.getWriter().print(c); |
|
|
|
this.response.getWriter().print(c); |
|
|
|
@ -546,6 +616,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintIntCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintIntCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
int i = 1234; |
|
|
|
int i = 1234; |
|
|
|
this.response.setContentLength(String.valueOf(i).length()); |
|
|
|
this.response.setContentLength(String.valueOf(i).length()); |
|
|
|
this.response.getWriter().print(i); |
|
|
|
this.response.getWriter().print(i); |
|
|
|
@ -554,6 +625,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintLongCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintLongCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
long l = 12345; |
|
|
|
long l = 12345; |
|
|
|
this.response.setContentLength(String.valueOf(l).length()); |
|
|
|
this.response.setContentLength(String.valueOf(l).length()); |
|
|
|
this.response.getWriter().print(l); |
|
|
|
this.response.getWriter().print(l); |
|
|
|
@ -562,6 +634,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintFloatCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintFloatCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
float f = 12345; |
|
|
|
float f = 12345; |
|
|
|
this.response.setContentLength(String.valueOf(f).length()); |
|
|
|
this.response.setContentLength(String.valueOf(f).length()); |
|
|
|
this.response.getWriter().print(f); |
|
|
|
this.response.getWriter().print(f); |
|
|
|
@ -570,6 +643,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintDoubleCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintDoubleCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
double x = 1.2345; |
|
|
|
double x = 1.2345; |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
@ -578,6 +652,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintCharArrayCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintCharArrayCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char[] x = new char[10]; |
|
|
|
char[] x = new char[10]; |
|
|
|
this.response.setContentLength(x.length); |
|
|
|
this.response.setContentLength(x.length); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
@ -586,6 +661,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintStringCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintStringCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String x = "12345"; |
|
|
|
String x = "12345"; |
|
|
|
this.response.setContentLength(x.length()); |
|
|
|
this.response.setContentLength(x.length()); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
@ -594,6 +670,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintObjectCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintObjectCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
Object x = "12345"; |
|
|
|
Object x = "12345"; |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
this.response.getWriter().print(x); |
|
|
|
@ -602,6 +679,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintlnCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintlnCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
this.response.setContentLength(NL.length()); |
|
|
|
this.response.setContentLength(NL.length()); |
|
|
|
this.response.getWriter().println(); |
|
|
|
this.response.getWriter().println(); |
|
|
|
assertThat(this.committed).isTrue(); |
|
|
|
assertThat(this.committed).isTrue(); |
|
|
|
@ -609,6 +687,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintlnBooleanCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintlnBooleanCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
boolean b = true; |
|
|
|
boolean b = true; |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.getWriter().println(b); |
|
|
|
this.response.getWriter().println(b); |
|
|
|
@ -617,6 +696,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintlnCharCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintlnCharCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char c = 1; |
|
|
|
char c = 1; |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.getWriter().println(c); |
|
|
|
this.response.getWriter().println(c); |
|
|
|
@ -625,6 +705,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintlnIntCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintlnIntCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
int i = 12345; |
|
|
|
int i = 12345; |
|
|
|
this.response.setContentLength(String.valueOf(i).length()); |
|
|
|
this.response.setContentLength(String.valueOf(i).length()); |
|
|
|
this.response.getWriter().println(i); |
|
|
|
this.response.getWriter().println(i); |
|
|
|
@ -633,6 +714,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintlnLongCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintlnLongCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
long l = 12345678; |
|
|
|
long l = 12345678; |
|
|
|
this.response.setContentLength(String.valueOf(l).length()); |
|
|
|
this.response.setContentLength(String.valueOf(l).length()); |
|
|
|
this.response.getWriter().println(l); |
|
|
|
this.response.getWriter().println(l); |
|
|
|
@ -641,6 +723,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintlnFloatCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintlnFloatCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
float f = 1234; |
|
|
|
float f = 1234; |
|
|
|
this.response.setContentLength(String.valueOf(f).length()); |
|
|
|
this.response.setContentLength(String.valueOf(f).length()); |
|
|
|
this.response.getWriter().println(f); |
|
|
|
this.response.getWriter().println(f); |
|
|
|
@ -649,6 +732,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintlnDoubleCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintlnDoubleCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
double x = 1; |
|
|
|
double x = 1; |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
@ -657,6 +741,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintlnCharArrayCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintlnCharArrayCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char[] x = new char[20]; |
|
|
|
char[] x = new char[20]; |
|
|
|
this.response.setContentLength(x.length); |
|
|
|
this.response.setContentLength(x.length); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
@ -665,6 +750,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintlnStringCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintlnStringCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String x = "1"; |
|
|
|
String x = "1"; |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
@ -673,6 +759,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterPrintlnObjectCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterPrintlnObjectCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
Object x = "1"; |
|
|
|
Object x = "1"; |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
this.response.getWriter().println(x); |
|
|
|
@ -681,6 +768,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterAppendCharSequenceCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterAppendCharSequenceCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String x = "a"; |
|
|
|
String x = "a"; |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.getWriter().append(x); |
|
|
|
this.response.getWriter().append(x); |
|
|
|
@ -689,6 +777,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterAppendCharSequenceIntIntCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterAppendCharSequenceIntIntCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String x = "abcdef"; |
|
|
|
String x = "abcdef"; |
|
|
|
int start = 1; |
|
|
|
int start = 1; |
|
|
|
int end = 3; |
|
|
|
int end = 3; |
|
|
|
@ -699,6 +788,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPrintWriterAppendCharCommits() throws Exception { |
|
|
|
public void contentLengthPrintWriterAppendCharCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
char x = 1; |
|
|
|
char x = 1; |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.getWriter().append(x); |
|
|
|
this.response.getWriter().append(x); |
|
|
|
@ -707,6 +797,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamWriteIntCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamWriteIntCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
int expected = 1; |
|
|
|
int expected = 1; |
|
|
|
this.response.setContentLength(String.valueOf(expected).length()); |
|
|
|
this.response.setContentLength(String.valueOf(expected).length()); |
|
|
|
this.response.getOutputStream().write(expected); |
|
|
|
this.response.getOutputStream().write(expected); |
|
|
|
@ -715,6 +806,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamWriteIntMultiDigitCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamWriteIntMultiDigitCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
int expected = 10000; |
|
|
|
int expected = 10000; |
|
|
|
this.response.setContentLength(String.valueOf(expected).length()); |
|
|
|
this.response.setContentLength(String.valueOf(expected).length()); |
|
|
|
this.response.getOutputStream().write(expected); |
|
|
|
this.response.getOutputStream().write(expected); |
|
|
|
@ -723,6 +815,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPlus1OutputStreamWriteIntMultiDigitCommits() throws Exception { |
|
|
|
public void contentLengthPlus1OutputStreamWriteIntMultiDigitCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
int expected = 10000; |
|
|
|
int expected = 10000; |
|
|
|
this.response.setContentLength(String.valueOf(expected).length() + 1); |
|
|
|
this.response.setContentLength(String.valueOf(expected).length() + 1); |
|
|
|
this.response.getOutputStream().write(expected); |
|
|
|
this.response.getOutputStream().write(expected); |
|
|
|
@ -734,6 +827,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
// gh-171
|
|
|
|
// gh-171
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthPlus1OutputStreamWriteByteArrayMultiDigitCommits() throws Exception { |
|
|
|
public void contentLengthPlus1OutputStreamWriteByteArrayMultiDigitCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
String expected = "{\n" + " \"parameterName\" : \"_csrf\",\n" |
|
|
|
String expected = "{\n" + " \"parameterName\" : \"_csrf\",\n" |
|
|
|
+ " \"token\" : \"06300b65-c4aa-4c8f-8cda-39ee17f545a0\",\n" + " \"headerName\" : \"X-CSRF-TOKEN\"\n" |
|
|
|
+ " \"token\" : \"06300b65-c4aa-4c8f-8cda-39ee17f545a0\",\n" + " \"headerName\" : \"X-CSRF-TOKEN\"\n" |
|
|
|
+ "}"; |
|
|
|
+ "}"; |
|
|
|
@ -746,6 +840,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintBooleanCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintBooleanCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
boolean b = true; |
|
|
|
boolean b = true; |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.getOutputStream().print(b); |
|
|
|
this.response.getOutputStream().print(b); |
|
|
|
@ -754,6 +849,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintCharCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintCharCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
char c = 1; |
|
|
|
char c = 1; |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.getOutputStream().print(c); |
|
|
|
this.response.getOutputStream().print(c); |
|
|
|
@ -762,6 +858,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintIntCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintIntCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
int i = 1234; |
|
|
|
int i = 1234; |
|
|
|
this.response.setContentLength(String.valueOf(i).length()); |
|
|
|
this.response.setContentLength(String.valueOf(i).length()); |
|
|
|
this.response.getOutputStream().print(i); |
|
|
|
this.response.getOutputStream().print(i); |
|
|
|
@ -770,6 +867,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintLongCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintLongCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
long l = 12345; |
|
|
|
long l = 12345; |
|
|
|
this.response.setContentLength(String.valueOf(l).length()); |
|
|
|
this.response.setContentLength(String.valueOf(l).length()); |
|
|
|
this.response.getOutputStream().print(l); |
|
|
|
this.response.getOutputStream().print(l); |
|
|
|
@ -778,6 +876,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintFloatCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintFloatCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
float f = 12345; |
|
|
|
float f = 12345; |
|
|
|
this.response.setContentLength(String.valueOf(f).length()); |
|
|
|
this.response.setContentLength(String.valueOf(f).length()); |
|
|
|
this.response.getOutputStream().print(f); |
|
|
|
this.response.getOutputStream().print(f); |
|
|
|
@ -786,6 +885,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintDoubleCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintDoubleCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
double x = 1.2345; |
|
|
|
double x = 1.2345; |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.getOutputStream().print(x); |
|
|
|
this.response.getOutputStream().print(x); |
|
|
|
@ -794,6 +894,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintStringCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintStringCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
String x = "12345"; |
|
|
|
String x = "12345"; |
|
|
|
this.response.setContentLength(x.length()); |
|
|
|
this.response.setContentLength(x.length()); |
|
|
|
this.response.getOutputStream().print(x); |
|
|
|
this.response.getOutputStream().print(x); |
|
|
|
@ -802,6 +903,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintlnCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintlnCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
this.response.setContentLength(NL.length()); |
|
|
|
this.response.setContentLength(NL.length()); |
|
|
|
this.response.getOutputStream().println(); |
|
|
|
this.response.getOutputStream().println(); |
|
|
|
assertThat(this.committed).isTrue(); |
|
|
|
assertThat(this.committed).isTrue(); |
|
|
|
@ -809,6 +911,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintlnBooleanCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintlnBooleanCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
boolean b = true; |
|
|
|
boolean b = true; |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.getOutputStream().println(b); |
|
|
|
this.response.getOutputStream().println(b); |
|
|
|
@ -817,6 +920,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintlnCharCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintlnCharCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
char c = 1; |
|
|
|
char c = 1; |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.setContentLength(1); |
|
|
|
this.response.getOutputStream().println(c); |
|
|
|
this.response.getOutputStream().println(c); |
|
|
|
@ -825,6 +929,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintlnIntCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintlnIntCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
int i = 12345; |
|
|
|
int i = 12345; |
|
|
|
this.response.setContentLength(String.valueOf(i).length()); |
|
|
|
this.response.setContentLength(String.valueOf(i).length()); |
|
|
|
this.response.getOutputStream().println(i); |
|
|
|
this.response.getOutputStream().println(i); |
|
|
|
@ -833,6 +938,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintlnLongCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintlnLongCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
long l = 12345678; |
|
|
|
long l = 12345678; |
|
|
|
this.response.setContentLength(String.valueOf(l).length()); |
|
|
|
this.response.setContentLength(String.valueOf(l).length()); |
|
|
|
this.response.getOutputStream().println(l); |
|
|
|
this.response.getOutputStream().println(l); |
|
|
|
@ -841,6 +947,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintlnFloatCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintlnFloatCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
float f = 1234; |
|
|
|
float f = 1234; |
|
|
|
this.response.setContentLength(String.valueOf(f).length()); |
|
|
|
this.response.setContentLength(String.valueOf(f).length()); |
|
|
|
this.response.getOutputStream().println(f); |
|
|
|
this.response.getOutputStream().println(f); |
|
|
|
@ -849,6 +956,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintlnDoubleCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintlnDoubleCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
double x = 1; |
|
|
|
double x = 1; |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.getOutputStream().println(x); |
|
|
|
this.response.getOutputStream().println(x); |
|
|
|
@ -857,6 +965,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamPrintlnStringCommits() throws Exception { |
|
|
|
public void contentLengthOutputStreamPrintlnStringCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
String x = "1"; |
|
|
|
String x = "1"; |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.setContentLength(String.valueOf(x).length()); |
|
|
|
this.response.getOutputStream().println(x); |
|
|
|
this.response.getOutputStream().println(x); |
|
|
|
@ -872,6 +981,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthOutputStreamWriteStringCommits() throws IOException { |
|
|
|
public void contentLengthOutputStreamWriteStringCommits() throws IOException { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
String body = "something"; |
|
|
|
String body = "something"; |
|
|
|
this.response.setContentLength(body.length()); |
|
|
|
this.response.setContentLength(body.length()); |
|
|
|
this.response.getOutputStream().print(body); |
|
|
|
this.response.getOutputStream().print(body); |
|
|
|
@ -881,6 +991,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
// gh-7261
|
|
|
|
// gh-7261
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void contentLengthLongOutputStreamWriteStringCommits() throws IOException { |
|
|
|
public void contentLengthLongOutputStreamWriteStringCommits() throws IOException { |
|
|
|
|
|
|
|
givenGetOutputStreamThenReturn(); |
|
|
|
String body = "something"; |
|
|
|
String body = "something"; |
|
|
|
this.response.setContentLengthLong(body.length()); |
|
|
|
this.response.setContentLengthLong(body.length()); |
|
|
|
this.response.getOutputStream().print(body); |
|
|
|
this.response.getOutputStream().print(body); |
|
|
|
@ -889,6 +1000,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void addHeaderContentLengthPrintWriterWriteStringCommits() throws Exception { |
|
|
|
public void addHeaderContentLengthPrintWriterWriteStringCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
int expected = 1234; |
|
|
|
int expected = 1234; |
|
|
|
this.response.addHeader("Content-Length", String.valueOf(String.valueOf(expected).length())); |
|
|
|
this.response.addHeader("Content-Length", String.valueOf(String.valueOf(expected).length())); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
@ -897,6 +1009,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void bufferSizePrintWriterWriteCommits() throws Exception { |
|
|
|
public void bufferSizePrintWriterWriteCommits() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String expected = "1234567890"; |
|
|
|
String expected = "1234567890"; |
|
|
|
given(this.response.getBufferSize()).willReturn(expected.length()); |
|
|
|
given(this.response.getBufferSize()).willReturn(expected.length()); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
@ -905,6 +1018,7 @@ public class OnCommittedResponseWrapperTests { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void bufferSizeCommitsOnce() throws Exception { |
|
|
|
public void bufferSizeCommitsOnce() throws Exception { |
|
|
|
|
|
|
|
givenGetWriterThenReturn(); |
|
|
|
String expected = "1234567890"; |
|
|
|
String expected = "1234567890"; |
|
|
|
given(this.response.getBufferSize()).willReturn(expected.length()); |
|
|
|
given(this.response.getBufferSize()).willReturn(expected.length()); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
this.response.getWriter().write(expected); |
|
|
|
|