01: /*
02: * WbPropertiesTest.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.util;
13:
14: import java.beans.PropertyChangeEvent;
15: import java.beans.PropertyChangeListener;
16: import java.beans.PropertyChangeListener;
17: import junit.framework.TestCase;
18:
19: /**
20: *
21: * @author thomas
22: */
23: public class WbPropertiesTest extends TestCase implements
24: PropertyChangeListener {
25: private String changedProperty = null;
26:
27: public WbPropertiesTest(String testName) {
28: super (testName);
29: }
30:
31: public void testChangeNotification() {
32: WbProperties props = new WbProperties();
33: props.setProperty("test.property", "bla");
34: props.setProperty("test2.property", "two");
35: props.addPropertyChangeListener(this , "test.property",
36: "test2.property");
37: changedProperty = null;
38: props.setProperty("test.property", "blub");
39: assertEquals("test.property", changedProperty);
40:
41: changedProperty = null;
42: props.setProperty("test2.property", "nothing");
43: assertEquals("test2.property", changedProperty);
44: }
45:
46: public void propertyChange(PropertyChangeEvent evt) {
47: changedProperty = evt.getPropertyName();
48: }
49: }
|