96d7f310027f6a5fb89025a94250f37494e86b9b
[portal.git] / ecomp-portal-BE-common / src / test / java / org / openecomp / portalapp / portal / framework / ApplicationCommonContextTestSuite.java
1 ///*-
2 // * ================================================================================
3 // * ECOMP Portal
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.portalapp.portal.framework;
21 //
22 //import java.io.IOException;
23 //
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;
51 //
52 ///**
53 // * 
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:"
61 // */
62 //
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 {
69 //
70 //      @Autowired
71 //      public WebApplicationContext wac;
72 //
73 //      private MockMvc mockMvc;
74 //
75 //      @Before
76 //      public void setup() {
77 //              if (mockMvc == null) {
78 //                      this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
79 //
80 //              }
81 //      }
82 //
83 //      public Object getBean(String name) {
84 //              return this.wac.getBean(name);
85 //      }
86 //
87 //      public MockMvc getMockMvc() {
88 //              return mockMvc;
89 //      }
90 //
91 //      public void setMockMvc(MockMvc mockMvc) {
92 //              this.mockMvc = mockMvc;
93 //      }
94 //
95 //      public WebApplicationContext getWebApplicationContext() {
96 //              return wac;
97 //      }
98 //
99 //}
100 //
101 //@Configuration
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
105 //              // them
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*") })
110 //@Profile("test")
111 //class MockAppConfig extends AppConfig {
112 //
113 //      @Bean
114 //      HibernateMappingLocatable locatable() {
115 //              return new MockHibernateMappingLocations();
116 //      }
117 //
118 //      @Bean
119 //      HibernateConfiguration hibConfiguration() {
120 //              return new HibernateConfiguration();
121 //      }
122 //
123 //      @Bean
124 //      public SystemProperties systemProperties() {
125 //              return new MockSystemProperties();
126 //      }
127 //
128 //      @Bean
129 //      public AbstractCacheManager cacheManager() {
130 //              return new CacheManager() {
131 //
132 //                      public void configure() throws IOException {
133 //
134 //                      }
135 //              };
136 //      }
137 //
138 //      public String[] tileDefinitions() {
139 //              return new String[] { "classpath:/WEB-INF/fusion/defs/definitions.xml",
140 //                              "classpath:/WEB-INF/defs/definitions.xml" };
141 //      }
142 //
143 //      public void addInterceptors(InterceptorRegistry registry) {
144 //              // registry.addInterceptor(new
145 //              // SessionTimeoutInterceptor()).excludePathPatterns(getExcludeUrlPathsForSessionTimeout());
146 //              // registry.addInterceptor(resourceInterceptor());
147 //      }
148 //
149 //      public static class MockSystemProperties extends SystemProperties {
150 //
151 //              public MockSystemProperties() {
152 //              }
153 //
154 //      }
155 //
156 //}
157 //
158 //@Profile("test")
159 //class MockHibernateMappingLocations implements HibernateMappingLocatable {
160 //
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") };
165 //
166 //      }
167 //
168 //      public String[] getPackagesToScan() {
169 //              return new String[] { "org.openecomp", "src" };
170 //      }
171 //
172 //}