3 * Copyright (C) 2014 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.lazyloading
;
12 import java
.util
.UUID
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.hibernate
.collection
.spi
.PersistentCollection
;
16 import org
.junit
.Assert
;
17 import org
.junit
.BeforeClass
;
18 import org
.junit
.Test
;
20 import eu
.etaxonomy
.cdm
.api
.service
.ICommonService
;
21 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyService
;
22 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
23 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
24 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
25 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKey
;
26 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
27 import eu
.etaxonomy
.taxeditor
.httpinvoker
.BaseRemotingTest
;
34 public class CdmEntityCacherTest
extends BaseRemotingTest
{
36 private static final Logger logger
= Logger
.getLogger(CdmEntityCacherTest
.class);
38 UUID polytomousKeyUuid
= UUID
.fromString("0d53ba20-7de4-4baa-bd8a-401048447d66");
39 UUID taxon1Uuid
= UUID
.fromString("2b336df7-29e8-4f79-985f-66502739d22f");
42 IPolytomousKeyService polytomousKeyService
= getRemoteApplicationController().getPolytomousKeyService();
43 ICommonService commonService
= getRemoteApplicationController().getCommonService();
44 ITaxonService taxonService
= getRemoteApplicationController().getTaxonService();
46 Language english
= Language
.getLanguageFromUuid(Language
.uuidEnglish
);
49 public static void initializePolytomousKeyTest() {
53 public void testSimpleCache() {
59 public void testCachingCdmEntities() {
60 PolytomousKey pkey
= CdmBase
.deproxy(polytomousKeyService
.find(polytomousKeyUuid
),PolytomousKey
.class);
61 PolytomousKeyNode pkeynode
= pkey
.getRoot();
63 PersistentCollection children
= (PersistentCollection
) pkeynode
.getChildren();
64 PolytomousKeyNode childNode0
= (PolytomousKeyNode
)commonService
.get(children
, 0);
65 PolytomousKey subkey1
= CdmBase
.deproxy(childNode0
.getSubkey(),PolytomousKey
.class);
66 String subkey1title
= subkey1
.getTitleCache();
67 subkey1
.setTitleCache(subkey1title
+ "test", true);
69 PolytomousKeyNode childNode1
= (PolytomousKeyNode
)commonService
.get(children
, 1);
70 PolytomousKey subkey2
= CdmBase
.deproxy(childNode1
.getSubkey(),PolytomousKey
.class);
71 String subkey2title
= subkey2
.getTitleCache();
72 subkey2
.setTitleCache(subkey2title
+ "test", true);
74 Assert
.assertNotSame(subkey1
, subkey2
);
76 polytomousKeyService
.merge(pkey
);