--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2014 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.lazyloading;
+
+import java.util.UUID;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.hibernate.collection.spi.PersistentCollection;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import eu.etaxonomy.cdm.api.service.ICommonService;
+import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
+import eu.etaxonomy.cdm.api.service.ITaxonService;
+import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.Language;
+import eu.etaxonomy.cdm.model.description.PolytomousKey;
+import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
+import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
+import eu.etaxonomy.taxeditor.httpinvoker.BaseRemotingTest;
+import eu.etaxonomy.taxeditor.httpinvoker.CDMServer;
+
+/**
+ * @author cmathew
+ * @date 16 Oct 2014
+ *
+ */
+public class CdmEntityCacherTest extends BaseRemotingTest {
+
+ private static final Logger logger = Logger.getLogger(CdmEntityCacherTest.class);
+
+ UUID polytomousKeyUuid = UUID.fromString("0d53ba20-7de4-4baa-bd8a-401048447d66");
+ UUID taxon1Uuid = UUID.fromString("2b336df7-29e8-4f79-985f-66502739d22f");
+
+
+ IPolytomousKeyService polytomousKeyService = getRemoteApplicationController().getPolytomousKeyService();
+ ICommonService commonService = getRemoteApplicationController().getCommonService();
+ ITaxonService taxonService = getRemoteApplicationController().getTaxonService();
+
+ Language english = Language.getLanguageFromUuid(Language.uuidEnglish);
+
+ @BeforeClass
+ public static void initializePolytomousKeyTest() {
+ logger.setLevel(Level.INFO);
+ CDMServer.getInstance().setKeepServerRunning(true);
+
+ initializeController("default", "127.0.0.1", 8080, "", NomenclaturalCode.ICNAFP);
+ }
+
+ @Test
+ public void testSimpleCache() {
+
+
+ }
+
+ @Test
+ public void testCachingCdmEntities() {
+ PolytomousKey pkey = CdmBase.deproxy(polytomousKeyService.find(polytomousKeyUuid),PolytomousKey.class);
+ PolytomousKeyNode pkeynode = pkey.getRoot();
+
+ PersistentCollection children = (PersistentCollection) pkeynode.getChildren();
+ PolytomousKeyNode childNode0 = (PolytomousKeyNode)commonService.get(children, 0);
+ PolytomousKey subkey1 = CdmBase.deproxy(childNode0.getSubkey(),PolytomousKey.class);
+ String subkey1title = subkey1.getTitleCache();
+ subkey1.setTitleCache(subkey1title + "test", true);
+
+ PolytomousKeyNode childNode1 = (PolytomousKeyNode)commonService.get(children, 1);
+ PolytomousKey subkey2 = CdmBase.deproxy(childNode1.getSubkey(),PolytomousKey.class);
+ String subkey2title = subkey2.getTitleCache();
+ subkey2.setTitleCache(subkey2title + "test", true);
+
+ Assert.assertNotSame(subkey1, subkey2);
+
+ polytomousKeyService.merge(pkey);
+
+
+ }
+
+
+}