1 package org.apache.commons.jcs.auxiliary.disk.jdbc.mysql;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.sql.SQLException;
23
24 import junit.framework.TestCase;
25
26 import org.apache.commons.jcs.auxiliary.disk.jdbc.TableState;
27 import org.apache.commons.jcs.auxiliary.disk.jdbc.dsfactory.SharedPoolDataSourceFactory;
28 import org.apache.commons.jcs.engine.control.CompositeCacheManager;
29
30
31
32
33
34
35
36
37 public class MySQLDiskCacheUnitTest
38 extends TestCase
39 {
40
41
42
43
44
45
46
47
48 public void testBalkOnGet() throws SQLException
49 {
50
51 MySQLDiskCacheAttributes attributes = new MySQLDiskCacheAttributes();
52 String tableName = "JCS_TEST";
53
54 attributes.setDriverClassName( "org.hsqldb.jdbcDriver" );
55 attributes.setTableName( tableName );
56 attributes.setBalkDuringOptimization( true );
57 SharedPoolDataSourceFactory dsFactory = new SharedPoolDataSourceFactory();
58 dsFactory.initialize(attributes);
59
60 TableState tableState = new TableState( tableName );
61 tableState.setState( TableState.OPTIMIZATION_RUNNING );
62
63 MySQLDiskCache<String, String> cache = new MySQLDiskCache<String, String>( attributes, dsFactory, tableState,
64 CompositeCacheManager.getUnconfiguredInstance() );
65
66
67 Object result = cache.processGet( "myKey" );
68
69
70 assertNull( "The result should be null", result );
71 }
72 }