[jbosscache-commits] JBoss Cache SVN: r7365 - in core/trunk/src: main/resources/config-samples and 6 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Mon Jan 5 06:59:09 EST 2009
Author: manik.surtani at jboss.com
Date: 2009-01-05 06:59:09 -0500 (Mon, 05 Jan 2009)
New Revision: 7365
Added:
core/trunk/src/test/java/org/jboss/cache/util/UnitTestDatabaseManager.java
Removed:
core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java
Modified:
core/trunk/src/main/resources/cache-jdbc.properties
core/trunk/src/main/resources/config-samples/all.xml
core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml
core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
core/trunk/src/test/resources/cache-jdbc.properties
Log:
Stuff that was left behind in moving the test in-memory DB from Derby to HSQL
Modified: core/trunk/src/main/resources/cache-jdbc.properties
===================================================================
--- core/trunk/src/main/resources/cache-jdbc.properties 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/main/resources/cache-jdbc.properties 2009-01-05 11:59:09 UTC (rev 7365)
@@ -14,9 +14,11 @@
cache.jdbc.node.type=BINARY
cache.jdbc.parent.column=parent
# Specify your DBMS's string concatenation function syntax in the following manner: concat(1 , 2) -> '12'.
-# This syntax should work an most popular DBMS like oracle, db2, mssql, mysql, PostgreSQL. Derby - on which
-#the tests are run does not support 'concat', but '1 || 2' . If no value is sepcified then concat(1 , 2) is used by default.
-cache.jdbc.sql-concat=1 || 2
+# This syntax should work an most popular DBMS like oracle, db2, mssql, mysql, PostgreSQL.
+#
+# Derby - does not support 'concat', but '1 || 2' . If no value is sepcified then concat(1 , 2) is used by default.
+#cache.jdbc.sql-concat=1 || 2
+#cache.jdbc.sql-concat=concat(1 , 2)
# JBoss Cache Table properties for Hypersonic, just overrides
#cache.jdbc.node.type=OBJECT
Modified: core/trunk/src/main/resources/config-samples/all.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/all.xml 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/main/resources/config-samples/all.xml 2009-01-05 11:59:09 UTC (rev 7365)
@@ -3,224 +3,224 @@
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
- <!--
- isolation levels supported: READ_COMMITTED and REPEATABLE_READ
- nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic (deprecated)
- -->
- <locking
- isolationLevel="REPEATABLE_READ"
- lockParentForChildInsertRemove="false"
- lockAcquisitionTimeout="20000"
- nodeLockingScheme="mvcc"
- writeSkewCheck="false"
- concurrencyLevel="500"/>
+ <!--
+ isolation levels supported: READ_COMMITTED and REPEATABLE_READ
+ nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic (deprecated)
+ -->
+ <locking
+ isolationLevel="REPEATABLE_READ"
+ lockParentForChildInsertRemove="false"
+ lockAcquisitionTimeout="20000"
+ nodeLockingScheme="mvcc"
+ writeSkewCheck="false"
+ concurrencyLevel="500"/>
- <!--
- Used to register a transaction manager and participate in ongoing transactions.
- -->
- <transaction
- transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"
- syncRollbackPhase="false"
- syncCommitPhase="false"/>
+ <!--
+ Used to register a transaction manager and participate in ongoing transactions.
+ -->
+ <transaction
+ transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"
+ syncRollbackPhase="false"
+ syncCommitPhase="false"/>
- <!--
- Used to register JMX statistics in any available MBean server
- -->
- <jmxStatistics
- enabled="false"/>
+ <!--
+ Used to register JMX statistics in any available MBean server
+ -->
+ <jmxStatistics
+ enabled="false"/>
- <!--
- If region based marshalling is used, defines whether new regions are inactive on startup.
- -->
- <startup
- regionsInactiveOnStartup="true"/>
+ <!--
+ If region based marshalling is used, defines whether new regions are inactive on startup.
+ -->
+ <startup
+ regionsInactiveOnStartup="true"/>
- <!--
- Used to register JVM shutdown hooks.
- hookBehavior: DEFAULT, REGISTER, DONT_REGISTER
- -->
- <shutdown
- hookBehavior="DEFAULT"/>
+ <!--
+ Used to register JVM shutdown hooks.
+ hookBehavior: DEFAULT, REGISTER, DONT_REGISTER
+ -->
+ <shutdown
+ hookBehavior="DEFAULT"/>
- <!--
- Used to define async listener notification thread pool size
- -->
- <listeners
- asyncPoolSize="1"
- asyncQueueSize="1000000"/>
+ <!--
+ Used to define async listener notification thread pool size
+ -->
+ <listeners
+ asyncPoolSize="1"
+ asyncQueueSize="1000000"/>
- <!--
- Used to enable invocation batching and allow the use of Cache.startBatch()/endBatch() methods.
- -->
- <invocationBatching
- enabled="false"/>
+ <!--
+ Used to enable invocation batching and allow the use of Cache.startBatch()/endBatch() methods.
+ -->
+ <invocationBatching
+ enabled="false"/>
- <!--
- serialization related configuration, used for replication and cache loading
- -->
- <serialization
- objectInputStreamPoolSize="12"
- objectOutputStreamPoolSize="14"
- version="3.0.0"
- marshallerClass="org.jboss.cache.marshall.VersionAwareMarshaller"
- useLazyDeserialization="false"
- useRegionBasedMarshalling="false"/>
+ <!--
+ serialization related configuration, used for replication and cache loading
+ -->
+ <serialization
+ objectInputStreamPoolSize="12"
+ objectOutputStreamPoolSize="14"
+ version="3.0.0"
+ marshallerClass="org.jboss.cache.marshall.VersionAwareMarshaller"
+ useLazyDeserialization="false"
+ useRegionBasedMarshalling="false"/>
- <!--
- This element specifies that the cache is clustered.
- modes supported: replication (r) or invalidation (i).
- -->
- <clustering mode="replication" clusterName="JBossCache-cluster">
+ <!--
+ This element specifies that the cache is clustered.
+ modes supported: replication (r) or invalidation (i).
+ -->
+ <clustering mode="replication" clusterName="JBossCache-cluster">
- <!--
- Defines whether to retrieve state on startup
- -->
- <stateRetrieval timeout="20000" fetchInMemoryState="false"/>
+ <!--
+ Defines whether to retrieve state on startup
+ -->
+ <stateRetrieval timeout="20000" fetchInMemoryState="false"/>
- <!--
- Network calls are synchronous.
- -->
- <sync replTimeout="20000"/>
- <!--
- Uncomment this for async replication.
- -->
- <!--<async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500" serializationExecutorPoolSize="20" serializationExecutorQueueSize="5000000"/>-->
+ <!--
+ Network calls are synchronous.
+ -->
+ <sync replTimeout="20000"/>
+ <!--
+ Uncomment this for async replication.
+ -->
+ <!--<async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500" serializationExecutorPoolSize="20" serializationExecutorQueueSize="5000000"/>-->
- <!-- Uncomment to use Buddy Replication -->
- <!--
- <buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000">
- <dataGravitation auto="true" removeOnFind="true" searchBackupTrees="true"/>
- <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
- <properties>
- numBuddies = 1
- ignoreColocatedBuddies = true
- </properties>
- </locator>
- </buddy>
- -->
+ <!-- Uncomment to use Buddy Replication -->
+ <!--
+ <buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000">
+ <dataGravitation auto="true" removeOnFind="true" searchBackupTrees="true"/>
+ <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator">
+ <properties>
+ numBuddies = 1
+ ignoreColocatedBuddies = true
+ </properties>
+ </locator>
+ </buddy>
+ -->
- <!--
- Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml
- ships with jgroups.jar and will be picked up by the class loader.
- -->
- <jgroupsConfig>
+ <!--
+ Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml
+ ships with jgroups.jar and will be picked up by the class loader.
+ -->
+ <jgroupsConfig>
- <UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
- loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10"
- mcast_port="45588" mcast_recv_buf_size="25000000" mcast_send_buf_size="640000"
- oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="4"
- oob_thread_pool.min_threads="1" oob_thread_pool.queue_enabled="true" oob_thread_pool.queue_max_size="10"
- oob_thread_pool.rejection_policy="Run" thread_naming_pattern="pl" thread_pool.enabled="true"
- thread_pool.keep_alive_time="30000" thread_pool.max_threads="25" thread_pool.min_threads="1"
- thread_pool.queue_enabled="true" thread_pool.queue_max_size="10" thread_pool.rejection_policy="Run"
- tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true"
- use_incoming_packet_handler="true"/>
- <PING num_initial_members="3" timeout="2000"/>
- <MERGE2 max_interval="30000" min_interval="10000"/>
- <FD_SOCK/>
- <FD max_tries="5" shun="true" timeout="10000"/>
- <VERIFY_SUSPECT timeout="1500"/>
- <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
- use_mcast_xmit="false"/>
- <UNICAST timeout="300,600,1200,2400,3600"/>
- <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/>
- <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000"
- view_bundling="true"/>
- <FRAG2 frag_size="60000"/>
- <pbcast.STREAMING_STATE_TRANSFER/>
- <pbcast.FLUSH timeout="0"/>
+ <UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2"
+ loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10"
+ mcast_port="45588" mcast_recv_buf_size="25000000" mcast_send_buf_size="640000"
+ oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="4"
+ oob_thread_pool.min_threads="1" oob_thread_pool.queue_enabled="true"
+ oob_thread_pool.queue_max_size="10"
+ oob_thread_pool.rejection_policy="Run" thread_naming_pattern="pl" thread_pool.enabled="true"
+ thread_pool.keep_alive_time="30000" thread_pool.max_threads="25" thread_pool.min_threads="1"
+ thread_pool.queue_enabled="true" thread_pool.queue_max_size="10" thread_pool.rejection_policy="Run"
+ tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true"
+ use_incoming_packet_handler="true"/>
+ <PING num_initial_members="3" timeout="2000"/>
+ <MERGE2 max_interval="30000" min_interval="10000"/>
+ <FD_SOCK/>
+ <FD max_tries="5" shun="true" timeout="10000"/>
+ <VERIFY_SUSPECT timeout="1500"/>
+ <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
+ use_mcast_xmit="false"/>
+ <UNICAST timeout="300,600,1200,2400,3600"/>
+ <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/>
+ <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000"
+ view_bundling="true"/>
+ <FRAG2 frag_size="60000"/>
+ <pbcast.STREAMING_STATE_TRANSFER/>
+ <pbcast.FLUSH timeout="0"/>
- </jgroupsConfig>
- </clustering>
+ </jgroupsConfig>
+ </clustering>
- <!--
- Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means
- the eviction thread will never run.
- -->
- <eviction wakeUpInterval="500">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
- <property name="maxNodes" value="5000"/>
- <property name="timeToLive" value="1000"/>
- </default>
- <region name="/org/jboss/data1">
- <property name="timeToLive" value="2000"/>
- </region>
- <region name="/org/jboss/data2" algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="100000">
- <property name="maxNodes" value="3000"/>
- <property name="minTimeToLive" value="4000"/>
- </region>
- </eviction>
+ <!--
+ Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means
+ the eviction thread will never run.
+ -->
+ <eviction wakeUpInterval="500">
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <property name="maxNodes" value="5000"/>
+ <property name="timeToLive" value="1000"/>
+ </default>
+ <region name="/org/jboss/data1">
+ <property name="timeToLive" value="2000"/>
+ </region>
+ <region name="/org/jboss/data2" algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="100000">
+ <property name="maxNodes" value="3000"/>
+ <property name="minTimeToLive" value="4000"/>
+ </region>
+ </eviction>
- <!--
- Cache loaders.
+ <!--
+ Cache loaders.
- If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted. Similarly, when the state
- is accessed again, it is removed from the cache loader and loaded into memory.
+ If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted. Similarly, when the state
+ is accessed again, it is removed from the cache loader and loaded into memory.
- Otherwise, state is always maintained in the cache loader as well as in memory.
+ Otherwise, state is always maintained in the cache loader as well as in memory.
- Set 'shared' to true if all instances in the cluster use the same cache loader instance, e.g., are talking to the
- same database.
- -->
- <loaders passivation="false" shared="false">
- <preload>
- <node fqn="/org/jboss"/>
- <node fqn="/org/tempdata"/>
- </preload>
+ Set 'shared' to true if all instances in the cluster use the same cache loader instance, e.g., are talking to the
+ same database.
+ -->
+ <loaders passivation="false" shared="false">
+ <preload>
+ <node fqn="/org/jboss"/>
+ <node fqn="/org/tempdata"/>
+ </preload>
- <!--
- we can have multiple cache loaders, which get chained
- -->
- <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true"
- ignoreModifications="true" purgeOnStartup="true">
+ <!--
+ we can have multiple cache loaders, which get chained
+ -->
+ <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true"
+ ignoreModifications="true" purgeOnStartup="true">
- <properties>
- cache.jdbc.table.name=jbosscache
- cache.jdbc.table.create=true
- cache.jdbc.table.drop=true
- cache.jdbc.table.primarykey=jbosscache_pk
- cache.jdbc.fqn.column=fqn
- cache.jdbc.fqn.type=varchar(255)
- cache.jdbc.node.column=node
- cache.jdbc.node.type=blob
- cache.jdbc.parent.column=parent
- cache.jdbc.sql-concat=1 || 2
- cache.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver
- cache.jdbc.url=jdbc:derby:jbossdb;create=true
- cache.jdbc.user=user1
- cache.jdbc.password=user1
- </properties>
- <!-- alternatively use a connection from a datasorce, as per the code sample below-->
- <!--<properties>-->
- <!--cache.jdbc.datasource=AllSampleDS-->
- <!--cache.jdbc.table.name=jbosscache-->
- <!--cache.jdbc.table.create=true-->
- <!--cache.jdbc.table.drop=true-->
- <!--</properties>-->
- <singletonStore enabled="true" class="org.jboss.cache.loader.SingletonStoreCacheLoader">
<properties>
- pushStateWhenCoordinator=true
- pushStateWhenCoordinatorTimeout=20000
+ cache.jdbc.table.name=jbosscache
+ cache.jdbc.table.create=true
+ cache.jdbc.table.drop=true
+ cache.jdbc.table.primarykey=jbosscache_pk
+ cache.jdbc.fqn.column=fqn
+ cache.jdbc.fqn.type=varchar(255)
+ cache.jdbc.node.column=node
+ cache.jdbc.node.type=blob
+ cache.jdbc.parent.column=parent
+ cache.jdbc.driver=org.hsqldb.jdbcDriver
+ cache.jdbc.url=jdbc:hsqldb:mem:jbosscache
+ cache.jdbc.user=sa
+ cache.jdbc.password=
</properties>
- </singletonStore>
- </loader>
- </loaders>
+ <!-- alternatively use a connection from a datasorce, as per the code sample below-->
+ <!--<properties>-->
+ <!--cache.jdbc.datasource=AllSampleDS-->
+ <!--cache.jdbc.table.name=jbosscache-->
+ <!--cache.jdbc.table.create=true-->
+ <!--cache.jdbc.table.drop=true-->
+ <!--</properties>-->
+ <singletonStore enabled="true" class="org.jboss.cache.loader.SingletonStoreCacheLoader">
+ <properties>
+ pushStateWhenCoordinator=true
+ pushStateWhenCoordinatorTimeout=20000
+ </properties>
+ </singletonStore>
+ </loader>
+ </loaders>
- <!--
- Define custom interceptors. All custom interceptors need to extend org.jboss.cache.interceptors.base.CommandInterceptor
- -->
- <!--
- <customInterceptors>
- <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor">
- <property name="attrOne" value="value1" />
- <property name="attrTwo" value="value2" />
- </interceptor>
- <interceptor position="last" class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/>
- <interceptor index="3" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/>
- <interceptor before="org.jboss.cache.interceptors.CallInterceptor"
- class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/>
- <interceptor after="org.jboss.cache.interceptors.CallInterceptor"
- class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/>
- </customInterceptors>
- -->
+ <!--
+ Define custom interceptors. All custom interceptors need to extend org.jboss.cache.interceptors.base.CommandInterceptor
+ -->
+ <!--
+ <customInterceptors>
+ <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor">
+ <property name="attrOne" value="value1" />
+ <property name="attrTwo" value="value2" />
+ </interceptor>
+ <interceptor position="last" class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/>
+ <interceptor index="3" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/>
+ <interceptor before="org.jboss.cache.interceptors.CallInterceptor"
+ class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/>
+ <interceptor after="org.jboss.cache.interceptors.CallInterceptor"
+ class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/>
+ </customInterceptors>
+ -->
</jbosscache>
Modified: core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/main/resources/config-samples/cacheloader-enabled.xml 2009-01-05 11:59:09 UTC (rev 7365)
@@ -1,54 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0">
- <!-- Configure the TransactionManager -->
- <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
+ <!-- Configure the TransactionManager -->
+ <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>
- <!-- Specific eviction policy configurations -->
- <eviction wakeUpInterval="5000">
- <!-- Cache wide default -->
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
- <property name="maxNodes" value="5000" />
- <property name="timeToLive" value="3000" />
- </default>
- <region name="/org/jboss/test/data">
- <property name="maxNodes" value="100" />
- <property name="timeToLive" value="3000" />
- </region>
- </eviction>
+ <!-- Specific eviction policy configurations -->
+ <eviction wakeUpInterval="5000">
+ <!-- Cache wide default -->
+ <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000">
+ <property name="maxNodes" value="5000"/>
+ <property name="timeToLive" value="3000"/>
+ </default>
+ <region name="/org/jboss/test/data">
+ <property name="maxNodes" value="100"/>
+ <property name="timeToLive" value="3000"/>
+ </region>
+ </eviction>
- <!-- Cache Passivation for Tree Cache
- On passivation, The objects are written to the backend store on eviction if passivation
- is true, otherwise the objects are persisted. On activation, the objects are restored in
- the memory cache and removed from the cache loader if 'passivation' attribute is true,
- otherwise the objects are only loaded from the cache loader -->
- <loaders passivation="false" shared="false">
- <preload>
- <node fqn="/"/>
- </preload>
- <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
- <loader
- class="org.jboss.cache.loader.JDBCCacheLoader"
- async="false"
- fetchPersistentState="true"
- ignoreModifications="false"
- purgeOnStartup="false">
- <properties>
- cache.jdbc.table.name=jbosscache
- cache.jdbc.table.create=true
- cache.jdbc.table.drop=true
- cache.jdbc.table.primarykey=jbosscache_pk
- cache.jdbc.fqn.column=fqn
- cache.jdbc.fqn.type=varchar(255)
- cache.jdbc.node.column=node
- cache.jdbc.node.type=blob
- cache.jdbc.parent.column=parent
- cache.jdbc.sql-concat=1 || 2
- cache.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver
- cache.jdbc.url=jdbc:derby:jbossdb;create=true
- cache.jdbc.user=user1
- cache.jdbc.password=user1
- </properties>
- </loader>
- </loaders>
+ <!-- Cache Passivation for Tree Cache
+On passivation, The objects are written to the backend store on eviction if passivation
+is true, otherwise the objects are persisted. On activation, the objects are restored in
+the memory cache and removed from the cache loader if 'passivation' attribute is true,
+otherwise the objects are only loaded from the cache loader -->
+ <loaders passivation="false" shared="false">
+ <preload>
+ <node fqn="/"/>
+ </preload>
+ <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
+ <loader
+ class="org.jboss.cache.loader.JDBCCacheLoader"
+ async="false"
+ fetchPersistentState="true"
+ ignoreModifications="false"
+ purgeOnStartup="false">
+ <properties>
+ cache.jdbc.table.name=jbosscache
+ cache.jdbc.table.create=true
+ cache.jdbc.table.drop=true
+ cache.jdbc.table.primarykey=jbosscache_pk
+ cache.jdbc.fqn.column=fqn
+ cache.jdbc.fqn.type=varchar(255)
+ cache.jdbc.node.column=node
+ cache.jdbc.node.type=blob
+ cache.jdbc.parent.column=parent
+ cache.jdbc.driver=org.hsqldb.jdbcDriver
+ cache.jdbc.url=jdbc:hsqldb:mem:jbosscache
+ cache.jdbc.user=sa
+ cache.jdbc.password=
+ </properties>
+ </loader>
+ </loaders>
</jbosscache>
Modified: core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderCompatibilityTest.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -1,17 +1,21 @@
package org.jboss.cache.loader;
+import org.jboss.cache.AbstractMultipleCachesTest;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.statetransfer.DefaultStateTransferManager;
-import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.TestDbPropertiesFactory;
+import org.jboss.cache.util.UnitTestDatabaseManager;
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import static org.testng.AssertJUnit.*;
-import org.testng.annotations.*;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -19,9 +23,6 @@
import java.util.HashSet;
import java.util.Properties;
-import org.jboss.cache.UnitTestCacheFactory;
-import org.jboss.cache.AbstractMultipleCachesTest;
-
/**
* Tests the compatibility between <tt>JDBCCacheLoader</tt> and <tt>JDBCCacheLoaderOld</tt>. More exactly,
* it tests whether the new <tt>JDBCCacheLoader</tt> works fine on data previously created
@@ -64,13 +65,13 @@
@BeforeTest
public void createDatabase()
{
- props = TestDbPropertiesFactory.getTestDbProperties();
+ props = UnitTestDatabaseManager.getTestDbProperties();
}
@AfterTest
public void shutDownDatabase()
{
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(props);
}
public void testCommonOperations() throws Exception
@@ -205,7 +206,7 @@
protected Properties getProperties() throws Exception
{
- return TestDbPropertiesFactory.getTestDbProperties();
+ return UnitTestDatabaseManager.getTestDbProperties();
}
private JDBCCacheLoader getNewCacheLoader(Properties prop) throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -7,10 +7,14 @@
package org.jboss.cache.loader;
import com.mchange.v2.c3p0.PooledDataSource;
-import org.jboss.cache.util.TestDbPropertiesFactory;
+import org.jboss.cache.util.UnitTestDatabaseManager;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.fail;
-import org.testng.annotations.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
import java.sql.Connection;
import java.util.Properties;
@@ -31,13 +35,13 @@
@BeforeTest
public void createDatabase()
{
- props = TestDbPropertiesFactory.getTestDbProperties();
+ props = UnitTestDatabaseManager.getTestDbProperties();
}
@AfterTest
public void shutDownDatabase()
{
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(props);
}
@BeforeMethod(alwaysRun = true)
Modified: core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/loader/DataSourceIntegrationTest.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -7,8 +7,12 @@
package org.jboss.cache.loader;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.transaction.DummyTransactionManager;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.UnitTestDatabaseManager;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNull;
import org.testng.annotations.AfterMethod;
@@ -25,11 +29,6 @@
import java.sql.SQLException;
import java.util.Properties;
-import org.jboss.cache.UnitTestCacheFactory;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.TestDbPropertiesFactory;
-
@Test(groups = "functional", sequential = true, testName = "loader.DataSourceIntegrationTest")
public class DataSourceIntegrationTest
{
@@ -75,7 +74,7 @@
{
// expected
}
- props = TestDbPropertiesFactory.getTestDbProperties();
+ props = UnitTestDatabaseManager.getTestDbProperties();
cache = (CacheSPI) new UnitTestCacheFactory<Object, Object>().createCache(false, getClass());
cache.getConfiguration().setCacheMode("local");
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
@@ -99,7 +98,7 @@
if (cache != null)
{
TestingUtil.killCaches(cache);
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(props);
cache = null;
}
}
@@ -115,7 +114,8 @@
try
{
Class.forName(properties.getProperty("cache.jdbc.driver"));
- } catch (ClassNotFoundException e)
+ }
+ catch (ClassNotFoundException e)
{
throw new RuntimeException(e);
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConfigTest.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -9,12 +9,10 @@
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
-
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.Properties;
-import org.jboss.cache.util.TestingUtil;
/**
* Unit test for JDBCCacheLoaderConfigTest
@@ -53,22 +51,21 @@
public void testSetGetBatchInfo()
{
Properties props = new Properties();
- props.put("ache.jdbc.table.name","jbosscache");
+ props.put("cache.jdbc.table.name", "jbosscache");
props.put("cache.jdbc.table.create", "true");
- props.put("cache.jdbc.table.drop","true");
- props.put("cache.jdbc.table.primarykey","jbosscache_pk");
- props.put("cache.jdbc.fqn.column","fqn");
+ props.put("cache.jdbc.table.drop", "true");
+ props.put("cache.jdbc.table.primarykey", "jbosscache_pk");
+ props.put("cache.jdbc.fqn.column", "fqn");
props.put("cache.jdbc.fqn.type", "varchar(255)");
- props.put("cache.jdbc.node.column","node");
+ props.put("cache.jdbc.node.column", "node");
props.put("cache.jdbc.node.type", "blob");
- props.put("cache.jdbc.parent.column","parent");
- props.put("cache.jdbc.sql-concat","1 || 2");
- props.put("cache.jdbc.driver","org.apache.derby.jdbc.EmbeddedDriver");
- props.put("cache.jdbc.url","jdbc:derby:jbossdb;create=true");
- props.put("cache.jdbc.user","user1");
- props.put("cache.jdbc.password","user1");
- props.put("cache.jdbc.batch.enable","false");
- props.put("cache.jdbc.batch.size","1001");
+ props.put("cache.jdbc.parent.column", "parent");
+ props.put("cache.jdbc.driver", "org.hsqldb.jdbcDriver");
+ props.put("cache.jdbc.url", "jdbc:hsqldb:mem:jbosscache");
+ props.put("cache.jdbc.user", "sa");
+ props.put("cache.jdbc.password", "");
+ props.put("cache.jdbc.batch.enable", "false");
+ props.put("cache.jdbc.batch.size", "1001");
JDBCCacheLoaderConfig config = new JDBCCacheLoaderConfig();
config.setProperties(props);
assert !config.isBatchEnabled();
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -3,6 +3,10 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.UnitTestDatabaseManager;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -10,11 +14,6 @@
import java.sql.Connection;
import java.util.Properties;
-import org.jboss.cache.UnitTestCacheFactory;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.TestDbPropertiesFactory;
-
/**
* To test the closing of JDBC connections
*/
@@ -27,7 +26,7 @@
@BeforeMethod
public void setUp() throws Exception
{
- props = TestDbPropertiesFactory.getTestDbProperties();
+ props = UnitTestDatabaseManager.getTestDbProperties();
cache = new UnitTestCacheFactory<Object, Object>().createCache(false, getClass());
cache.getConfiguration().setCacheLoaderConfig(UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "", JDBCCacheLoader.class.getName(), props, false, false, true, false, false));
cache.start();
@@ -37,7 +36,7 @@
public void tearDown()
{
TestingUtil.killCaches(cache);
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(props);
cache = null;
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderHsqldbDSTest.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -6,16 +6,17 @@
*/
package org.jboss.cache.loader;
-import org.jboss.cache.Fqn;
+import org.hsqldb.jdbc.jdbcDataSource;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.transaction.DummyTransactionManager;
-import org.jboss.cache.util.TestDbPropertiesFactory;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.Test;
+import org.jboss.cache.util.UnitTestDatabaseManager;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertNull;
import org.testng.annotations.AfterTest;
-import org.hsqldb.jdbc.jdbcDataSource;
+import org.testng.annotations.Test;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -23,23 +24,17 @@
import java.util.Properties;
/**
- * This test runs cache loader tests using Database as the cache loader store.
- * The default test is configured using MySQL.
- * The server and database configuration is read from a properties file located at
- * /etc/cache-jdbc.properties.
+ * This test runs a JDBC cache loader, obtaining connections from a JDBC DataSource.
* <p/>
- * The appropriate JDBC driver (i.e mysql-connector-java-3.0.10-stable-bin.jar)
- * must be in the lib directory for this test to run successfuly
- *
- * @author <a href="hmesha at novell.com">Hany Mesha</a>
- * @version <tt>$Revision$</tt>
+ * This test uses HSQL and an in-memory DB.
*/
@Test(groups = {"functional"}, testName = "loader.JDBCCacheLoaderHsqldbDSTest")
public class JDBCCacheLoaderHsqldbDSTest extends CacheLoaderTestsBase
{
- //private String old_factory = null;
private final String FACTORY = "org.jboss.cache.transaction.DummyContextFactory";
- private final String JNDI_NAME = "java:/DerbyDS";
+ private final String JNDI_NAME = "java:/TestDS";
+ private Properties prop;
+ private jdbcDataSource ds;
protected void configureCache(CacheSPI cache) throws Exception
{
@@ -59,7 +54,7 @@
// expected
}
- prop = TestDbPropertiesFactory.getTestDbProperties();
+ prop = UnitTestDatabaseManager.getTestDbProperties();
ds = new jdbcDataSource();
ds.setDatabase(prop.getProperty("cache.jdbc.url"));
@@ -68,75 +63,64 @@
context.bind(JNDI_NAME, ds);
assertNotNull(JNDI_NAME + " bound", context.lookup(JNDI_NAME));
}
- String props = "cache.jdbc.datasource =" + JNDI_NAME + "\n" +
- "cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
- "cache.jdbc.sql-concat= 1 || 2" + "\n" +
- "cache.jdbc.table.name=jbosscache" + "\n" +
- "cache.jdbc.table.primarykey=jbosscache_pk";
- CacheLoaderConfig config = UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "", "org.jboss.cache.loader.JDBCCacheLoader",
- props, false, true, false, false, false);
+ Properties p = new Properties();
+ p.setProperty("cache.jdbc.datasource", JNDI_NAME);
+ p.setProperty("cache.jdbc.node.type", prop.getProperty("cache.jdbc.node.type"));
+ p.setProperty("cache.jdbc.table.name", prop.getProperty("cache.jdbc.table.name"));
+ p.setProperty("cache.jdbc.table.primarykey", prop.getProperty("cache.jdbc.table.primarykey"));
+ JDBCCacheLoaderConfig jdbcConfig = new JDBCCacheLoaderConfig();
+ jdbcConfig.setFetchPersistentState(true);
+ jdbcConfig.setProperties(p);
+ CacheLoaderConfig config = new CacheLoaderConfig();
+ config.addIndividualCacheLoaderConfig(jdbcConfig);
cache.getConfiguration().setCacheLoaderConfig(config);
cache.create();
}
- private Properties prop;
-
- private jdbcDataSource ds;
-
@AfterTest
- protected void distroyDbAfterTest() throws Exception
+ protected void destroyDbAfterTest() throws Exception
{
Properties icProps = new Properties();
icProps.setProperty(Context.INITIAL_CONTEXT_FACTORY, FACTORY);
Context ctx = new InitialContext(icProps);
ctx.unbind(JNDI_NAME);
- TestDbPropertiesFactory.shutdownInMemoryDatabase(prop);
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(prop);
}
- public void testLargeObject()
+ public void testLargeObject() throws Exception
{
- try
+ String key = "LargeObj";
+ // create an object with size bigger than 4k (k=1024 bytes)
+ StringBuilder text = new StringBuilder("LargeObject");
+ while (text.toString().getBytes().length < (1024 * 100))
{
- String key = "LargeObj";
- // create an object with size bigger than 4k (k=1024 bytes)
- StringBuilder text = new StringBuilder("LargeObject");
- while (text.toString().getBytes().length < (1024 * 100))
- {
- text.append(text);
- }
- String initialValue = text.toString();
- // insert it into the cache loader
- loader.remove(Fqn.fromString("/"));
-
- Object retVal = loader.put(FQN, key, initialValue);
- assertNull(retVal);
- addDelay();
- // load the object from the cache loader and validate it
- assertEquals(initialValue, (String) loader.get(FQN).get(key));
- // update the object and validate it
- String updatedValue = initialValue.concat(("UpdatedValue"));
- retVal = loader.put(FQN, key, updatedValue);
- assertEquals(initialValue, (String) retVal);
- assertEquals(updatedValue, (String) loader.get(FQN).get(key));
+ text.append(text);
}
- catch (Exception e)
- {
- fail(e.toString());
- }
+ String initialValue = text.toString();
+ // insert it into the cache loader
+ loader.remove(Fqn.fromString("/"));
+
+ Object retVal = loader.put(FQN, key, initialValue);
+ assertNull(retVal);
+ addDelay();
+ // load the object from the cache loader and validate it
+ assertEquals(initialValue, (String) loader.get(FQN).get(key));
+ // update the object and validate it
+ String updatedValue = initialValue.concat(("UpdatedValue"));
+ retVal = loader.put(FQN, key, updatedValue);
+ assertEquals(initialValue, (String) retVal);
+ assertEquals(updatedValue, (String) loader.get(FQN).get(key));
}
+ @Override
public void testTransactionRollback() throws Exception
{
// no-op
}
+ @Override
public void testIntegratedTransactionRollback() throws Exception
{
// no-op
}
-
- public void testRemoveData()
- {
- super.testRemoveData();
- }
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderStateTransferTest.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -24,22 +24,23 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.UnitTestCacheFactory;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.util.TestDbPropertiesFactory;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.transaction.GenericTransactionManagerLookup;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.UnitTestDatabaseManager;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.AfterTest;
import java.util.Properties;
/**
* UT for testing JDBCCacheLoader during state transfer.
+ *
* @author Mircea.Markus at jboss.com
* @since 3.0
*/
@@ -56,19 +57,18 @@
@BeforeTest
public void createDatabase()
{
- props1 = TestDbPropertiesFactory.getTestDbProperties();
- props2 = TestDbPropertiesFactory.getTestDbProperties();
+ props1 = UnitTestDatabaseManager.getTestDbProperties();
+ props2 = UnitTestDatabaseManager.getTestDbProperties();
}
@AfterTest
public void shutDownDatabase()
{
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props1);
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props2);
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(props1);
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(props2);
}
-
@AfterMethod
public void tearDown()
{
@@ -82,7 +82,7 @@
c.setTransactionManagerLookupClass(GenericTransactionManagerLookup.class.getName());
CacheLoaderConfig clc = UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "/", JDBCCacheLoader.class.getName(), props, false, true, false, false, false);
clc.setPassivation(false);
- clc.getFirstCacheLoaderConfig().setPurgeOnStartup(true);
+ clc.getFirstCacheLoaderConfig().setPurgeOnStartup(true);
c.setCacheLoaderConfig(clc);
c.setCacheMode(CacheMode.REPL_SYNC);
c.setStateRetrievalTimeout(1000 * 120);//allow 2 minutes for before state transfer timeouts
@@ -96,9 +96,9 @@
first.put("/a/b/d", "key", "value");
first.put("/a/b/e", "key", "value");
second = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration(props2), getClass());
- assert second.get("/a/b/c","key").equals("value");
- assert second.get("/a/b/d","key").equals("value");
- assert second.get("/a/b/e","key").equals("value");
+ assert second.get("/a/b/c", "key").equals("value");
+ assert second.get("/a/b/d", "key").equals("value");
+ assert second.get("/a/b/e", "key").equals("value");
JDBCCacheLoader cacheLoader = (JDBCCacheLoader) second.getCacheLoaderManager().getCacheLoader();
assert cacheLoader.exists(Fqn.fromString("/a"));
assert cacheLoader.exists(Fqn.fromString("/a/b"));
@@ -113,16 +113,16 @@
long cacheStartTime = System.currentTimeMillis() - startTime;
for (int i = 0; i < 5012; i++)
{
- first.put("a/b/"+i, "k","v");
+ first.put("a/b/" + i, "k", "v");
}
startTime = System.currentTimeMillis();
second = (CacheSPI) new UnitTestCacheFactory().createCache(getConfiguration(props2), getClass());
long stateTranferTime = System.currentTimeMillis() - startTime - cacheStartTime;
System.out.println("stateTranferTime = " + stateTranferTime);
- for (int i = 0; i < 5012; i+=100)
+ for (int i = 0; i < 5012; i += 100)
{
- second.get("a/b/"+ i, "k").equals("v");
+ second.get("a/b/" + i, "k").equals("v");
}
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -6,16 +6,21 @@
*/
package org.jboss.cache.loader;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.*;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.util.UnitTestDatabaseManager;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertNull;
+import static org.testng.AssertJUnit.assertTrue;
+import static org.testng.AssertJUnit.fail;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
import java.util.Properties;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.util.TestDbPropertiesFactory;
-
/**
* This test runs cache loader tests using Database as the cache loader store.
* The default test is configured using Derby embedded framework.
@@ -38,17 +43,17 @@
@BeforeTest
public void createDatabase()
{
- props = TestDbPropertiesFactory.getTestDbProperties();
+ props = UnitTestDatabaseManager.getTestDbProperties();
}
@AfterTest
public void shutDownDatabase()
{
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(props);
}
- @BeforeMethod
- public void clearDatabase() throws Exception
+ @BeforeMethod
+ public void clearDatabase() throws Exception
{
loader.remove(Fqn.ROOT);
}
@@ -77,7 +82,9 @@
private void append(String propertyName, Properties prop, StringBuilder builder)
{
if (prop.containsKey(propertyName))
+ {
builder.append(propertyName).append("=").append(prop.getProperty(propertyName)).append("\n");
+ }
}
public void testLargeObject()
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheLoaderMarshallingJDBCTest.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -3,6 +3,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.Configuration;
@@ -11,14 +12,13 @@
import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.loader.JDBCCacheLoaderConfig;
import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.TestDbPropertiesFactory;
+import org.jboss.cache.util.UnitTestDatabaseManager;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import java.util.Collections;
import java.util.Properties;
-import org.jboss.cache.UnitTestCacheFactory;
/**
* Tests marshalling/unmarshalling during cache loader operations involving types
@@ -37,11 +37,12 @@
@AfterMethod(alwaysRun = true)
- @Override public void tearDown() throws Exception
+ @Override
+ public void tearDown() throws Exception
{
TestingUtil.killCaches(cache);
Properties props = cache.getConfiguration().getCacheLoaderConfig().getFirstCacheLoaderConfig().getProperties();
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(props);
super.tearDown();
cache = null;
}
@@ -94,7 +95,7 @@
private Cache createCache(boolean useRegionBased) throws Exception
{
- Properties prop = TestDbPropertiesFactory.getTestDbProperties();
+ Properties prop = UnitTestDatabaseManager.getTestDbProperties();
// ensure cleanup after each test
prop.setProperty("cache.jdbc.table.drop", "true");
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationToJDBCCacheLoaderTest.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -6,24 +6,24 @@
*/
package org.jboss.cache.passivation;
-import java.util.Properties;
-
import org.jboss.cache.Fqn;
-import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import org.jboss.cache.config.CacheLoaderConfig;
+import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig;
import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.TestDbPropertiesFactory;
-import org.testng.annotations.Test;
+import org.jboss.cache.util.UnitTestDatabaseManager;
import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
-import org.testng.annotations.AfterTest;
+import org.testng.annotations.Test;
+import java.util.Properties;
+
/**
* Tests passivation using JDBC Cache Loader.
* This test has MySQL hard-coded. To run it, run MySQL first: mysqld -u=root
*
* @author <a href="mailto:{hmesha at novell.com}">{Hany Mesha}</a>
- * @version $Id$
+ * @version $Id$
*/
@Test(groups = "functional", testName = "passivation.PassivationToJDBCCacheLoaderTest")
public class PassivationToJDBCCacheLoaderTest extends PassivationTestsBase
@@ -36,18 +36,18 @@
public void createDatabase()
{
durration = System.currentTimeMillis();
- props = TestDbPropertiesFactory.getTestDbProperties();
+ props = UnitTestDatabaseManager.getTestDbProperties();
}
@AfterTest
public void shutDownDatabase()
{
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(props);
}
private Properties getJDBCProps()
{
- return props;
+ return props;
}
@AfterMethod(alwaysRun = true)
@@ -56,7 +56,7 @@
log.info("**** TEARING DOWN ****");
if (loader != null) loader.remove(Fqn.ROOT);
TestingUtil.killCaches(cache);
- TestDbPropertiesFactory.shutdownInMemoryDatabase(props);
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(props);
}
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferTestBase.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -22,7 +22,11 @@
package org.jboss.cache.statetransfer;
-import org.jboss.cache.*;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Region;
+import org.jboss.cache.UnitTestCacheFactory;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
@@ -30,8 +34,8 @@
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.marshall.SelectedClassnameClassLoader;
-import org.jboss.cache.util.TestDbPropertiesFactory;
import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.UnitTestDatabaseManager;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import org.testng.annotations.AfterMethod;
@@ -223,12 +227,12 @@
{
if (cacheloaderClass.equals("org.jboss.cache.loader.JDBCCacheLoader"))
{
- Properties prop = TestDbPropertiesFactory.getTestDbProperties();
+ Properties prop = UnitTestDatabaseManager.getTestDbProperties();
String props = "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" + "cache.jdbc.url="
+ prop.getProperty("cache.jdbc.url") + "\n" + "cache.jdbc.user="
+ prop.getProperty("cache.jdbc.user") + "\n" + "cache.jdbc.password="
+ prop.getProperty("cache.jdbc.password") + "\n" + "cache.jdbc.node.type="
- + prop.getProperty("cache.jdbc.node.type") + "\n" + "cache.jdbc.sql-concat="
+ + prop.getProperty("cache.jdbc.node.type") + "\n" + "cache.jdbc.sql-concat="
+ prop.getProperty("cache.jdbc.sql-concat") + "\n" + "cache.jdbc.table.name="
+ prop.getProperty("cache.jdbc.table.name");
@@ -395,7 +399,7 @@
protected ClassLoader getClassLoader() throws Exception
{
String[] includesClasses = {"org.jboss.cache.marshall.Person",
- "org.jboss.cache.marshall.Address"};
+ "org.jboss.cache.marshall.Address"};
String[] excludesClasses = {};
ClassLoader cl = Thread.currentThread().getContextClassLoader();
return new SelectedClassnameClassLoader(includesClasses, excludesClasses, cl);
@@ -404,7 +408,7 @@
protected ClassLoader getNotFoundClassLoader() throws Exception
{
String[] notFoundClasses = {"org.jboss.cache.marshall.Person",
- "org.jboss.cache.marshall.Address"};
+ "org.jboss.cache.marshall.Address"};
ClassLoader cl = Thread.currentThread().getContextClassLoader();
return new SelectedClassnameClassLoader(null, null, notFoundClasses, cl);
}
Deleted: core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -1,141 +0,0 @@
-package org.jboss.cache.util;
-
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import java.io.IOException;
-import java.io.File;
-import java.sql.DriverManager;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.sql.SQLException;
-
-/**
- * @author Mircea.Markus at jboss.com
- */
-public class TestDbPropertiesFactory
-{
- private static final Properties realProps = new Properties();
-
- private static AtomicInteger userIndex = new AtomicInteger(0);
-
- static {
- //so that all individual databases are created here
- System.setProperty("derby.system.home", TestingUtil.TEST_FILES);
- try
- {
- realProps.load(TestDbPropertiesFactory.class.getClassLoader().getResourceAsStream("cache-jdbc.properties"));
- } catch (IOException e)
- {
- e.printStackTrace();
- throw new Error("Missing property file: cache-jdbc.properties",e);
- }
- }
-
- public static Properties getTestDbProperties()
- {
- synchronized (realProps)
- {
- return returnBasedOnDifferentInstance();
- }
- }
-
- public static void shutdownInMemoryDatabase(Properties props)
- {
- Connection conn = null;
- Statement st = null;
- try
- {
- String shutDownConnection = getShutdownUrl(props);
- String url = props.getProperty("cache.jdbc.url");
- assert url != null;
- conn = DriverManager.getConnection(shutDownConnection);
- st = conn.createStatement();
- st.execute("SHUTDOWN");
- }
- catch (Throwable e)
- {
- throw new IllegalStateException(e);
- }
- finally
- {
- try
- {
- conn.close();
- st.close();
- } catch (SQLException e)
- {
- e.printStackTrace();
- }
- }
- }
-
- public static void clearDatabaseFiles(Properties props)
- {
- //now delete the disk folder
- String dbName = getDatabaseName(props);
- String toDel = TestingUtil.TEST_FILES + File.separator + dbName;
- TestingUtil.recursiveFileRemove(toDel);
- }
-
- public static String getDatabaseName(Properties prop)
- {
- //jdbc:hsqldb:mem:jbosscache
- StringTokenizer tokenizer = new StringTokenizer(prop.getProperty("cache.jdbc.url"), ":");
- tokenizer.nextToken();
- tokenizer.nextToken();
- tokenizer.nextToken();
- return tokenizer.nextToken();
- }
-
- private static String getShutdownUrl(Properties props)
- {
- String url = props.getProperty("cache.jdbc.url");
- assert url != null;
- //jdbc:derby:jbossdb;create=true
- StringTokenizer tokenizer = new StringTokenizer(url,";");
- String result = tokenizer.nextToken() + ";" + "shutdown=true";
- return result;
- }
-
- private static Properties returnBasedOnDifferentInstance()
- {
- //jdbc:hsqldb:mem:jbosscache
- Properties toReturn = (Properties) realProps.clone();
- String jdbcUrl = toReturn.getProperty("cache.jdbc.url");
- Pattern pattern = Pattern.compile("jbosscache");
- Matcher matcher = pattern.matcher(jdbcUrl);
- boolean found = matcher.find();
- assert found;
- String newJdbcUrl = matcher.replaceFirst(extractTestName() + userIndex.incrementAndGet());
- toReturn.put("cache.jdbc.url", newJdbcUrl);
- return toReturn;
- }
-
- private static String extractTestName()
- {
- StackTraceElement[] stack = Thread.currentThread().getStackTrace();
- if (stack.length == 0) return null;
- for (int i = stack.length - 1; i > 0; i--)
- {
- StackTraceElement e = stack[i];
- String className = e.getClassName();
- if (className.indexOf("org.jboss.cache") != -1) return className.replace('.','_') + "_" + e.getMethodName();
- }
- return null;
- }
-
-
- private static Properties returnBasedOnDifferentTables()
- {
- Properties toReturn = (Properties) realProps.clone();
- String tableName = toReturn.getProperty("cache.jdbc.table.name");
- int currentIndex = userIndex.incrementAndGet();
- toReturn.setProperty("cache.jdbc.table.name", tableName + currentIndex);
- String pk = toReturn.getProperty("cache.jdbc.table.primarykey");
- toReturn.setProperty("cache.jdbc.table.primarykey", pk + currentIndex);
- return toReturn;
- }
-}
Copied: core/trunk/src/test/java/org/jboss/cache/util/UnitTestDatabaseManager.java (from rev 7363, core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/UnitTestDatabaseManager.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/util/UnitTestDatabaseManager.java 2009-01-05 11:59:09 UTC (rev 7365)
@@ -0,0 +1,145 @@
+package org.jboss.cache.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+public class UnitTestDatabaseManager
+{
+ private static final Properties realProps = new Properties();
+
+ private static AtomicInteger userIndex = new AtomicInteger(0);
+
+ static
+ {
+ //so that all individual databases are created here
+ try
+ {
+ InputStream stream = new FileLookup().getAsInputStreamFromClassLoader("cache-jdbc.properties");
+ realProps.load(stream);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ throw new Error("Missing property file: cache-jdbc.properties", e);
+ }
+ }
+
+ public static Properties getTestDbProperties()
+ {
+ synchronized (realProps)
+ {
+ return returnBasedOnDifferentInstance();
+ }
+ }
+
+ public static void shutdownInMemoryDatabase(Properties props)
+ {
+ Connection conn = null;
+ Statement st = null;
+ try
+ {
+ String shutDownConnection = getShutdownUrl(props);
+ String url = props.getProperty("cache.jdbc.url");
+ assert url != null;
+ conn = DriverManager.getConnection(shutDownConnection);
+ st = conn.createStatement();
+ st.execute("SHUTDOWN");
+ }
+ catch (Throwable e)
+ {
+ throw new IllegalStateException(e);
+ }
+ finally
+ {
+ try
+ {
+ conn.close();
+ st.close();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void clearDatabaseFiles(Properties props)
+ {
+ //now delete the disk folder
+ String dbName = getDatabaseName(props);
+ String toDel = TestingUtil.TEST_FILES + File.separator + dbName;
+ TestingUtil.recursiveFileRemove(toDel);
+ }
+
+ public static String getDatabaseName(Properties prop)
+ {
+ //jdbc:hsqldb:mem:jbosscache
+ StringTokenizer tokenizer = new StringTokenizer(prop.getProperty("cache.jdbc.url"), ":");
+ tokenizer.nextToken();
+ tokenizer.nextToken();
+ tokenizer.nextToken();
+ return tokenizer.nextToken();
+ }
+
+ private static String getShutdownUrl(Properties props)
+ {
+ String url = props.getProperty("cache.jdbc.url");
+ assert url != null;
+ //jdbc:derby:jbossdb;create=true
+ StringTokenizer tokenizer = new StringTokenizer(url, ";");
+ String result = tokenizer.nextToken() + ";" + "shutdown=true";
+ return result;
+ }
+
+ private static Properties returnBasedOnDifferentInstance()
+ {
+ //jdbc:hsqldb:mem:jbosscache
+ Properties toReturn = (Properties) realProps.clone();
+ String jdbcUrl = toReturn.getProperty("cache.jdbc.url");
+ Pattern pattern = Pattern.compile("jbosscache");
+ Matcher matcher = pattern.matcher(jdbcUrl);
+ boolean found = matcher.find();
+ assert found;
+ String newJdbcUrl = matcher.replaceFirst(extractTestName() + userIndex.incrementAndGet());
+ toReturn.put("cache.jdbc.url", newJdbcUrl);
+ return toReturn;
+ }
+
+ private static String extractTestName()
+ {
+ StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+ if (stack.length == 0) return null;
+ for (int i = stack.length - 1; i > 0; i--)
+ {
+ StackTraceElement e = stack[i];
+ String className = e.getClassName();
+ if (className.indexOf("org.jboss.cache") != -1) return className.replace('.', '_') + "_" + e.getMethodName();
+ }
+ return null;
+ }
+
+
+ private static Properties returnBasedOnDifferentTables()
+ {
+ Properties toReturn = (Properties) realProps.clone();
+ String tableName = toReturn.getProperty("cache.jdbc.table.name");
+ int currentIndex = userIndex.incrementAndGet();
+ toReturn.setProperty("cache.jdbc.table.name", tableName + currentIndex);
+ String pk = toReturn.getProperty("cache.jdbc.table.primarykey");
+ toReturn.setProperty("cache.jdbc.table.primarykey", pk + currentIndex);
+ return toReturn;
+ }
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/util/UnitTestDatabaseManager.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: core/trunk/src/test/resources/cache-jdbc.properties
===================================================================
--- core/trunk/src/test/resources/cache-jdbc.properties 2009-01-05 11:49:39 UTC (rev 7364)
+++ core/trunk/src/test/resources/cache-jdbc.properties 2009-01-05 11:59:09 UTC (rev 7365)
@@ -62,7 +62,7 @@
#cache.jdbc.user=postgres
#cache.jdbc.password=admin
-## Derby
+## HSQL
cache.jdbc.driver = org.hsqldb.jdbcDriver
cache.jdbc.url=jdbc:hsqldb:mem:jbosscache
cache.jdbc.user=sa
More information about the jbosscache-commits
mailing list