|
24 | 24 | import javax.servlet.ServletConfig;
|
25 | 25 | import javax.servlet.ServletContext;
|
26 | 26 | import javax.servlet.ServletException;
|
| 27 | +import javax.servlet.http.HttpServletRequest; |
27 | 28 | import java.io.IOException;
|
| 29 | +import java.util.Arrays; |
| 30 | +import java.util.Collections; |
28 | 31 | import java.util.Enumeration;
|
29 | 32 | import java.util.HashMap;
|
30 | 33 | import java.util.Map;
|
31 | 34 | import java.util.concurrent.atomic.AtomicReference;
|
32 | 35 |
|
33 | 36 | import static org.mockito.Mockito.mock;
|
| 37 | +import static org.mockito.Mockito.when; |
34 | 38 | import static org.testng.Assert.assertEquals;
|
35 | 39 | import static org.testng.Assert.assertFalse;
|
36 | 40 | import static org.testng.Assert.assertNotNull;
|
@@ -335,4 +339,17 @@ public void testForceContentType() throws Exception {
|
335 | 339 | assertNull(request.getContentType());
|
336 | 340 | }
|
337 | 341 |
|
| 342 | + @Test |
| 343 | + public void testWrapMethodWithNullAttributeValue() throws IOException, ServletException { |
| 344 | + HttpServletRequest mockRequest = mock(HttpServletRequest.class); |
| 345 | + when(mockRequest.getAttributeNames()).thenReturn(Collections.enumeration(Arrays.asList("org.eclipse.jetty.multipartConfig"))); |
| 346 | + when(mockRequest.getAttribute("org.eclipse.jetty.multipartConfig")).thenReturn(null); |
| 347 | + |
| 348 | + AtmosphereRequest wrappedRequest = AtmosphereRequestImpl.wrap(mockRequest); |
| 349 | + |
| 350 | + assertNotNull(wrappedRequest, "Wrapped request should not be null"); |
| 351 | + assertNull(wrappedRequest.getAttribute("org.eclipse.jetty.multipartConfig"), "Attribute value should be null"); |
| 352 | + } |
| 353 | + |
| 354 | + |
338 | 355 | }
|
0 commit comments