96c4172931ffa28f8c462bfe13df460b10821ac4
[portal.git] / ecomp-portal-BE-common / src / test / java / org / onap / portalapp / portal / framework / ApplicationCommonContextTestSuite.java
1 package org.onap.portalapp.portal.framework;
2 /*-
3  * ============LICENSE_START==========================================
4  * ONAP Portal
5  * ===================================================================
6  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
7  * ===================================================================
8  *
9  * Unless otherwise specified, all software contained herein is licensed
10  * under the Apache License, Version 2.0 (the "License");
11  * you may not use this software except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  *             http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  * Unless otherwise specified, all documentation contained herein is licensed
23  * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
24  * you may not use this documentation except in compliance with the License.
25  * You may obtain a copy of the License at
26  *
27  *             https://creativecommons.org/licenses/by/4.0/
28  *
29  * Unless required by applicable law or agreed to in writing, documentation
30  * distributed under the License is distributed on an "AS IS" BASIS,
31  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32  * See the License for the specific language governing permissions and
33  * limitations under the License.
34  *
35  * ============LICENSE_END============================================
36  *
37  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
38  */
39 //package org.onap.portalapp.portal.framework;
40 //
41 //import java.io.IOException;
42 //
43 //import org.junit.Before;
44 //import org.junit.runner.RunWith;
45 //import org.onap.portalsdk.core.conf.AppConfig;
46 ////import org.onap.portalapp.conf.ExternalAppConfig;
47 ////import org.onap.portalapp.conf.HibernateMappingLocations;
48 //import org.onap.portalsdk.core.conf.HibernateConfiguration;
49 //import org.onap.portalsdk.core.conf.HibernateMappingLocatable;
50 //import org.onap.portalsdk.core.objectcache.AbstractCacheManager;
51 //import org.onap.portalsdk.core.util.CacheManager;
52 //import org.onap.portalsdk.core.util.SystemProperties;
53 //import org.springframework.beans.factory.annotation.Autowired;
54 //import org.springframework.context.annotation.Bean;
55 //import org.springframework.context.annotation.ComponentScan;
56 //import org.springframework.context.annotation.Configuration;
57 //import org.springframework.context.annotation.FilterType;
58 //import org.springframework.context.annotation.Profile;
59 //import org.springframework.core.io.ClassPathResource;
60 //import org.springframework.core.io.Resource;
61 //import org.springframework.test.context.ActiveProfiles;
62 //import org.springframework.test.context.ContextConfiguration;
63 //import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
64 //import org.springframework.test.context.web.AnnotationConfigWebContextLoader;
65 //import org.springframework.test.context.web.WebAppConfiguration;
66 //import org.springframework.test.web.servlet.MockMvc;
67 //import org.springframework.test.web.servlet.setup.MockMvcBuilders;
68 //import org.springframework.web.context.WebApplicationContext;
69 //import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
70 //
71 ///**
72 // * 
73 // * In order to write a unit test, 1. inherit this class 2. place the "war"
74 // * folder on your test class's classpath 3. run the test with the following VM
75 // * argument; This is important because when starting the application from
76 // * Container, the System Properties file (SystemProperties.java) can have the
77 // * direct path but, when running from the Mock Junit container, the path should
78 // * be prefixed with "classpath" to enable the mock container to search for the
79 // * file in the classpath -Dcontainer.classpath="classpath:"
80 // */
81 //
82 //@SuppressWarnings("deprecation")
83 //@RunWith(SpringJUnit4ClassRunner.class)
84 //@WebAppConfiguration
85 //@ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = { MockAppConfig.class })
86 //@ActiveProfiles(value = "test")
87 //public class ApplicationCommonContextTestSuite {
88 //
89 //      @Autowired
90 //      public WebApplicationContext wac;
91 //
92 //      private MockMvc mockMvc;
93 //
94 //      @Before
95 //      public void setup() {
96 //              if (mockMvc == null) {
97 //                      this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
98 //
99 //              }
100 //      }
101 //
102 //      public Object getBean(String name) {
103 //              return this.wac.getBean(name);
104 //      }
105 //
106 //      public MockMvc getMockMvc() {
107 //              return mockMvc;
108 //      }
109 //
110 //      public void setMockMvc(MockMvc mockMvc) {
111 //              this.mockMvc = mockMvc;
112 //      }
113 //
114 //      public WebApplicationContext getWebApplicationContext() {
115 //              return wac;
116 //      }
117 //
118 //}
119 //
120 //@Configuration
121 //@ComponentScan(basePackages = "org.onap", excludeFilters = {
122 //              // the following source configurations should not be scanned; instead of
123 //              // using Exclusion filter, we can use the @Profile annotation to exclude
124 //              // them
125 //              @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.onap.portalsdk.core.controller.LogoutController*"),
126 //              @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.onap.portalsdk.core.controller.SDKLoginController*"),
127 //              @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.onap.portalapp.conf.ExternalAppConfig*"),
128 //              @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.onap.*.*InitUebHandler*") })
129 //@Profile("test")
130 //class MockAppConfig extends AppConfig {
131 //
132 //      @Bean
133 //      HibernateMappingLocatable locatable() {
134 //              return new MockHibernateMappingLocations();
135 //      }
136 //
137 //      @Bean
138 //      HibernateConfiguration hibConfiguration() {
139 //              return new HibernateConfiguration();
140 //      }
141 //
142 //      @Bean
143 //      public SystemProperties systemProperties() {
144 //              return new MockSystemProperties();
145 //      }
146 //
147 //      @Bean
148 //      public AbstractCacheManager cacheManager() {
149 //              return new CacheManager() {
150 //
151 //                      public void configure() throws IOException {
152 //
153 //                      }
154 //              };
155 //      }
156 //
157 //      public String[] tileDefinitions() {
158 //              return new String[] { "classpath:/WEB-INF/fusion/defs/definitions.xml",
159 //                              "classpath:/WEB-INF/defs/definitions.xml" };
160 //      }
161 //
162 //      public void addInterceptors(InterceptorRegistry registry) {
163 //              // registry.addInterceptor(new
164 //              // SessionTimeoutInterceptor()).excludePathPatterns(getExcludeUrlPathsForSessionTimeout());
165 //              // registry.addInterceptor(resourceInterceptor());
166 //      }
167 //
168 //      public static class MockSystemProperties extends SystemProperties {
169 //
170 //              public MockSystemProperties() {
171 //              }
172 //
173 //      }
174 //
175 //}
176 //
177 //@Profile("test")
178 //class MockHibernateMappingLocations implements HibernateMappingLocatable {
179 //
180 //      public Resource[] getMappingLocations() {
181 //              return new Resource[] { new ClassPathResource("WEB-INF/fusion/orm/Fusion.hbm.xml"),
182 //                              new ClassPathResource("WEB-INF/fusion/orm/EP.hbm.xml"),
183 //                              new ClassPathResource("WEB-INF/fusion/orm/Workflow.hbm.xml") };
184 //
185 //      }
186 //
187 //      public String[] getPackagesToScan() {
188 //              return new String[] { "org.onap", "src" };
189 //      }
190 //
191 //}