Project

General

Profile

Download (2.15 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.assertEquals;
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.INonViralName;
24
import eu.etaxonomy.cdm.model.name.Rank;
25
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
26
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
27

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

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

    
40
		@Test
41
		public void testPropertyChange() {
42
		    INonViralName b = TaxonNameFactory.NewNonViralInstance(Rank.SPECIES());
43
			((TaxonNameBase<?,?>)b).addPropertyChangeListener(this);
44
			b.setGenusOrUninomial("Abies");
45
				assertEquals(b.getGenusOrUninomial(), lastPropValue);
46
			b.setGenusOrUninomial("Picea");
47
				assertEquals(b.getGenusOrUninomial(), lastPropValue);
48
			b.setGenusOrUninomial("Unipicea");
49
				assertEquals(b.getGenusOrUninomial(), lastPropValue);
50
			b.setSpecificEpithet("vulgaris");
51
				assertEquals(b.getSpecificEpithet(), lastPropValue);
52
			b.setParsingProblem(2);
53
				assertEquals(b.getParsingProblem(), lastPropValue);
54
		}
55

    
56
		@Test
57
		public void testPropertyChangeBoolean() {
58
			BotanicalName b = TaxonNameFactory.NewBotanicalInstance(Rank.SPECIES());
59
			b.addPropertyChangeListener(this);
60
			b.setAnamorphic(true);
61
			assertEquals(b.isAnamorphic(), lastPropValue);
62
		}
63

    
64
		@Before
65
		public void updateDebugLevel(){
66
			logger.setLevel(Level.INFO);
67
		}
68

    
69
	}
70

    
(2-2/2)