1
|
/**
|
2
|
* Copyright (C) 2007 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.model.reference;
|
11
|
|
12
|
import static org.junit.Assert.assertEquals;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
import org.junit.After;
|
16
|
import org.junit.AfterClass;
|
17
|
import org.junit.Assert;
|
18
|
import org.junit.Before;
|
19
|
import org.junit.BeforeClass;
|
20
|
import org.junit.Test;
|
21
|
import org.springframework.beans.BeanUtils;
|
22
|
|
23
|
/**
|
24
|
* @author a.mueller
|
25
|
* @created 23.03.2009
|
26
|
*/
|
27
|
//@Ignore
|
28
|
public class PublicationBaseTest {
|
29
|
@SuppressWarnings("unused")
|
30
|
private static Logger logger = Logger.getLogger(PublicationBaseTest.class);
|
31
|
|
32
|
private IBook reference;
|
33
|
private IArticle reference2;
|
34
|
private String publisher1;
|
35
|
private String publisher2;
|
36
|
private String place1;
|
37
|
private String place2;
|
38
|
|
39
|
/**
|
40
|
* @throws java.lang.Exception
|
41
|
*/
|
42
|
@BeforeClass
|
43
|
public static void setUpBeforeClass() throws Exception {
|
44
|
}
|
45
|
|
46
|
/**
|
47
|
* @throws java.lang.Exception
|
48
|
*/
|
49
|
@AfterClass
|
50
|
public static void tearDownAfterClass() throws Exception {
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* @throws java.lang.Exception
|
55
|
*/
|
56
|
@Before
|
57
|
public void setUp() throws Exception {
|
58
|
publisher1 = "publisher1";
|
59
|
publisher2 = "publisher2";
|
60
|
place1 = "place1";
|
61
|
place2 = "place2";
|
62
|
reference = ReferenceFactory.newBook();
|
63
|
reference2 = ReferenceFactory.newArticle();
|
64
|
|
65
|
}
|
66
|
|
67
|
/**
|
68
|
* @throws java.lang.Exception
|
69
|
*/
|
70
|
@After
|
71
|
public void tearDown() throws Exception {
|
72
|
}
|
73
|
|
74
|
|
75
|
|
76
|
/**
|
77
|
* Test method for {@link eu.etaxonomy.cdm.model.reference.PublicationBase#addPublisher(java.lang.String, java.lang.String)}.
|
78
|
*/
|
79
|
@Test
|
80
|
public void testAddPublisherStringString() {
|
81
|
assertEquals("No publisher is set", null, reference.getPublisher());
|
82
|
reference.setPublisher(publisher1, place1);
|
83
|
assertEquals("The publishers is publisher1", publisher1, reference.getPublisher());
|
84
|
assertEquals("The place is place1", place1, reference.getPlacePublished());
|
85
|
reference.setPublisher(publisher2, place2);
|
86
|
assertEquals("Second publisher must be publisher2", publisher2, reference.getPublisher());
|
87
|
|
88
|
assertEquals("Second publication place must be place2", place2, reference.getPlacePublished());
|
89
|
}
|
90
|
|
91
|
@Test
|
92
|
public void testInReferenceValidation(){
|
93
|
IJournal journal = ReferenceFactory.newJournal();
|
94
|
reference2.setInJournal(journal);
|
95
|
//TODO: to validate it, the object has to be saved to the db
|
96
|
IBookSection booksection = ((Reference)reference2).castReferenceToBookSection();
|
97
|
|
98
|
}
|
99
|
|
100
|
|
101
|
/**
|
102
|
* Test method for {@link eu.etaxonomy.cdm.model.reference.Reference#clone()}.
|
103
|
* This test was originally designed for the case when publisher was still
|
104
|
* a subclass holding publishing information. The current model is simplified
|
105
|
* and therefore this test is more or less obsolet
|
106
|
*/
|
107
|
@Test
|
108
|
public void testClone() {
|
109
|
reference.setPublisher(publisher1, place1);
|
110
|
// publicationBase.addPublisher(publisher2, place2);
|
111
|
Reference clone = (Reference)reference.clone();
|
112
|
assertEquals("Publisher place must be equal in original publication and cloned publication", place1, clone.getPlacePublished());
|
113
|
Assert.assertSame(place1, reference.getPublisher(), clone.getPublisher());
|
114
|
}
|
115
|
|
116
|
@Test
|
117
|
public void beanTests(){
|
118
|
// #5307 Test that BeanUtils does not fail
|
119
|
BeanUtils.getPropertyDescriptors(Reference.class);
|
120
|
}
|
121
|
}
|