@@ -48,7 +48,8 @@ public void testBuilder_defaults() {
4848 assertThat (initParameters .isIllegalArgumentBackendError ()).isFalse ();
4949 assertThat (initParameters .isExceptionCompatibilityEnabled ()).isTrue ();
5050 assertThat (initParameters .isPrettyPrintEnabled ()).isTrue ();
51- verifyAsMap (initParameters , "" , "true" , "true" , "false" , "true" , "true" );
51+ assertThat (initParameters .isAddContentLength ()).isFalse ();
52+ verifyAsMap (initParameters , "" , "true" , "true" , "false" , "true" , "true" , "false" );
5253 }
5354
5455 @ Test
@@ -60,13 +61,14 @@ public void testBuilder_emptySetsAndTrue() {
6061 .setIllegalArgumentBackendError (true )
6162 .setExceptionCompatibilityEnabled (true )
6263 .setPrettyPrintEnabled (true )
64+ .setAddContentLength (true )
6365 .build ();
6466 assertThat (initParameters .getServiceClasses ()).isEmpty ();
6567 assertThat (initParameters .isServletRestricted ()).isTrue ();
6668 assertThat (initParameters .isClientIdWhitelistEnabled ()).isTrue ();
6769 assertThat (initParameters .isIllegalArgumentBackendError ()).isTrue ();
6870 assertThat (initParameters .isExceptionCompatibilityEnabled ()).isTrue ();
69- verifyAsMap (initParameters , "" , "true" , "true" , "true" , "true" , "true" );
71+ verifyAsMap (initParameters , "" , "true" , "true" , "true" , "true" , "true" , "true" );
7072 }
7173
7274 @ Test
@@ -78,12 +80,13 @@ public void testBuilder_oneEntrySetsAndFalse() {
7880 .setIllegalArgumentBackendError (false )
7981 .setExceptionCompatibilityEnabled (false )
8082 .setPrettyPrintEnabled (false )
83+ .setAddContentLength (false )
8184 .build ();
8285 assertThat (initParameters .getServiceClasses ()).containsExactly (String .class );
8386 assertThat (initParameters .isServletRestricted ()).isFalse ();
8487 assertThat (initParameters .isClientIdWhitelistEnabled ()).isFalse ();
8588 verifyAsMap (
86- initParameters , String .class .getName (), "false" , "false" , "false" , "false" , "false" );
89+ initParameters , String .class .getName (), "false" , "false" , "false" , "false" , "false" , "false" );
8790 }
8891
8992 @ Test
@@ -93,7 +96,7 @@ public void testBuilder_twoEntrySets() {
9396 .build ();
9497 assertThat (initParameters .getServiceClasses ()).containsExactly (String .class , Integer .class );
9598 verifyAsMap (initParameters , String .class .getName () + ',' + Integer .class .getName (), "true" ,
96- "true" , "false" , "true" , "true" );
99+ "true" , "false" , "true" , "true" , "false" );
97100 }
98101
99102 @ Test
@@ -108,7 +111,7 @@ public void testFromServletConfig_nullConfig() throws ServletException {
108111 @ Test
109112 public void testFromServletConfig_nullValues () throws ServletException {
110113 ServletInitializationParameters initParameters =
111- fromServletConfig (null , null , null , null , null , null );
114+ fromServletConfig (null , null , null , null , null , null , null );
112115 assertThat (initParameters .getServiceClasses ()).isEmpty ();
113116 assertThat (initParameters .isServletRestricted ()).isTrue ();
114117 assertThat (initParameters .isClientIdWhitelistEnabled ()).isTrue ();
@@ -120,7 +123,7 @@ public void testFromServletConfig_nullValues() throws ServletException {
120123 @ Test
121124 public void testFromServletConfig_emptySetsAndFalse () throws ServletException {
122125 ServletInitializationParameters initParameters =
123- fromServletConfig ("" , "false" , "false" , "false" , "false" , "false" );
126+ fromServletConfig ("" , "false" , "false" , "false" , "false" , "false" , "false" );
124127 assertThat (initParameters .getServiceClasses ()).isEmpty ();
125128 assertThat (initParameters .isServletRestricted ()).isFalse ();
126129 assertThat (initParameters .isClientIdWhitelistEnabled ()).isFalse ();
@@ -132,7 +135,7 @@ public void testFromServletConfig_emptySetsAndFalse() throws ServletException {
132135 @ Test
133136 public void testFromServletConfig_oneEntrySetsAndTrue () throws ServletException {
134137 ServletInitializationParameters initParameters =
135- fromServletConfig (String .class .getName (), "true" , "true" , "true" , "true" , "true" );
138+ fromServletConfig (String .class .getName (), "true" , "true" , "true" , "true" , "true" , "true" );
136139 assertThat (initParameters .getServiceClasses ()).containsExactly (String .class );
137140 assertThat (initParameters .isServletRestricted ()).isTrue ();
138141 assertThat (initParameters .isClientIdWhitelistEnabled ()).isTrue ();
@@ -144,22 +147,22 @@ public void testFromServletConfig_oneEntrySetsAndTrue() throws ServletException
144147 @ Test
145148 public void testFromServletConfig_twoEntrySets () throws ServletException {
146149 ServletInitializationParameters initParameters = fromServletConfig (
147- String .class .getName () + ',' + Integer .class .getName (), null , null , null , null , null );
150+ String .class .getName () + ',' + Integer .class .getName (), null , null , null , null , null , null );
148151 assertThat (initParameters .getServiceClasses ()).containsExactly (String .class , Integer .class );
149152 }
150153
151154 @ Test
152155 public void testFromServletConfig_skipsEmptyElements () throws ServletException {
153156 ServletInitializationParameters initParameters = fromServletConfig (
154157 ",," + String .class .getName () + ",,," + Integer .class .getName () + "," , null , null , null ,
155- null , null );
158+ null , null , null );
156159 assertThat (initParameters .getServiceClasses ()).containsExactly (String .class , Integer .class );
157160 }
158161
159162 @ Test
160163 public void testFromServletConfig_invalidRestrictedThrows () throws ServletException {
161164 try {
162- fromServletConfig (null , "yes" , null , null , null , null );
165+ fromServletConfig (null , "yes" , null , null , null , null , null );
163166 fail ("Expected IllegalArgumentException" );
164167 } catch (IllegalArgumentException expected ) {
165168 // expected
@@ -170,25 +173,27 @@ private void verifyAsMap(
170173 ServletInitializationParameters initParameters , String serviceClasses ,
171174 String isServletRestricted , String isClientIdWhitelistEnabled ,
172175 String isIllegalArgumentBackendError , String isExceptionCompatibilityEnabled ,
173- String isPrettyPrintEnabled ) {
176+ String isPrettyPrintEnabled , String isAddContentLength ) {
174177 Map <String , String > map = initParameters .asMap ();
175- assertThat (map ).hasSize (6 );
178+ assertThat (map ).hasSize (7 );
176179 assertThat (map .get ("services" )).isEqualTo (serviceClasses );
177180 assertThat (map .get ("restricted" )).isEqualTo (isServletRestricted );
178181 assertThat (map .get ("clientIdWhitelistEnabled" )).isEqualTo (isClientIdWhitelistEnabled );
179182 assertThat (map .get ("illegalArgumentIsBackendError" )).isEqualTo (isIllegalArgumentBackendError );
180183 assertThat (map .get ("enableExceptionCompatibility" )).isEqualTo (isExceptionCompatibilityEnabled );
181184 assertThat (map .get ("prettyPrint" )).isEqualTo (isPrettyPrintEnabled );
185+ assertThat (map .get ("addContentLength" )).isEqualTo (isAddContentLength );
182186 }
183187
184188 private ServletInitializationParameters fromServletConfig (
185189 String serviceClasses , String isServletRestricted ,
186190 String isClientIdWhitelistEnabled , String isIllegalArgumentBackendError ,
187- String isExceptionCompatibilityEnabled , String isPrettyPrintEnabled )
191+ String isExceptionCompatibilityEnabled , String isPrettyPrintEnabled ,
192+ String isAddContentLength )
188193 throws ServletException {
189194 ServletConfig servletConfig = new StubServletConfig (serviceClasses ,
190195 isServletRestricted , isClientIdWhitelistEnabled , isIllegalArgumentBackendError ,
191- isExceptionCompatibilityEnabled , isPrettyPrintEnabled );
196+ isExceptionCompatibilityEnabled , isPrettyPrintEnabled , isAddContentLength );
192197 return ServletInitializationParameters .fromServletConfig (
193198 servletConfig , getClass ().getClassLoader ());
194199 }
@@ -199,14 +204,15 @@ private static class StubServletConfig implements ServletConfig {
199204 public StubServletConfig (
200205 String serviceClasses , String isServletRestricted , String isClientIdWhitelistEnabled ,
201206 String isIllegalArgumentBackendError , String isExceptionCompatibilityEnabled ,
202- String isPrettyPrintEnabled ) {
207+ String isPrettyPrintEnabled , String isAddContentLength ) {
203208 initParameters = Maps .newHashMap ();
204209 initParameters .put ("services" , serviceClasses );
205210 initParameters .put ("restricted" , isServletRestricted );
206211 initParameters .put ("clientIdWhitelistEnabled" , isClientIdWhitelistEnabled );
207212 initParameters .put ("illegalArgumentIsBackendError" , isIllegalArgumentBackendError );
208213 initParameters .put ("enableExceptionCompatibility" , isExceptionCompatibilityEnabled );
209214 initParameters .put ("prettyPrint" , isPrettyPrintEnabled );
215+ initParameters .put ("addContentLength" , isAddContentLength );
210216 }
211217
212218 @ Override
0 commit comments