import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.DirectColorModel;
import java.util.Hashtable;

/**
 * The following test program demonstrights that a BufferedImage will
 * start returning bogus objects from getProperty if it is given any
 * property in it's constructor.
 *
 * The behaviour should at least be consistent in both cases below.
 *
 * You should be able to build and run the test with the following:
 * 
 * % javac BIProp.java 
 * % java  BIProp
 */
public class BIProp {
    public static void main(String [] args) {
        ColorModel cm = new DirectColorModel(32, 0x00FF0000, 0x0000FF00, 
                                             0x000000FF, 0xFF000000);
        // Construct BufferedImage with no properties
        BufferedImage bi1 = new BufferedImage
            (cm, cm.createCompatibleWritableRaster(100, 100),
             cm.isAlphaPremultiplied(), null);

        // Construct BufferedImage with one property
        Hashtable ht = new Hashtable();
        ht.put("XXX YYY", "hello World");
        BufferedImage bi2 = new BufferedImage
            (cm, cm.createCompatibleWritableRaster(100, 100),
             cm.isAlphaPremultiplied(), ht);

        // We what happens when we ask for properties that don't exist
        // in the BufferedImage.
        System.out.println("Get 'foo': " + bi1.getProperty("foo") + " " +
                           bi2.getProperty("foo"));
        System.out.println("Get 'bar': " + bi1.getProperty("bar") + " " +
                           bi2.getProperty("bar"));
        System.out.println("Get 'baz': " + bi1.getProperty("baz") + " " +
                           bi2.getProperty("baz"));
    }
}

