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.portalapp.portal.framework;
22 //import java.io.IOException;
24 //import org.junit.Before;
25 //import org.junit.runner.RunWith;
26 //import org.openecomp.portalsdk.core.conf.AppConfig;
27 ////import org.openecomp.portalapp.conf.ExternalAppConfig;
28 ////import org.openecomp.portalapp.conf.HibernateMappingLocations;
29 //import org.openecomp.portalsdk.core.conf.HibernateConfiguration;
30 //import org.openecomp.portalsdk.core.conf.HibernateMappingLocatable;
31 //import org.openecomp.portalsdk.core.objectcache.AbstractCacheManager;
32 //import org.openecomp.portalsdk.core.util.CacheManager;
33 //import org.openecomp.portalsdk.core.util.SystemProperties;
34 //import org.springframework.beans.factory.annotation.Autowired;
35 //import org.springframework.context.annotation.Bean;
36 //import org.springframework.context.annotation.ComponentScan;
37 //import org.springframework.context.annotation.Configuration;
38 //import org.springframework.context.annotation.FilterType;
39 //import org.springframework.context.annotation.Profile;
40 //import org.springframework.core.io.ClassPathResource;
41 //import org.springframework.core.io.Resource;
42 //import org.springframework.test.context.ActiveProfiles;
43 //import org.springframework.test.context.ContextConfiguration;
44 //import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
45 //import org.springframework.test.context.web.AnnotationConfigWebContextLoader;
46 //import org.springframework.test.context.web.WebAppConfiguration;
47 //import org.springframework.test.web.servlet.MockMvc;
48 //import org.springframework.test.web.servlet.setup.MockMvcBuilders;
49 //import org.springframework.web.context.WebApplicationContext;
50 //import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
54 // * In order to write a unit test, 1. inherit this class 2. place the "war"
55 // * folder on your test class's classpath 3. run the test with the following VM
56 // * argument; This is important because when starting the application from
57 // * Container, the System Properties file (SystemProperties.java) can have the
58 // * direct path but, when running from the Mock Junit container, the path should
59 // * be prefixed with "classpath" to enable the mock container to search for the
60 // * file in the classpath -Dcontainer.classpath="classpath:"
63 //@SuppressWarnings("deprecation")
64 //@RunWith(SpringJUnit4ClassRunner.class)
65 //@WebAppConfiguration
66 //@ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = { MockAppConfig.class })
67 //@ActiveProfiles(value = "test")
68 //public class ApplicationCommonContextTestSuite {
71 // public WebApplicationContext wac;
73 // private MockMvc mockMvc;
76 // public void setup() {
77 // if (mockMvc == null) {
78 // this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
83 // public Object getBean(String name) {
84 // return this.wac.getBean(name);
87 // public MockMvc getMockMvc() {
91 // public void setMockMvc(MockMvc mockMvc) {
92 // this.mockMvc = mockMvc;
95 // public WebApplicationContext getWebApplicationContext() {
102 //@ComponentScan(basePackages = "org.openecomp", excludeFilters = {
103 // // the following source configurations should not be scanned; instead of
104 // // using Exclusion filter, we can use the @Profile annotation to exclude
106 // @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openecomp.portalsdk.core.controller.LogoutController*"),
107 // @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openecomp.portalsdk.core.controller.SDKLoginController*"),
108 // @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openecomp.portalapp.conf.ExternalAppConfig*"),
109 // @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.openecomp.*.*InitUebHandler*") })
111 //class MockAppConfig extends AppConfig {
114 // HibernateMappingLocatable locatable() {
115 // return new MockHibernateMappingLocations();
119 // HibernateConfiguration hibConfiguration() {
120 // return new HibernateConfiguration();
124 // public SystemProperties systemProperties() {
125 // return new MockSystemProperties();
129 // public AbstractCacheManager cacheManager() {
130 // return new CacheManager() {
132 // public void configure() throws IOException {
138 // public String[] tileDefinitions() {
139 // return new String[] { "classpath:/WEB-INF/fusion/defs/definitions.xml",
140 // "classpath:/WEB-INF/defs/definitions.xml" };
143 // public void addInterceptors(InterceptorRegistry registry) {
144 // // registry.addInterceptor(new
145 // // SessionTimeoutInterceptor()).excludePathPatterns(getExcludeUrlPathsForSessionTimeout());
146 // // registry.addInterceptor(resourceInterceptor());
149 // public static class MockSystemProperties extends SystemProperties {
151 // public MockSystemProperties() {
159 //class MockHibernateMappingLocations implements HibernateMappingLocatable {
161 // public Resource[] getMappingLocations() {
162 // return new Resource[] { new ClassPathResource("WEB-INF/fusion/orm/Fusion.hbm.xml"),
163 // new ClassPathResource("WEB-INF/fusion/orm/EP.hbm.xml"),
164 // new ClassPathResource("WEB-INF/fusion/orm/Workflow.hbm.xml") };
168 // public String[] getPackagesToScan() {
169 // return new String[] { "org.openecomp", "src" };