Skip to content

Commit

Permalink
unit test for MockRemoteCache auto configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
areyouok committed Jun 21, 2019
1 parent af36a76 commit 7203cc7
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
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 jetcache-test/src/test/resources/config/application-mock.yml
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




0 comments on commit 7203cc7

Please sign in to comment.