-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change ehCache storage location (#3184)
* fix cache storage location and adding condition on cache controller creation Signed-off-by: at670475 <[email protected]> * change condition on cacheconfig Signed-off-by: at670475 <[email protected]> * fix license check Signed-off-by: at670475 <[email protected]> * make bean matchable by default Signed-off-by: at670475 <[email protected]> * fix code smell Signed-off-by: at670475 <[email protected]> * remove config Signed-off-by: at670475 <[email protected]> * add test Signed-off-by: at670475 <[email protected]> * add test Signed-off-by: at670475 <[email protected]> * fix test name Signed-off-by: at670475 <[email protected]> --------- Signed-off-by: at670475 <[email protected]>
- Loading branch information
Showing
5 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
gateway-service/src/main/java/org/zowe/apiml/gateway/config/NoOpCacheConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
package org.zowe.apiml.gateway.config; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.cache.CacheManager; | ||
import org.springframework.cache.annotation.EnableCaching; | ||
import org.springframework.cache.support.NoOpCacheManager; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.zowe.apiml.util.CacheUtils; | ||
|
||
/** | ||
* Spring configuration to disable EhCache usage. | ||
*/ | ||
@EnableCaching | ||
@Configuration | ||
@ConditionalOnProperty(value = "apiml.caching.enabled", havingValue = "false") | ||
public class NoOpCacheConfig { | ||
@Bean | ||
public CacheManager cacheManager() { | ||
return new NoOpCacheManager(); | ||
} | ||
|
||
@Bean | ||
public CacheUtils cacheUtils() { | ||
return new CacheUtils(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
gateway-service/src/test/java/org/zowe/apiml/gateway/config/CacheConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
package org.zowe.apiml.gateway.config; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.cache.CacheManager; | ||
import org.springframework.cache.jcache.JCacheCacheManager; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = CacheConfig.class) | ||
@ActiveProfiles("test") | ||
class CacheConfigTest { | ||
|
||
@Autowired | ||
private CacheManager cacheManager; | ||
|
||
@Test | ||
void testCacheManagerIsRealImplementation() { | ||
assertNotNull(cacheManager); | ||
assertTrue(cacheManager instanceof JCacheCacheManager); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
gateway-service/src/test/java/org/zowe/apiml/gateway/config/NoOpCacheConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
package org.zowe.apiml.gateway.config; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.cache.CacheManager; | ||
import org.springframework.cache.support.NoOpCacheManager; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = NoOpCacheConfig.class, properties = "apiml.caching.enabled=false") | ||
@ActiveProfiles("test") | ||
class NoOpCacheConfigTest { | ||
@Autowired | ||
private CacheManager cacheManager; | ||
|
||
@Test | ||
void testDisabledCacheManager() { | ||
assertNotNull(cacheManager); | ||
assertTrue(cacheManager instanceof NoOpCacheManager); | ||
} | ||
} |