1
2
3
4
5
6
7
8
9
10
11
12 package com.octo.captcha.engine.bufferedengine;
13
14 import com.octo.captcha.Captcha;
15 import junit.framework.TestCase;
16
17 import java.util.Locale;
18
19 /***
20 * @author Benoit
21 */
22 public abstract class BufferedEngineContainerTestAbstract extends TestCase {
23
24
25
26
27
28 public void testGetNextCaptcha() {
29 BufferedEngineContainer engine = getEngine();
30 assertTrue(Captcha.class.isInstance(engine.getNextCaptcha()));
31 releaseEngine(engine);
32 }
33
34
35
36
37 public void testGetNextCaptchaLocale() {
38 BufferedEngineContainer engine = getEngine();
39 assertTrue(Captcha.class.isInstance(engine.getNextCaptcha(Locale.FRANCE)));
40 releaseEngine(engine);
41 }
42
43 public void testSwapCaptchasFromPersistentToVolatileMemory() {
44 BufferedEngineContainer engine = getEngine();
45 int size = engine.getVolatileBuffer().size();
46
47 engine.feedPersistentBuffer();
48
49 engine.swapCaptchasFromPersistentToVolatileMemory();
50
51 assertTrue(size < engine.getVolatileBuffer().size());
52
53 releaseEngine(engine);
54 }
55
56 public void testFeedPersistentBuffer() {
57 BufferedEngineContainer engine = getEngine();
58 int size = engine.getPersistentBuffer().size();
59
60 engine.feedPersistentBuffer();
61
62 assertTrue(size < engine.getPersistentBuffer().size());
63 releaseEngine(engine);
64 }
65
66 public abstract BufferedEngineContainer getEngine();
67
68 public abstract void releaseEngine(BufferedEngineContainer engine);
69
70 }