BAEL-6848: Set a Parameter in a HttpServletRequest in Java

This commit is contained in:
Manfred 2023-09-02 23:14:33 +01:00
parent 8c54cce5d1
commit 6cb7a375cc
5 changed files with 11 additions and 11 deletions

View File

@ -12,7 +12,7 @@ import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.junit.Test;
public class LanguageServletIntegrationTest {
public class LanguageServletLiveTest {
@Test
public void whenGetRequestUsingHttpClient_thenResponseBodyContainsDefaultLanguage() throws Exception {

View File

@ -14,7 +14,7 @@ import org.apache.http.util.EntityUtils;
import org.junit.BeforeClass;
import org.junit.Test;
public class SanitizeParametersRequestIntegrationTest {
public class SanitizeParametersRequestLiveTest {
private static String PARAM_INPUT;

View File

@ -1,8 +1,8 @@
package com.baeldung.setparam;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.mockito.Mockito.when;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.HashMap;
import java.util.Map;
@ -18,7 +18,7 @@ import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class SanitizeParametersRequestWrapperUnitTest {
private String NEW_VALUE = "NEW VALUE";
private static final String NEW_VALUE = "NEW VALUE";
private Map<String, String[]> parameterMap;
@ -37,7 +37,7 @@ public class SanitizeParametersRequestWrapperUnitTest {
SanitizeParametersRequestWrapper wrapper = new SanitizeParametersRequestWrapper(request);
String actualValue = wrapper.getParameter("input");
assertEquals(actualValue, "&lt;script&gt;alert('Hello');&lt;/script&gt;");
assertEquals("&lt;script&gt;alert('Hello');&lt;/script&gt;", actualValue);
}
@Test(expected = UnsupportedOperationException.class)
@ -54,7 +54,7 @@ public class SanitizeParametersRequestWrapperUnitTest {
firstCallValues[0] = NEW_VALUE;
String[] secondCallValues = wrapper.getParameterValues("input");
assertNotEquals(firstCallValues, secondCallValues);
assertThat(secondCallValues).doesNotContain(NEW_VALUE);
}
}

View File

@ -1,7 +1,7 @@
package com.baeldung.setparam;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.mockito.Mockito.when;
import java.util.HashMap;
@ -18,7 +18,7 @@ import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class SetParameterRequestWrapperUnitTest {
private String NEW_VALUE = "NEW VALUE";
private static final String NEW_VALUE = "NEW VALUE";
private Map<String, String[]> parameterMap;
@ -38,7 +38,7 @@ public class SetParameterRequestWrapperUnitTest {
wrapper.setParameter("newInput", "newInputValue");
String actualValue = wrapper.getParameter("newInput");
assertEquals(actualValue, "newInputValue");
assertEquals("newInputValue", actualValue);
}
@Test(expected = UnsupportedOperationException.class)
@ -55,7 +55,7 @@ public class SetParameterRequestWrapperUnitTest {
firstCallValues[0] = NEW_VALUE;
String[] secondCallValues = wrapper.getParameterValues("input");
assertNotEquals(firstCallValues, secondCallValues);
assertThat(secondCallValues).doesNotContain(NEW_VALUE);
}
}

View File

@ -14,7 +14,7 @@ import org.apache.http.util.EntityUtils;
import org.junit.BeforeClass;
import org.junit.Test;
public class UnsanitizedParametersRequestIntegrationTest {
public class UnsanitizedParametersRequestLiveTest {
private static final String TAG_SCRIPT = "<script>alert('Hello');</script>";