1   /***
2    * 
3    * Copyright 2004 Protique Ltd
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License"); 
6    * you may not use this file except in compliance with the License. 
7    * You may obtain a copy of the License at 
8    * 
9    * http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License. 
16   * 
17   **/
18  package org.codehaus.activespace.cache;
19  
20  import org.codehaus.activespace.jms.ActiveMQClusteredCacheManagerFactory;
21  
22  /***
23   * @version $Revision: 1.4 $
24   */
25  public class ClusteredCacheTest extends TransactionalCacheTest {
26      protected ClusteredCacheManagerFactory cacheManagerFactory = new ActiveMQClusteredCacheManagerFactory("vm://localhost");
27      private TransactionalCacheManager secondaryCacheManager;
28      private TransactionalCache secondaryCache;
29  
30      public void testTransaction() throws Exception {
31          assertTrue(secondaryCache.isEmpty());
32  
33          super.testTransaction();
34  
35          // lets check that the transactions have been applied to our copy
36          assertEquals("Secondary cache should not be empty: " + secondaryCache, 2, secondaryCache.size());
37          assertEquals("James", secondaryCache.get("name"));
38          assertEquals("London", secondaryCache.get("location"));
39      }
40  
41      protected void setUp() throws Exception {
42          secondaryCacheManager = cacheManagerFactory.createCacheManager(getName());
43          secondaryCache = secondaryCacheManager.createTransactionalCache("A");
44          super.setUp();
45      }
46  
47      protected void tearDown() throws Exception {
48          super.tearDown();
49          secondaryCacheManager.stop();
50      }
51  
52      protected TransactionalCacheManager createCacheManager() throws Exception {
53          return cacheManagerFactory.createCacheManager(getName());
54      }
55  }