3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.cdm
.strategy
.cache
.agent
;
14 import static org
.junit
.Assert
.assertNotNull
;
15 import junit
.framework
.Assert
;
17 import org
.apache
.log4j
.Logger
;
18 import org
.junit
.After
;
19 import org
.junit
.AfterClass
;
20 import org
.junit
.Before
;
21 import org
.junit
.BeforeClass
;
22 import org
.junit
.Test
;
24 import eu
.etaxonomy
.cdm
.common
.CdmUtils
;
25 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
32 public class PersonDefaultCacheStrategyTest
{
33 @SuppressWarnings("unused")
34 private static final Logger logger
= Logger
.getLogger(PersonDefaultCacheStrategyTest
.class);
36 private static Person person1
;
37 private static Person person2
;
38 private static Person person3
;
41 * @throws java.lang.Exception
44 public static void setUpBeforeClass() throws Exception
{
48 * @throws java.lang.Exception
51 public static void tearDownAfterClass() throws Exception
{
57 * @throws java.lang.Exception
60 public void setUp() throws Exception
{
61 person1
= Person
.NewInstance();
63 person1
.setFirstname("P1FN");
64 person1
.setLastname("P1LN");
65 person1
.setPrefix("Dr1.");
66 person1
.setSuffix("Suff1");
68 person2
= Person
.NewInstance();
69 person2
.setNomenclaturalTitle("P2NomT");
70 person2
.setLastname("P2LN");
71 person2
.setFirstname("P2FN");
72 person2
.setSuffix("P2Suff");
74 person3
= Person
.NewInstance(); //empty person
79 * @throws java.lang.Exception
82 public void tearDown() throws Exception
{
85 //**************************************** TESTS **************************************
88 * Test method for {@link eu.etaxonomy.cdm.strategy.cache.agent.PersonDefaultCacheStrategy#NewInstance()}.
91 public final void testNewInstance() {
92 PersonDefaultCacheStrategy cacheStrategy
= PersonDefaultCacheStrategy
.NewInstance();
93 assertNotNull(cacheStrategy
);
97 public final void testGetNomenclaturalTitleCache(){
98 Assert
.assertNotNull("person1 nomenclatural title must not to be null", person1
.getNomenclaturalTitle());
99 Assert
.assertEquals("Person1 nomenclatural title should be created by elements", "Dr1. P1FN P1LN Suff1", person1
.getNomenclaturalTitle());
100 person1
.setSuffix(null);
101 Assert
.assertEquals("Person1 title should be Dr1. P1FN P1LN", "Dr1. P1FN P1LN", person1
.getNomenclaturalTitle());
103 Assert
.assertEquals("Person2 title should be P2NomT", "P2NomT", person2
.getNomenclaturalTitle());
105 Assert
.assertNotNull("person3 nomenclatural title must not to be null", person3
.getNomenclaturalTitle());
106 Assert
.assertTrue("Person3 nomenclatural title must not be empty", CdmUtils
.isNotEmpty(person3
.getNomenclaturalTitle()));
107 //don't take to serious, may be also something different, but not empty
108 Assert
.assertEquals("Person3 title should start with Person#0", "Person#0", person3
.getNomenclaturalTitle().substring(0, 8));
113 public final void testGetTitleCache(){
114 Assert
.assertNotNull("person1 title cache must not to be null", person1
.getTitleCache());
115 Assert
.assertEquals("Person1 title cache should be created by elements", "Dr1. P1FN P1LN Suff1", person1
.getTitleCache());
116 person1
.setSuffix(null);
117 Assert
.assertEquals("Person1 title cache should be Dr1. P1FN P1LN", "Dr1. P1FN P1LN", person1
.getTitleCache());
119 Assert
.assertEquals("Person2 title cache should be P2NomT", "P2FN P2LN P2Suff", person2
.getTitleCache());
121 Assert
.assertNotNull("person3 title cache must not to be null", person3
.getTitleCache());
122 Assert
.assertTrue("Person3 title cache must not be empty", CdmUtils
.isNotEmpty(person3
.getTitleCache()));
123 //don't take to serious, may be also something different, but not empty
124 Assert
.assertEquals("Person3 title cache should start with Person#0", "Person#0", person3
.getTitleCache().substring(0, 8));