-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unit test for MockRemoteCache auto configuration.
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
jetcache-test/src/test/java/com/alicp/jetcache/autoconfigure/MockStarterTest.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,54 @@ | ||
package com.alicp.jetcache.autoconfigure; | ||
|
||
import com.alicp.jetcache.Cache; | ||
import com.alicp.jetcache.anno.CreateCache; | ||
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation; | ||
import com.alicp.jetcache.anno.config.EnableMethodCache; | ||
import com.alicp.jetcache.test.beans.MyFactoryBean; | ||
import com.alicp.jetcache.test.spring.SpringTest; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
/** | ||
* Created on 2019/6/21. | ||
* | ||
* @author <a href="mailto:[email protected]">huangli</a> | ||
*/ | ||
@Configuration | ||
@EnableAutoConfiguration | ||
@ComponentScan(basePackages = {"com.alicp.jetcache.test.beans", "com.alicp.jetcache.anno.inittestbeans"}) | ||
@EnableMethodCache(basePackages = {"com.alicp.jetcache.test.beans", "com.alicp.jetcache.anno.inittestbeans"}) | ||
@EnableCreateCacheAnnotation | ||
public class MockStarterTest extends SpringTest { | ||
|
||
@Test | ||
public void tests() throws Exception { | ||
System.setProperty("spring.profiles.active", "mock"); | ||
context = SpringApplication.run(MockStarterTest.class); | ||
doTest(); | ||
} | ||
|
||
@Component | ||
public static class A { | ||
@CreateCache | ||
private Cache cache; | ||
|
||
@PostConstruct | ||
public void test() { | ||
Assert.assertTrue(cache.PUT("K", "V").isSuccess()); | ||
} | ||
} | ||
|
||
@Bean(name = "factoryBeanTarget") | ||
public MyFactoryBean factoryBean() { | ||
return new MyFactoryBean(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
jetcache-test/src/test/resources/config/application-mock.yml
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,32 @@ | ||
jetcache: | ||
statIntervalMinutes: 15 | ||
areaInCacheName: false | ||
penetrationProtect: false | ||
|
||
local: | ||
default: | ||
type: caffeine | ||
keyConvertor: fastjson | ||
limit: 200 | ||
defaultExpireInMillis: 10000 | ||
A1: | ||
type: linkedhashmap | ||
keyConvertor: fastjson | ||
limit: 100 | ||
expireAfterAccess: true | ||
defaultExpireInMillis: 10000 | ||
remote: | ||
default: | ||
type: mock | ||
keyConvertor: fastjson | ||
defaultExpireInMillis: 10000 | ||
keyPrefix: mockprefix | ||
A1: | ||
type: mock | ||
keyConvertor: fastjson | ||
defaultExpireInMillis: 10000 | ||
keyPrefix: mockprefix_a1 | ||
|
||
|
||
|
||
|