6b87dbe4079786afffa181c5922efc57c9227f8f
[portal/sdk.git] /
1 /*-
2  * ================================================================================
3  * eCOMP Portal SDK
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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  * ================================================================================
19  */
20 package org.openecomp.portalsdk.controller.sessionmgt;
21 /*package org.openecomp.portalsdk.controller.sessionmgt;
22
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;
29
30 import org.openecomp.portalsdk.MockApplicationContextTestSuite;
31 import org.openecomp.portalsdk.service.sessionmgt.CoreTimeoutHandler;
32
33 public class PortalCommunicationTest extends MockApplicationContextTestSuite{
34         
35         
36         @Test
37         public void testGetTimeoutSessions() throws Exception {
38
39                 MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/api/sessionTimeOuts");
40                 MockHttpSession httpSession = new MockHttpSession(this.wac.getServletContext(),"1234");
41                 CoreTimeoutHandler.sessionCreated("12", "1234", httpSession);
42                 
43                 ResultActions ra = this.getMockMvc().perform(requestBuilder);
44
45                 System.out.println(" %%%%%%%%%%%%%%%%%%%%%%%%% " + ra.andReturn().getResponse().getContentAsString());
46                 System.out.println(" %%%%%%%%%%%%%%%%%%%%%%%%% " + "{\"12\":{\"jSessionId\":\"1234\",\"sessionTimOutMilliSec\":");
47                 
48                 Assert.assertTrue(ra.andReturn().getResponse().getContentAsString().startsWith("{\"12\":{\"jSessionId\":\"1234\",\"sessionTimOutMilliSec\":"));
49
50         }
51         
52         @Test
53         public void testUpdateTimeoutSessions() throws Exception {
54                 
55                 // pre condition
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);
60         
61                 String responseSessMapStr = ra.andReturn().getResponse().getContentAsString();
62                 
63                 
64                 // test
65                 requestBuilder = MockMvcRequestBuilders.post("/api/updateSessionTimeOuts");
66                 requestBuilder.param("sessionMap", responseSessMapStr);
67                 ra = this.getMockMvc().perform(requestBuilder);
68                 
69                 
70         }
71         
72         
73
74 }
75 */