2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 package org.openecomp.portalsdk.controller.sessionmgt;
21 /*package org.openecomp.portalsdk.controller.sessionmgt;
23 import org.junit.Assert;
24 import org.junit.Test;
25 import org.springframework.mock.web.MockHttpSession;
26 import org.springframework.test.web.servlet.ResultActions;
27 import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
28 import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
30 import org.openecomp.portalsdk.MockApplicationContextTestSuite;
31 import org.openecomp.portalsdk.service.sessionmgt.CoreTimeoutHandler;
33 public class PortalCommunicationTest extends MockApplicationContextTestSuite{
37 public void testGetTimeoutSessions() throws Exception {
39 MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/api/sessionTimeOuts");
40 MockHttpSession httpSession = new MockHttpSession(this.wac.getServletContext(),"1234");
41 CoreTimeoutHandler.sessionCreated("12", "1234", httpSession);
43 ResultActions ra = this.getMockMvc().perform(requestBuilder);
45 System.out.println(" %%%%%%%%%%%%%%%%%%%%%%%%% " + ra.andReturn().getResponse().getContentAsString());
46 System.out.println(" %%%%%%%%%%%%%%%%%%%%%%%%% " + "{\"12\":{\"jSessionId\":\"1234\",\"sessionTimOutMilliSec\":");
48 Assert.assertTrue(ra.andReturn().getResponse().getContentAsString().startsWith("{\"12\":{\"jSessionId\":\"1234\",\"sessionTimOutMilliSec\":"));
53 public void testUpdateTimeoutSessions() throws Exception {
56 MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/api/sessionTimeOuts");
57 MockHttpSession httpSession = new MockHttpSession(this.wac.getServletContext(),"1234");
58 CoreTimeoutHandler.sessionCreated("12", "1234", httpSession);
59 ResultActions ra = this.getMockMvc().perform(requestBuilder);
61 String responseSessMapStr = ra.andReturn().getResponse().getContentAsString();
65 requestBuilder = MockMvcRequestBuilders.post("/api/updateSessionTimeOuts");
66 requestBuilder.param("sessionMap", responseSessMapStr);
67 ra = this.getMockMvc().perform(requestBuilder);