1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.strategy.cache.reference;
|
11
|
|
12
|
import static org.junit.Assert.assertEquals;
|
13
|
import static org.junit.Assert.assertNotNull;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.junit.After;
|
17
|
import org.junit.AfterClass;
|
18
|
import org.junit.Before;
|
19
|
import org.junit.BeforeClass;
|
20
|
import org.junit.Test;
|
21
|
|
22
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
23
|
import eu.etaxonomy.cdm.model.reference.ICdDvd;
|
24
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
25
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
26
|
|
27
|
public class CdDvdDefaultCacheStrategyTest {
|
28
|
@SuppressWarnings("unused")
|
29
|
private static Logger logger = Logger.getLogger(CdDvdDefaultCacheStrategyTest.class);
|
30
|
|
31
|
Reference cdDvd;
|
32
|
String title;
|
33
|
String publisher;
|
34
|
String place;
|
35
|
TimePeriod publicationDate;
|
36
|
CdDvdDefaultCacheStrategy<Reference> instance;
|
37
|
|
38
|
@BeforeClass
|
39
|
public static void setUpBeforeClass() throws Exception {
|
40
|
}
|
41
|
|
42
|
@AfterClass
|
43
|
public static void tearDownAfterClass() throws Exception {
|
44
|
}
|
45
|
|
46
|
@Before
|
47
|
public void setUp() throws Exception {
|
48
|
ReferenceFactory refFactory = ReferenceFactory.newInstance();
|
49
|
this.cdDvd = refFactory.newCdDvd();
|
50
|
title = "A nice CD title";
|
51
|
cdDvd.setTitle(title);
|
52
|
publisher = "An ugly publisher";
|
53
|
place = "A beutiful place";
|
54
|
publicationDate = TimePeriod.NewInstance(1999, 2001);
|
55
|
cdDvd.setDatePublished(publicationDate);
|
56
|
this.instance = CdDvdDefaultCacheStrategy.NewInstance();
|
57
|
}
|
58
|
|
59
|
@After
|
60
|
public void tearDown() throws Exception {
|
61
|
}
|
62
|
|
63
|
@Test
|
64
|
public void testNewInstance() {
|
65
|
assertNotNull(instance);
|
66
|
}
|
67
|
|
68
|
@Test
|
69
|
public void testGetNomRefTitleWithoutYearAndAuthor() {
|
70
|
String result = instance.getNomRefTitleWithoutYearAndAuthor(cdDvd);
|
71
|
assertEquals(title, result);
|
72
|
}
|
73
|
|
74
|
//TODO missing publicationPlace and publisher has to be discussed
|
75
|
@Test
|
76
|
public void testGetTitleCache() {
|
77
|
String result = instance.getTitleCache(cdDvd);
|
78
|
assertEquals(title + ". 1999-2001", result);
|
79
|
}
|
80
|
|
81
|
|
82
|
}
|