SuperX-Kernmodul
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 lines
1.6 KiB

package de.superx.servlet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import java.lang.reflect.Field;
import java.util.HashMap;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.fileupload.FileUploadException;
import org.junit.Test;
/**
* @author hiber
*/
public class CSVServletRequestTest extends BaseServletTest {
private CSVServletRequest csvServletRequest;
/**
* Test (using reflection) for
* {@link de.superx.servlet.CSVServletRequest}
*
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws NoSuchFieldException
* @throws SecurityException
*/
@Test
public void testConstructor() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
HashMap<String, String[]> params = new HashMap<>();
Exception neverThrownException = null;
try {
this.csvServletRequest = new CSVServletRequest(this.request, params);
} catch (FileUploadException e) {
neverThrownException = e;
}
assertNull("exception has not been thrown", neverThrownException);
assertEquals("passed map equals returned map", this.csvServletRequest.getParameterMap(), params);
Field requestField = this.csvServletRequest.getClass().getDeclaredField("r");
requestField.setAccessible(true);
HttpServletRequest privateRequestFieldValue = (HttpServletRequest) requestField.get(this.csvServletRequest);
assertEquals("passed request equals returned request", privateRequestFieldValue, this.request);
requestField.setAccessible(false);
}
}