diff options
author | aclement <aclement> | 2005-10-05 12:49:53 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-10-05 12:49:53 +0000 |
commit | 8d098f969f5ef67fb15b2b56f44bdd21f7929bc6 (patch) | |
tree | 07ba83989de8292887b13e3466d5fe544d2a92db /tests/multiIncremental/PR85132/inc1 | |
parent | 12e6334bf5f77d7c3bc2e66eeefa105f0507334a (diff) | |
download | aspectj-8d098f969f5ef67fb15b2b56f44bdd21f7929bc6.tar.gz aspectj-8d098f969f5ef67fb15b2b56f44bdd21f7929bc6.zip |
testcase for pr85132
Diffstat (limited to 'tests/multiIncremental/PR85132/inc1')
-rw-r--r-- | tests/multiIncremental/PR85132/inc1/bean/Demo.java | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/multiIncremental/PR85132/inc1/bean/Demo.java b/tests/multiIncremental/PR85132/inc1/bean/Demo.java new file mode 100644 index 000000000..a4ef0472c --- /dev/null +++ b/tests/multiIncremental/PR85132/inc1/bean/Demo.java @@ -0,0 +1,81 @@ +/* +Copyright (c) Xerox Corporation 1998-2002. All rights reserved. + + +Use and copying of this software and preparation of derivative works based +upon this software are permitted. Any distribution of this software or +derivative works must comply with all applicable United States export control +laws. +*/ + +package bean; + +import java.beans.*; +import java.io.*; + +public class Demo implements PropertyChangeListener { + + static final String fileName = "test.tmp"; + + /** + * when Demo is playing the listener role, + * this method reports that a propery has changed + */ + public void propertyChange(PropertyChangeEvent e){ + System.out.println("Property " + e.getPropertyName() + " changed from " + + e.getOldValue() + " to " + e.getNewValue() ); + } + + /** + * main: test the program + */ + public static void main(String[] args){ + Point p1 = new Point(); + p1.addPropertyChangeListener(new Demo()); + System.out.println("p1 =" + p1); + p1.setRectangular(5,2); + System.out.println("p1 =" + p1); + p1.setX( 6 ); + p1.setY( 3 ); + System.out.println("p1 =" + p1); + p1.offset(6,4); + System.out.println("p1 =" + p1); + save(p1, fileName); + Point p2 = (Point) restore(fileName); + System.out.println("Had: " + p1); + System.out.println("Got: " + p2); + } + + /** + * Save a serializable object to a file + */ + static void save(Serializable p, String fn){ + try { + System.out.println("Writing to file: " + p); + FileOutputStream fo = new FileOutputStream(fn); + ObjectOutputStream so = new ObjectOutputStream(fo); + so.writeObject(p); + so.flush(); + } catch (Exception e) { + System.out.println(e); + System.exit(1); + } + } + + /** + * Restore a serializable object from the file + */ + static Object restore(String fn){ + try { + Object result; + System.out.println("Reading from file: " + fn); + FileInputStream fi = new FileInputStream(fn); + ObjectInputStream si = new ObjectInputStream(fi); + return si.readObject(); + } catch (Exception e) { + System.out.println(e); + System.exit(1); + } + return null; + } +} |