| Eliza Margaretha | 269e5a6 | 2014-09-30 16:58:23 +0000 | [diff] [blame] | 1 | package de.ids_mannheim.korap.cache; |
| 2 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 3 | import java.util.Collections; |
| 4 | |
| 5 | import net.sf.jsr107cache.Cache; |
| 6 | import net.sf.jsr107cache.CacheException; |
| 7 | import net.sf.jsr107cache.CacheFactory; |
| 8 | import net.sf.jsr107cache.CacheManager; |
| 9 | |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 10 | import static org.junit.Assert.*; |
| 11 | import org.junit.Test; |
| 12 | import org.junit.Ignore; |
| 13 | import org.junit.runner.RunWith; |
| 14 | import org.junit.runners.JUnit4; |
| 15 | |
| 16 | @RunWith(JUnit4.class) |
| 17 | public class TestCache { |
| 18 | |
| 19 | @Test |
| 20 | public void cache1 () { |
| 21 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 22 | Cache cache; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 23 | |
| 24 | try { |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 25 | CacheFactory cacheFactory = CacheManager.getInstance() |
| 26 | .getCacheFactory(); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 27 | cache = cacheFactory.createCache(Collections.emptyMap()); |
| 28 | } |
| 29 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 30 | catch (CacheException e) { |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 31 | // ... |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 32 | return; |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 35 | cache.put("beispiel1", "Das ist ein Test"); |
| 36 | cache.put("beispiel2", "Das ist ein Versuch"); |
| 37 | cache.put("beispiel3", "Das ist ein Beispiel"); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 38 | |
| Nils Diewald | bb33da2 | 2015-03-04 16:24:25 +0000 | [diff] [blame] | 39 | assertEquals(cache.get("beispiel1"), "Das ist ein Test"); |
| 40 | assertEquals(cache.get("beispiel2"), "Das ist ein Versuch"); |
| 41 | assertEquals(cache.get("beispiel3"), "Das ist ein Beispiel"); |
| Nils Diewald | f399a67 | 2013-11-18 17:55:22 +0000 | [diff] [blame] | 42 | }; |
| 43 | }; |