Project

General

Profile

Download (3.49 KB) Statistics
| Branch: | Tag: | Revision:
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
 * Originally tested the PublicationBase class.
25
 * Now this class was merged into {@link Reference}
26
 * therefore this class is a special test for
27
 * {@link Reference}.
28
 * @author a.mueller
29
 * @since 23.03.2009
30
 */
31
public class PublicationBaseTest {
32
	@SuppressWarnings("unused")
33
	private static Logger logger = Logger.getLogger(PublicationBaseTest.class);
34

    
35
	private IBook reference;
36
	private IArticle reference2;
37
	private String publisher1;
38
	private String publisher2;
39
	private String place1;
40
	private String place2;
41

    
42
	/**
43
	 * @throws java.lang.Exception
44
	 */
45
	@BeforeClass
46
	public static void setUpBeforeClass() throws Exception {
47
	}
48

    
49
	/**
50
	 * @throws java.lang.Exception
51
	 */
52
	@AfterClass
53
	public static void tearDownAfterClass() throws Exception {
54
	}
55

    
56
	/**
57
	 * @throws java.lang.Exception
58
	 */
59
	@Before
60
	public void setUp() throws Exception {
61
		publisher1 = "publisher1";
62
		publisher2 = "publisher2";
63
		place1 = "place1";
64
		place2 = "place2";
65
		reference = ReferenceFactory.newBook();
66
		reference2 = ReferenceFactory.newArticle();
67

    
68
	}
69

    
70
	/**
71
	 * @throws java.lang.Exception
72
	 */
73
	@After
74
	public void tearDown() throws Exception {
75
	}
76

    
77

    
78

    
79
	/**
80
	 * Test method for {@link eu.etaxonomy.cdm.model.reference.PublicationBase#addPublisher(java.lang.String, java.lang.String)}.
81
	 */
82
	@Test
83
	public void testAddPublisherStringString() {
84
		assertEquals("No publisher is set", null, reference.getPublisher());
85
		reference.setPublisher(publisher1, place1);
86
		assertEquals("The publishers is publisher1", publisher1, reference.getPublisher());
87
		assertEquals("The place is place1", place1, reference.getPlacePublished());
88
		reference.setPublisher(publisher2, place2);
89
		assertEquals("Second publisher must be publisher2", publisher2, reference.getPublisher());
90

    
91
		assertEquals("Second publication place must be place2", place2, reference.getPlacePublished());
92
	}
93

    
94
	@Test
95
	public void testInReferenceValidation(){
96
		IJournal journal = ReferenceFactory.newJournal();
97
		reference2.setInJournal(journal);
98
		//TODO: to validate it, the object has to be saved to the db
99
		IBookSection booksection = ((Reference)reference2).castReferenceToBookSection();
100

    
101
	}
102

    
103

    
104
	/**
105
	 * Test method for {@link eu.etaxonomy.cdm.model.reference.Reference#clone()}.
106
	 * This test was originally designed for the case when publisher was still
107
	 * a subclass holding publishing information. The current model is simplified
108
	 * and therefore this test is more or less obsolet
109
	 */
110
	@Test
111
	public void testClone() {
112
		reference.setPublisher(publisher1, place1);
113
//		publicationBase.addPublisher(publisher2, place2);
114
		Reference clone = (Reference)reference.clone();
115
		assertEquals("Publisher place must be equal in original publication and cloned publication", place1, clone.getPlacePublished());
116
		Assert.assertSame(place1, reference.getPublisher(), clone.getPublisher());
117
	}
118

    
119
    @Test
120
    public void beanTests(){
121
//      #5307 Test that BeanUtils does not fail
122
        BeanUtils.getPropertyDescriptors(Reference.class);
123
    }
124
}
(1-1/2)