1 package org.apache.commons.jcs3.auxiliary.remote.http.client;
2
3 import org.apache.commons.jcs3.JCS;
4 import org.apache.commons.jcs3.access.CacheAccess;
5
6 /*
7 * Licensed to the Apache Software Foundation (ASF) under one
8 * or more contributor license agreements. See the NOTICE file
9 * distributed with this work for additional information
10 * regarding copyright ownership. The ASF licenses this file
11 * to you under the Apache License, Version 2.0 (the
12 * "License"); you may not use this file except in compliance
13 * with the License. You may obtain a copy of the License at
14 *
15 * http://www.apache.org/licenses/LICENSE-2.0
16 *
17 * Unless required by applicable law or agreed to in writing,
18 * software distributed under the License is distributed on an
19 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20 * KIND, either express or implied. See the License for the
21 * specific language governing permissions and limitations
22 * under the License.
23 */
24
25 import junit.framework.TestCase;
26
27 /** Manual tester for a JCS instance configured to use the http client. */
28 public class RemoteHttpCacheManualTester
29 extends TestCase
30 {
31 /** number to use for the test */
32 private static final int items = 100;
33
34 /**
35 * Test setup
36 */
37 @Override
38 public void setUp()
39 {
40 JCS.setConfigFilename( "/TestRemoteHttpCache.ccf" );
41 }
42
43 /**
44 * A unit test for JUnit
45 * @throws Exception Description of the Exception
46 */
47 public void testSimpleLoad()
48 throws Exception
49 {
50 final CacheAccess<String, String> jcs = JCS.getInstance( "testCache1" );
51
52 jcs.put( "TestKey", "TestValue" );
53
54 // System.out.println( jcs.getStats() );
55
56 for ( int i = 1; i <= items; i++ )
57 {
58 jcs.put( i + ":key", "data" + i );
59 }
60
61 for ( int i = items; i > 0; i-- )
62 {
63 final String res = jcs.get( i + ":key" );
64 if ( res == null )
65 {
66 //assertNotNull( "[" + i + ":key] should not be null", res );
67 }
68 }
69
70 // test removal
71 jcs.remove( "300:key" );
72 assertNull( jcs.get( "TestKey" ) );
73
74 // System.out.println( jcs.getStats() );
75 }
76 }