Skip to content

Commit 11f80c1

Browse files
committed
add unit test cases for dubbo-filter module
1 parent 023ba8d commit 11f80c1

File tree

5 files changed

+86
-1
lines changed

5 files changed

+86
-1
lines changed

dubbo-filter/dubbo-filter-cache/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<description>The cache module of dubbo project</description>
2929
<properties>
3030
<skip_maven_deploy>false</skip_maven_deploy>
31+
<hazelcast_version>3.9-EA</hazelcast_version>
3132
</properties>
3233
<dependencies>
3334
<dependency>
@@ -42,7 +43,7 @@
4243
<dependency>
4344
<groupId>com.hazelcast</groupId>
4445
<artifactId>hazelcast</artifactId>
45-
<version>3.9-EA</version>
46+
<version>${hazelcast_version}</version>
4647
</dependency>
4748
</dependencies>
4849
</project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.alibaba.dubbo.cache.support;
2+
3+
import com.alibaba.dubbo.cache.Cache;
4+
import com.alibaba.dubbo.common.URL;
5+
import com.alibaba.dubbo.rpc.Invocation;
6+
import com.alibaba.dubbo.rpc.RpcInvocation;
7+
8+
public abstract class AbstractCacheFactoryTest {
9+
10+
protected Cache constructCache() {
11+
URL url = URL.valueOf("test://test:11/test?cache=jcache");
12+
Invocation invocation = new RpcInvocation();
13+
return getCacheFactory().getCache(url, invocation);
14+
}
15+
16+
protected abstract AbstractCacheFactory getCacheFactory();
17+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.alibaba.dubbo.cache.support.jcache;
2+
3+
import com.alibaba.dubbo.cache.Cache;
4+
import com.alibaba.dubbo.cache.support.AbstractCacheFactory;
5+
import com.alibaba.dubbo.cache.support.AbstractCacheFactoryTest;
6+
import org.junit.Test;
7+
8+
import static org.hamcrest.core.Is.is;
9+
import static org.junit.Assert.assertThat;
10+
11+
public class JCacheFactoryTest extends AbstractCacheFactoryTest {
12+
13+
@Test
14+
public void testJCacheFactory() throws Exception {
15+
Cache cache = super.constructCache();
16+
assertThat(cache instanceof JCache, is(true));
17+
}
18+
19+
@Override
20+
protected AbstractCacheFactory getCacheFactory() {
21+
return new JCacheFactory();
22+
}
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.alibaba.dubbo.cache.support.lru;
2+
3+
import com.alibaba.dubbo.cache.Cache;
4+
import com.alibaba.dubbo.cache.support.AbstractCacheFactory;
5+
import com.alibaba.dubbo.cache.support.AbstractCacheFactoryTest;
6+
import org.junit.Test;
7+
8+
import static org.hamcrest.core.Is.is;
9+
import static org.junit.Assert.assertThat;
10+
11+
public class LruCacheFactoryTest extends AbstractCacheFactoryTest{
12+
@Test
13+
public void testLruCacheFactory() throws Exception {
14+
Cache cache = super.constructCache();
15+
assertThat(cache instanceof LruCache, is(true));
16+
}
17+
18+
@Override
19+
protected AbstractCacheFactory getCacheFactory() {
20+
return new LruCacheFactory();
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.alibaba.dubbo.cache.support.threadlocal;
2+
3+
import com.alibaba.dubbo.cache.Cache;
4+
import com.alibaba.dubbo.cache.support.AbstractCacheFactory;
5+
import com.alibaba.dubbo.cache.support.AbstractCacheFactoryTest;
6+
import org.junit.Test;
7+
8+
import static org.hamcrest.core.Is.is;
9+
import static org.junit.Assert.assertThat;
10+
11+
public class ThreadLocalCacheFactoryTest extends AbstractCacheFactoryTest {
12+
@Test
13+
public void testThreadLocalCacheFactory() throws Exception {
14+
Cache cache = super.constructCache();
15+
assertThat(cache instanceof ThreadLocalCache, is(true));
16+
}
17+
18+
@Override
19+
protected AbstractCacheFactory getCacheFactory() {
20+
return new ThreadLocalCacheFactory();
21+
}
22+
}

0 commit comments

Comments
 (0)