Relative Content

Tag Archive for spring-boot

Spring boot test can not cast GenericWebApplicationContext

I’m new with spring boot. I follow clean architecture with spring boot in this link https://www.baeldung.com/spring-boot-clean-architecture In this tutorial, spring context load bean with bean factory. Then when I want to test API with MockMvc. I write test class follow this:

Is there anyway to access the configurable values

public class HumanAgentSocket extends TextWebSocketHandler { @Value(“${human.agents.available}”) private int availableHumanAgents; private List<WebSocketSession> sessions = new ArrayList<>(); private List<String> sessionIds = new ArrayList<>(); private HashMap<WebSocketSession,WebSocketSession> socketConnections = new HashMap<WebSocketSession,WebSocketSession>(); private int noOfHumanAgents = 1; private ObjectMapper objectMapper = new ObjectMapper(); @Override public void afterConnectionEstablished(WebSocketSession session) throws IOException { if (noOfHumanAgents<=5){ System.out.println(“Agents “+availableHumanAgents); sessions.add(session); sessionIds.add(session.getId()); System.out.println(“List “+sessionIds); […]