// $Id: CacheImplTest.java,v 1.1 2003/10/30 01:21:19 bwang00 Exp $

/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 * Created on Jan 18, 2003
 */
package org.jboss.cache;


import java.util.ArrayList;
import java.util.HashMap;




/**
 *
 * @author Bela Ban
 * @version $Revision: 1.1 $
 */
public class CacheImplTest {


    public static void main(String[] args) {
        CacheImpl c=new CacheImpl();


        // c.setCacheMode(Options.TRANSIENT);


        try {
            System.out.println("-- creating replicated cache");
            c.createService();

            System.out.println("-- starting cache");
            c.startService();


            c.put("name", "Bela Ban");
            System.out.println("cache size is " + c.size());
            System.out.println("value for \"name\" is " + c.get("name"));

            CacheKey k1, k2;
            k1=new CacheKey("name");
            k2=new CacheKey("name");

            HashMap map=new HashMap();

            if(k1.equals(k2))
                System.out.println("is equal");
            else
                System.out.println("not equals");

            map.put(k1, "value for k1");
            map.put(k2, "value for k2");

            System.out.println("size(): " + map.size() + ", value for \"name\": " + map.get("name"));

            ArrayList l=new ArrayList();
            if(!l.contains(k1))
                l.add(k1);

            if(!l.contains(k2))
                l.add(k2);

            System.out.println("size(): " + l.size() + ", first element: " + l.get(0));
        }
        catch(TimeoutException e) {
        }
        catch(LockingException e) {
        }
        catch(Throwable t) {
            System.err.println("exception is " + t);
        }
    }
}
