View Javadoc
1   package org.apache.commons.jcs.auxiliary.remote;
2   
3   import java.util.ArrayList;
4   import java.util.List;
5   
6   import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
7   
8   /*
9    * Licensed to the Apache Software Foundation (ASF) under one
10   * or more contributor license agreements.  See the NOTICE file
11   * distributed with this work for additional information
12   * regarding copyright ownership.  The ASF licenses this file
13   * to you under the Apache License, Version 2.0 (the
14   * "License"); you may not use this file except in compliance
15   * with the License.  You may obtain a copy of the License at
16   *
17   *   http://www.apache.org/licenses/LICENSE-2.0
18   *
19   * Unless required by applicable law or agreed to in writing,
20   * software distributed under the License is distributed on an
21   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22   * KIND, either express or implied.  See the License for the
23   * specific language governing permissions and limitations
24   * under the License.
25   */
26  
27  import junit.framework.TestCase;
28  
29  /**
30   * Tests for RemoteCacheNoWaitFacade.
31   */
32  public class RemoteCacheNoWaitFacadeUnitTest
33      extends TestCase
34  {
35      /**
36       * Verify that we can add an item.
37       */
38      public void testAddNoWait_InList()
39      {
40          // SETUP
41          List<RemoteCacheNoWait<String, String>> noWaits = new ArrayList<RemoteCacheNoWait<String,String>>();
42          IRemoteCacheAttributes cattr = new RemoteCacheAttributes();
43          cattr.setCacheName( "testCache1" );
44  
45          RemoteCache<String, String> client = new RemoteCache<String, String>(cattr, null, null, null);
46          RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client );
47          noWaits.add( noWait );
48  
49          RemoteCacheNoWaitFacade<String, String> facade = new RemoteCacheNoWaitFacade<String, String>(noWaits, cattr, null, null, null );
50          
51          // VERIFY
52          assertEquals( "Should have one entry.", 1, facade.noWaits.size() );
53          assertTrue( "Should be in the list.", facade.noWaits.contains( noWait ) );
54          assertSame( "Should have same facade.", facade, ((RemoteCache<String, String>)facade.noWaits.get(0).getRemoteCache()).getFacade() );
55      }
56  }