Skip to content
Snippets Groups Projects
Commit 59b201ae authored by Piotr Gawron's avatar Piotr Gawron
Browse files

log levels are restored properly

parent c7fdb6b6
No related branches found
No related tags found
1 merge request!836Resolve "Implement Spring Security"
Pipeline #11868 passed
......@@ -3,25 +3,25 @@ package lcsb.mapviewer.web;
import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import java.net.URI;
import java.util.*;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse;
import org.apache.logging.log4j.*;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configurator;
import org.junit.Test;
import org.junit.*;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.RequestBuilder;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import lcsb.mapviewer.api.BaseController;
@RunWith(SpringJUnit4ClassRunner.class)
public class EndPointsInputValidationTests extends ControllerIntegrationTest {
......@@ -34,10 +34,24 @@ public class EndPointsInputValidationTests extends ControllerIntegrationTest {
@Autowired
public RequestMappingHandlerMapping requestMappingHandlerMapping;
@Autowired
ServletContext container;
@Before
public void setUp() throws Exception {
Configurator.setAllLevels(LogManager.getRootLogger().getName(), Level.FATAL);
}
@After
public void tearDown() throws Exception {
String file = "src/test/resources/log4j2.properties";
LoggerContext context = (org.apache.logging.log4j.core.LoggerContext) org.apache.logging.log4j.LogManager
.getContext(false);
context.setConfigLocation(new URI(file));
}
@Test
public void testResponseStatusCodeFromEndpoints() throws Exception {
Configurator.setAllLevels(LogManager.getRootLogger().getName(), Level.FATAL);
for (RequestMappingInfo t : requestMappingHandlerMapping.getHandlerMethods().keySet()) {
for (String url : t.getPatternsCondition().getPatterns()) {
for (RequestMethod method : t.getMethodsCondition().getMethods()) {
......@@ -45,7 +59,6 @@ public class EndPointsInputValidationTests extends ControllerIntegrationTest {
}
}
}
Configurator.setAllLevels(LogManager.getRootLogger().getName(), Level.INFO);
}
private void testUrl(String url, RequestMethod method) throws Exception {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment