Project

General

Profile

Download (1.98 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.aspectj;
11

    
12
import static org.junit.Assert.*;
13

    
14
import java.beans.PropertyChangeEvent;
15
import java.beans.PropertyChangeListener;
16

    
17
import org.apache.log4j.Level;
18
import org.apache.log4j.Logger;
19
import org.junit.Before;
20
import org.junit.Test;
21

    
22
import eu.etaxonomy.cdm.model.name.BotanicalName;
23
import eu.etaxonomy.cdm.model.name.NonViralName;
24
import eu.etaxonomy.cdm.model.name.Rank;
25

    
26
	public class PropertyChangeTest implements PropertyChangeListener {
27
		static Logger logger = Logger.getLogger(PropertyChangeTest.class);
28
		private Object lastPropValue;
29

    
30
		public void propertyChange(PropertyChangeEvent e){
31
		logger.debug("Property [" + e.getPropertyName() 
32
				+ "] changed from " + e.getOldValue() 
33
				+ " to " + e.getNewValue());
34
		lastPropValue = e.getNewValue() == null ? null : e.getNewValue();
35
		}
36

    
37
		@Test
38
		public void testPropertyChange() {
39
			NonViralName b = NonViralName.NewInstance(Rank.SPECIES());
40
			b.addPropertyChangeListener(this);
41
			b.setGenusOrUninomial("Abies");
42
				assertEquals(b.getGenusOrUninomial(), lastPropValue);
43
			b.setGenusOrUninomial("Picea");
44
				assertEquals(b.getGenusOrUninomial(), lastPropValue);
45
			b.setGenusOrUninomial("Unipicea");
46
				assertEquals(b.getGenusOrUninomial(), lastPropValue);
47
			b.setSpecificEpithet("vulgaris");
48
				assertEquals(b.getSpecificEpithet(), lastPropValue);
49
			b.setParsingProblem(2);
50
				assertEquals(b.getParsingProblem(), lastPropValue);
51
		}
52

    
53
		@Test
54
		public void testPropertyChangeBoolean() {
55
			BotanicalName b = BotanicalName.NewInstance(Rank.SPECIES());
56
			b.addPropertyChangeListener(this);
57
			b.setAnamorphic(true);
58
			assertEquals(b.isAnamorphic(), lastPropValue);
59
		}
60
		
61
		@Before
62
		public void updateDebugLevel(){
63
			logger.setLevel(Level.INFO);
64
		}
65

    
66
	}
67

    
(2-2/2)