Skip to content

Commit b1bcb83

Browse files
author
Dan Blaisdell
committed
unit tests for MongoCacheBuilder
1 parent 1d6ad5c commit b1bcb83

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,47 @@
11
package com.arhs.spring.cache.mongo;
22

3+
import com.arhs.spring.cache.mongo.serializer.JavaSerializer;
4+
import org.junit.Test;
5+
import org.junit.runner.RunWith;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.data.mongodb.core.MongoTemplate;
8+
import org.springframework.test.context.ContextConfiguration;
9+
import org.springframework.test.context.junit4.SpringRunner;
10+
11+
@RunWith(SpringRunner.class)
12+
@ContextConfiguration(classes = TestConfiguration.class)
313
public class MongoCacheBuilderTest {
14+
15+
private static final String CACHE_NAME = "cache";
16+
private static final String COLLECTION_NAME = "test";
17+
private static final long TTL = 0;
18+
19+
@Autowired
20+
private MongoTemplate mongoTemplate;
21+
22+
@Test
23+
public void testBuildWithSerializer() {
24+
MongoCacheBuilder builder = new MongoCacheBuilder(
25+
COLLECTION_NAME,
26+
mongoTemplate,
27+
CACHE_NAME
28+
);
29+
builder.withSerializer(new JavaSerializer());
30+
builder.withTTL(TTL);
31+
builder.withFlushOnBoot(false);
32+
builder.build();
33+
}
34+
35+
@Test
36+
public void testBuildWithoutSerializer() {
37+
MongoCacheBuilder builder = new MongoCacheBuilder(
38+
COLLECTION_NAME,
39+
mongoTemplate,
40+
CACHE_NAME
41+
);
42+
builder.withTTL(TTL);
43+
builder.withFlushOnBoot(false);
44+
builder.build();
45+
}
46+
447
}

0 commit comments

Comments
 (0)