1 package org.apache.commons.jcs.auxiliary.remote.http.client;
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.JCS;
24 import org.apache.commons.jcs.access.CacheAccess;
25
26 /** Manual tester for a JCS instance configured to use the http client. */
27 public class RemoteHttpCacheManualTester
28 extends TestCase
29 {
30 /** number to use for the test */
31 private static int items = 100;
32
33 /**
34 * Test setup
35 */
36 @Override
37 public void setUp()
38 {
39 JCS.setConfigFilename( "/TestRemoteHttpCache.ccf" );
40 }
41
42 /**
43 * A unit test for JUnit
44 * @throws Exception Description of the Exception
45 */
46 public void testSimpleLoad()
47 throws Exception
48 {
49 CacheAccess<String, String> jcs = JCS.getInstance( "testCache1" );
50
51 jcs.put( "TestKey", "TestValue" );
52
53 // System.out.println( jcs.getStats() );
54
55 for ( int i = 1; i <= items; i++ )
56 {
57 jcs.put( i + ":key", "data" + i );
58 }
59
60 for ( int i = items; i > 0; i-- )
61 {
62 String res = jcs.get( i + ":key" );
63 if ( res == null )
64 {
65 //assertNotNull( "[" + i + ":key] should not be null", res );
66 }
67 }
68
69 // test removal
70 jcs.remove( "300:key" );
71 assertNull( jcs.get( "TestKey" ) );
72
73 // System.out.println( jcs.getStats() );
74 }
75 }