View Javadoc
1   package org.apache.commons.jcs.engine;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import junit.framework.TestCase;
23  import org.apache.commons.jcs.auxiliary.remote.MockRemoteCacheListener;
24  import org.apache.commons.jcs.engine.behavior.ICacheEventQueue;
25  import org.apache.commons.jcs.engine.behavior.ICacheEventQueue.QueueType;
26  import org.apache.commons.jcs.engine.behavior.ICacheListener;
27  
28  /** Unit tests for the CacheEventQueueFactory */
29  public class CacheEventQueueFactoryUnitTest
30      extends TestCase
31  {
32      /** Test create */
33      public void testCreateCacheEventQueue_Single()
34      {
35          // SETUP
36          QueueType eventQueueType = QueueType.SINGLE;
37          ICacheListener<String, String> listener = new MockRemoteCacheListener<String, String>();
38          long listenerId = 1;
39  
40          CacheEventQueueFactory<String, String> factory = new CacheEventQueueFactory<String, String>();
41  
42          // DO WORK
43          ICacheEventQueue<String, String> result = factory.createCacheEventQueue( listener, listenerId, "cacheName", "threadPoolName", eventQueueType );
44  
45          // VERIFY
46          assertNotNull( "Should have a result", result );
47          assertTrue( "Wrong type", result instanceof CacheEventQueue );
48      }
49  
50      /** Test create */
51      public void testCreateCacheEventQueue_Pooled()
52      {
53          // SETUP
54          QueueType eventQueueType = QueueType.POOLED;
55          ICacheListener<String, String> listener = new MockRemoteCacheListener<String, String>();
56          long listenerId = 1;
57  
58          CacheEventQueueFactory<String, String> factory = new CacheEventQueueFactory<String, String>();
59  
60          // DO WORK
61          ICacheEventQueue<String, String> result = factory.createCacheEventQueue( listener, listenerId, "cacheName", "threadPoolName", eventQueueType );
62  
63          // VERIFY
64          assertNotNull( "Should have a result", result );
65          assertTrue( "Wrong type", result instanceof PooledCacheEventQueue );
66      }
67  }