1414 */
1515package com .dasburo .spring .cache .dynamo ;
1616
17- import org .junit .Assert ;
18- import org .junit .Before ;
19- import org .junit .ClassRule ;
20- import org .junit .Test ;
21- import org .junit .runner .RunWith ;
17+ import org .junit .jupiter .api .BeforeEach ;
18+ import org .junit .jupiter .api .Test ;
19+ import org .junit .jupiter .api .extension .ExtendWith ;
2220import org .springframework .beans .factory .annotation .Autowired ;
2321import org .springframework .cache .Cache ;
2422import org .springframework .test .context .ContextConfiguration ;
25- import org .springframework .test .context .junit4 . SpringRunner ;
23+ import org .springframework .test .context .junit . jupiter . SpringExtension ;
2624import software .amazon .awssdk .services .dynamodb .DynamoDbClient ;
2725
2826import java .util .ArrayList ;
3230import static org .hamcrest .CoreMatchers .hasItem ;
3331import static org .hamcrest .CoreMatchers .instanceOf ;
3432import static org .hamcrest .MatcherAssert .assertThat ;
33+ import static org .junit .jupiter .api .Assertions .*;
3534
3635/**
3736 * Unit tests for {@link DynamoCacheManager}.
3837 *
3938 * @author Georg Zimmermann
4039 */
41- @ RunWith ( SpringRunner .class )
40+ @ ExtendWith ({ SpringExtension .class , TestDbCreationExtension . class } )
4241@ ContextConfiguration (classes = TestConfiguration .class )
4342public class DynamoCacheManagerTest {
4443
4544 private static final String CACHE_NAME = "cache" ;
4645
47- @ ClassRule
48- public static TestDbCreationRule dynamoDB = new TestDbCreationRule ();
49-
5046 @ Autowired
5147 private DynamoDbClient dynamoTemplate ;
5248
5349 private DynamoCacheManager manager ;
5450
55- @ Before
51+ @ BeforeEach
5652 public void setup () {
5753 DynamoCacheBuilder defaultCacheBuilder = DynamoCacheBuilder .newInstance (CACHE_NAME , dynamoTemplate );
5854 this .manager = new DynamoCacheManager (Collections .singletonList (defaultCacheBuilder ));
@@ -70,8 +66,8 @@ public void loadCaches() {
7066
7167 final DynamoCacheManager manager = new DynamoCacheManager (initialCaches );
7268 final Collection <? extends Cache > caches = manager .loadCaches ();
73- Assert . assertNotNull (caches );
74- Assert . assertEquals (1 , caches .size ());
69+ assertNotNull (caches );
70+ assertEquals (1 , caches .size ());
7571 }
7672
7773 /**
@@ -80,12 +76,12 @@ public void loadCaches() {
8076 @ Test
8177 public void cache () {
8278 final Cache cache = manager .getCache (CACHE_NAME );
83- Assert . assertNotNull (cache );
84- Assert . assertEquals (CACHE_NAME , cache .getName ());
79+ assertNotNull (cache );
80+ assertEquals (CACHE_NAME , cache .getName ());
8581 assertThat (cache , instanceOf (DynamoCache .class ));
8682
8783 final DynamoCache dynamoCache = (DynamoCache ) cache ;
88- Assert . assertEquals (dynamoCache .getNativeCache (), dynamoTemplate );
84+ assertEquals (dynamoCache .getNativeCache (), dynamoTemplate );
8985 }
9086
9187 /**
@@ -94,19 +90,19 @@ public void cache() {
9490 @ Test
9591 public void getCache () {
9692 final Cache cache = manager .getCache (CACHE_NAME );
97- Assert . assertNotNull (cache );
93+ assertNotNull (cache );
9894
9995 final Cache invalidCache = manager .getCache ("invalid" );
100- Assert . assertNull (invalidCache );
96+ assertNull (invalidCache );
10197 }
10298
10399 /**
104100 * Test for {@link DynamoCacheManager#getCacheNames()}
105101 */
106102 @ Test
107103 public void getCacheNames () {
108- Assert . assertNotNull (manager .getCacheNames ());
109- Assert . assertEquals (1 , manager .getCacheNames ().size ());
104+ assertNotNull (manager .getCacheNames ());
105+ assertEquals (1 , manager .getCacheNames ().size ());
110106 assertThat (manager .getCacheNames (), hasItem (CACHE_NAME ));
111107 }
112108
0 commit comments