package org.jboss.cache.aop;

import junit.framework.TestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.PropertyConfigurator;
import org.jboss.cache.aop.PojoCache;
import org.jboss.cache.aop.test.IdObject;
import org.jboss.cache.aop.test.ValueObject;

import java.util.HashMap;
import java.util.Map;

public class RecursiveRefAopTest extends TestCase
{
   private static final String CONFIG_FILENAME = "META-INF/local-service.xml";
   private PojoCache treeCache;
   Log log=LogFactory.getLog(ReplicatedAopTest.class);

   private Map cachedMap;

   public RecursiveRefAopTest(String name)
   {
      super(name);
   }

   protected void setUp() throws Exception
   {
      super.setUp();
      log.info("setUp() ....");
      treeCache = new PojoCache();

      PropertyConfigurator cacheConfig = new PropertyConfigurator();
      cacheConfig.configure(treeCache, CONFIG_FILENAME);
      treeCache.startService();
      treeCache.putObject("/aop/test", new HashMap());
      cachedMap = (Map) treeCache.getObject("/aop/test");
   }

   protected void tearDown() throws Exception
   {
      super.tearDown();
   }

   public void XtestDummy() {

   }

   /**
    * This test feature is not currently supported now since we can't support key is non-primitive object
    * that overrides the hashCode().
    */
   public void testRecuriveMapKey()
   {
      try {
         IdObject id = new IdObject("1");
         ValueObject value = new ValueObject(id, 3.0f);
         cachedMap.put(id, value);
      } // try
      catch (Exception x) {
         x.printStackTrace();
         fail("testFailed");
      } // catch
   } // initCache


} // class TestRunner


