changeset 1233:c3aaa11e4eb6

6821495: test/java/awt/print/PrinterJob/PrtException.java fails Reviewed-by: igor, prr
author jgodinez
date Mon, 20 Apr 2009 12:31:36 -0700
parents d609ae2faac2
children 53ca5822bdfe
files test/java/awt/PrintJob/EdgeTest/EdgeTest.java test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java test/java/awt/print/PrinterJob/Collate2DPrintingTest.java test/java/awt/print/PrinterJob/PrtException.java test/javax/print/CheckDupFlavor.java test/javax/print/LookupServices.java test/javax/print/TestRaceCond.java test/javax/print/attribute/Chroma.java test/javax/print/attribute/ChromaticityValues.java test/javax/print/attribute/GetCopiesSupported.java test/javax/print/attribute/PSCopiesFlavorTest.java test/javax/print/attribute/SidesPageRangesTest.java test/javax/print/attribute/SupportedPrintableAreas.java test/javax/print/attribute/autosense/PrintAutoSenseData.java
diffstat 14 files changed, 1007 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/awt/PrintJob/EdgeTest/EdgeTest.java	Wed Apr 15 08:47:21 2009 -0700
+++ b/test/java/awt/PrintJob/EdgeTest/EdgeTest.java	Mon Apr 20 12:31:36 2009 -0700
@@ -27,6 +27,7 @@
  * @summary Verifies that (0, 0) is the upper-left corner of the page, not
  *          the upper-left corner adjusted for the margins.
  * @author dpm
+ * @run main/manual EdgeTest
  */
 
 import java.awt.*;
@@ -43,7 +44,9 @@
                                 }
                             );
         f.setVisible(true);
-        PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", null);
+        JobAttributes job = new JobAttributes();
+        job.setDialog(JobAttributes.DialogType.NONE);
+        PrintJob pj = getToolkit().getPrintJob(f, "EdgeTest", job, null);
         if (pj != null) {
             Graphics g = pj.getGraphics();
             Dimension d = pj.getPageDimension();
--- a/test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java	Wed Apr 15 08:47:21 2009 -0700
+++ b/test/java/awt/PrintJob/MultipleEnd/MultipleEnd.java	Mon Apr 20 12:31:36 2009 -0700
@@ -44,7 +44,10 @@
     public MultipleEndFrame() {
         super("MultipleEnd");
         setVisible(true);
-        PrintJob pj  = getToolkit().getPrintJob(this, "MuiltipleEnd", null);
+
+        JobAttributes job = new JobAttributes();
+        job.setDialog(JobAttributes.DialogType.NONE);
+        PrintJob pj  = getToolkit().getPrintJob(this, "MultipleEnd", job, null);
         if (pj != null) {
             pj.end();
             pj.end();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/Collate2DPrintingTest.java	Mon Apr 20 12:31:36 2009 -0700
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/**
+ * @test
+ * @bug 6362683
+ * @summary Collation should work.
+ * @run main/manual Collate2DPrintingTest
+ */
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+import javax.print.attribute.standard.*;
+import javax.print.attribute.*;
+import javax.print.*;
+import java.io.*;
+
+public class Collate2DPrintingTest
+    extends Frame implements Doc, Printable, ActionListener {
+
+        Button print2D = new Button("2D Print");
+        Button printMerlin = new Button("PrintService");
+        PrinterJob pj = PrinterJob.getPrinterJob();
+        PrintService defService = null;
+        HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
+
+    public Collate2DPrintingTest() {
+
+        Panel butPanel = new Panel();
+        butPanel.add(print2D);
+        butPanel.add(printMerlin);
+        print2D.addActionListener(this);
+        printMerlin.addActionListener(this);
+        addWindowListener (new WindowAdapter() {
+            public void windowClosing (WindowEvent e) {
+                dispose();
+            }
+        });
+        add("South", butPanel);
+
+        defService = PrintServiceLookup.lookupDefaultPrintService();
+        PrintService[] pservice;
+        if (defService == null) {
+            pservice = PrintServiceLookup.lookupPrintServices(null, null);
+            if (pservice.length == 0) {
+                throw new RuntimeException("No printer found.  TEST ABORTED");
+            }
+            defService = pservice[0];
+        }
+        prSet.add(SheetCollate.COLLATED);
+        prSet.add(new Copies(2));
+        pj.setPrintable(Collate2DPrintingTest.this);
+        setSize(300, 200);
+        setVisible(true);
+    }
+
+
+    public int print(Graphics g, PageFormat pf, int pageIndex)
+          throws PrinterException {
+        g.drawString("Page: " + pageIndex, 100, 100);
+        if (pageIndex == 2) {
+            return Printable.NO_SUCH_PAGE;
+        } else {
+            return Printable.PAGE_EXISTS;
+        }
+    }
+
+    public void actionPerformed (ActionEvent ae) {
+        try {
+            if (ae.getSource() == print2D) {
+                if (pj.printDialog(prSet)) {
+                    pj.print(prSet);
+                }
+            } else {
+                DocPrintJob pj = defService.createPrintJob();
+                pj.print(this, prSet);
+            }
+            System.out.println ("DONE");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    public DocAttributeSet getAttributes() {
+        return null;
+    }
+
+    public DocFlavor getDocFlavor() {
+        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
+        return flavor;
+    }
+
+    public Object getPrintData() {
+        return this;
+    }
+
+    public Reader getReaderForText() {
+        return null;
+    }
+
+    public InputStream getStreamForBytes() {
+        return null;
+    }
+
+  public static void main( String[] args) {
+
+  String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "The print result should be collated."
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+     new Collate2DPrintingTest();
+  }
+}
+
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.setVisible(true);
+      println( "Any messages for the tester will display here." );
+    }
+
+   public static void createDialog( )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      String[] defInstr = { "Instructions will appear here. ", "" } ;
+      dialog.printInstructions( defInstr );
+      dialog.setVisible(true);
+      println( "Any messages for the tester will display here." );
+    }
+
+
+   public static void printInstructions( String[] instructions )
+    {
+      dialog.printInstructions( instructions );
+    }
+
+
+   public static void println( String messageIn )
+    {
+      dialog.displayMessage( messageIn );
+    }
+
+}// Sysout  class
+
+/**
+  This is part of the standard test machinery.  It provides a place for the
+   test instructions to be displayed, and a place for interactive messages
+   to the user to be displayed.
+  To have the test instructions displayed, see Sysout.
+  To have a message to the user be displayed, see Sysout.
+  Do not call anything in this dialog directly.
+  */
+class TestDialog extends Dialog {
+
+   TextArea instructionsText;
+   TextArea messageText;
+   int maxStringLength = 80;
+
+   //DO NOT call this directly, go through Sysout
+   public TestDialog( Frame frame, String name )
+    {
+      super( frame, name );
+      int scrollBoth = TextArea.SCROLLBARS_BOTH;
+      instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
+      add( "North", instructionsText );
+
+      messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
+      add("Center", messageText);
+
+      pack();
+
+      setVisible(true);
+    }// TestDialog()
+
+   //DO NOT call this directly, go through Sysout
+   public void printInstructions( String[] instructions )
+    {
+      //Clear out any current instructions
+      instructionsText.setText( "" );
+
+      //Go down array of instruction strings
+
+      String printStr, remainingStr;
+      for( int i=0; i < instructions.length; i++ )
+       {
+         //chop up each into pieces maxSringLength long
+         remainingStr = instructions[ i ];
+         while( remainingStr.length() > 0 )
+          {
+            //if longer than max then chop off first max chars to print
+            if( remainingStr.length() >= maxStringLength )
+             {
+               //Try to chop on a word boundary
+               int posOfSpace = remainingStr.
+                  lastIndexOf( ' ', maxStringLength - 1 );
+
+               if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
+
+               printStr = remainingStr.substring( 0, posOfSpace + 1 );
+               remainingStr = remainingStr.substring( posOfSpace + 1 );
+             }
+            //else just print
+            else
+             {
+               printStr = remainingStr;
+               remainingStr = "";
+             }
+
+            instructionsText.append( printStr + "\n" );
+
+          }// while
+
+       }// for
+
+    }//printInstructions()
+
+   //DO NOT call this directly, go through Sysout
+   public void displayMessage( String messageIn )
+    {
+      messageText.append( messageIn + "\n" );
+    }
+
+ }// TestDialog  class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/print/PrinterJob/PrtException.java	Mon Apr 20 12:31:36 2009 -0700
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+  @test
+  @bug 4429544
+  @summary This test should not throw a printer exception. Test has been modified to correspond with the behavior of 1.5 and above.
+  @run main PrtException
+*/
+
+import java.awt.*;
+import java.awt.print.*;
+import javax.print.*;
+
+public class PrtException implements Printable {
+    PrinterJob pj;
+
+    public PrtException() {
+
+        try{
+            PrintService[] svc;
+            PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
+            if (defService == null) {
+                svc = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
+                if (svc.length == 0) {
+                    throw new RuntimeException("Printer is required for this test.  TEST ABORTED");
+                }
+                defService = svc[0];
+            }
+
+            System.out.println("PrintService found : "+defService);
+            pj = PrinterJob.getPrinterJob();;
+            pj.setPrintService(defService);
+            //pj.setPrintable(this); // commenting this line should not result in PrinterException
+            pj.print();
+        } catch(PrinterException e ) {
+            e.printStackTrace();
+            throw new RuntimeException(" PrinterException should not be thrown. TEST FAILED");
+        }
+        System.out.println("TEST PASSED");
+    }
+
+
+    public int print(Graphics g,PageFormat pf,int pageIndex) {
+        Graphics2D g2= (Graphics2D)g;
+        if(pageIndex>=1){
+            return Printable.NO_SUCH_PAGE;
+        }
+        g2.translate(pf.getImageableX(), pf.getImageableY());
+        g2.setColor(Color.black);
+        g2.drawString("Hello world.", 10, 10);
+
+        return Printable.PAGE_EXISTS;
+    }
+
+    public static void main(String arg[]) {
+        PrtException sp = new PrtException();
+    }
+}
--- a/test/javax/print/CheckDupFlavor.java	Wed Apr 15 08:47:21 2009 -0700
+++ b/test/javax/print/CheckDupFlavor.java	Mon Apr 20 12:31:36 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2004-2009 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,17 +35,19 @@
 
 public class CheckDupFlavor {
     public static void main(String[] args){
-        PrintService pservice =
-                     PrintServiceLookup.lookupDefaultPrintService();
-
-        if (pservice == null) {
-                System.out.println("No default PrintService found. Test ABORTED.");
-            return;
+        PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
+        PrintService[] pservice;
+        if (defService == null) {
+            pservice = PrintServiceLookup.lookupPrintServices(null, null);
+            if (pservice.length == 0) {
+                throw new RuntimeException("No printer found.  TEST ABORTED");
+            }
+            defService = pservice[0];
         }
 
-        System.out.println("Default service = "+pservice);
+        System.out.println("PrintService = "+defService);
 
-        DocFlavor[] flavors = pservice.getSupportedDocFlavors();
+        DocFlavor[] flavors = defService.getSupportedDocFlavors();
         if (flavors==null) {
             System.out.println("No flavors supported. Test PASSED.");
             return;
@@ -54,13 +56,13 @@
 
         ArrayList flavorList = new ArrayList();
         for (int i=0; i<flavors.length; i++) {
-                if (flavors[i] == null) {
-                        throw new RuntimeException("Null flavor. Test FAILED.");
-                } else if (flavorList.contains(flavors[i])) {
-                        throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
-                } else {
-                        flavorList.add(flavors[i]);
-                }
+            if (flavors[i] == null) {
+                 throw new RuntimeException("Null flavor. Test FAILED.");
+            } else if (flavorList.contains(flavors[i])) {
+                 throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
+            } else {
+                flavorList.add(flavors[i]);
+            }
         }
         System.out.println("No duplicate found. Test PASSED.");
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/print/LookupServices.java	Mon Apr 20 12:31:36 2009 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4510477 6520186
+ * @summary No crash with HP OfficeJet 600 installed.
+ * @run main LookupServices
+*/
+
+import javax.print.attribute.*;
+import javax.print.*;
+
+public class LookupServices {
+    public static void main (String [] args) {
+
+        DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
+        HashPrintRequestAttributeSet prSet = null;
+
+        PrintService[] serv = PrintServiceLookup.lookupPrintServices(flavor, null);
+        System.out.println("default "+PrintServiceLookup.lookupDefaultPrintService());
+        if (serv.length==0) {
+            System.out.println("no PrintService supports GIF");
+            return;
+        }
+
+        System.out.println("Selected print service: "+ serv[0]);
+    }
+
+}
--- a/test/javax/print/TestRaceCond.java	Wed Apr 15 08:47:21 2009 -0700
+++ b/test/javax/print/TestRaceCond.java	Mon Apr 20 12:31:36 2009 -0700
@@ -43,6 +43,10 @@
         PrintService[] pservs = PrintServiceLookup.lookupPrintServices(null, null);
         PrintService pserv2 = PrintServiceLookup.lookupDefaultPrintService();
 
+        if ((pserv1 == null) || (pserv2==null)) {
+            return;
+        }
+
         if (pserv1.hashCode() != pserv2.hashCode()) {
             throw new RuntimeException("Different hashCodes for equal print "
                             + "services: " + pserv1.hashCode() + " "
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/print/attribute/Chroma.java	Mon Apr 20 12:31:36 2009 -0700
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test 1.3 01/05/11
+ * @bug 4456750
+ * @summary Test for supported chromaticity values with null DocFlavor.
+ *          No exception should be thrown.
+ * @run main Chroma
+*/
+
+// Chroma.java
+import java.io.*;
+
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class Chroma {
+
+   public static void main(String args[]) {
+
+      StreamPrintServiceFactory []fact =
+        StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
+              DocFlavor.SERVICE_FORMATTED.PRINTABLE,
+              DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType());
+
+      if (fact.length != 0) {
+          OutputStream out = new ByteArrayOutputStream();
+          StreamPrintService sps = fact[0].getPrintService(out);
+          checkChroma(sps);
+      }
+
+      PrintService defSvc = PrintServiceLookup.lookupDefaultPrintService();
+      if (defSvc != null) {
+           checkChroma(defSvc);
+      }
+
+   }
+
+    static void checkChroma(PrintService svc) {
+       if (svc.isAttributeCategorySupported(Chromaticity.class)) {
+            svc.getSupportedAttributeValues(Chromaticity.class,null,null);
+       }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/print/attribute/ChromaticityValues.java	Mon Apr 20 12:31:36 2009 -0700
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 4446106
+ * @summary Test for chromaticity values.
+ * @run main ChromaticityValues
+*/
+
+
+
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+import java.util.ArrayList;
+
+public class ChromaticityValues {
+
+    public static void main(String args[]) {
+        System.out.println("=======================================================================");
+        System.out.println("INSTRUCTIONS: This test is only for WINDOWS platform. ");
+        System.out.println("You should have a printer configured as your default printer in your system.");
+        System.out.println("=======================================================================");
+
+        String os=System.getProperty("os.name").toLowerCase();
+
+        if (!(os.indexOf("win")>=0)) {
+            System.out.println("Not a Windows System.  TEST ABORTED");
+            return;
+        }
+
+        PrintService pservice = PrintServiceLookup.lookupDefaultPrintService();
+        if (pservice == null) {
+            throw new RuntimeException("A printer is required for this test.");
+        }
+
+        System.out.println("Default Service is "+pservice);
+        ColorSupported psa = (ColorSupported)pservice.getAttribute(ColorSupported.class);
+        ArrayList cValues = new ArrayList();
+
+        if (pservice.isAttributeCategorySupported(Chromaticity.class)) {
+            Chromaticity[] values =(Chromaticity[])
+                (pservice.getSupportedAttributeValues(Chromaticity.class, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null));
+            if ((values != null) && (values.length > 0)) {
+                for (int i=0; i<values.length; i++) {
+                    cValues.add(values[i]);
+                }
+            } else {
+                System.out.println("Chromaticity value is unknown. TEST ABORTED");
+                return;
+            }
+
+        } else {
+            System.out.println("Chromaticity is not supported. TEST ABORTED");
+            return;
+
+        }
+
+        if (psa != null) {
+            if (psa.equals(ColorSupported.SUPPORTED)) {
+                if (cValues.size() < 2) {
+                    throw new RuntimeException("ColorSupported is supported, values for Chromaticity should be monochrome and color.");
+                }
+            } else {
+                if ((cValues.size() != 1) ||
+                    (!cValues.contains(Chromaticity.MONOCHROME))) {
+                    throw new RuntimeException("ColorSupported is not supported, values for Chromaticity should only be monochrome.");
+                }
+            }
+        } else { // ColorSupported unknown
+            if (!cValues.contains(Chromaticity.COLOR)) {
+                throw new RuntimeException("ColorSupported is unknown, values for Chromaticity should at least include color.");
+            }
+
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/print/attribute/GetCopiesSupported.java	Mon Apr 20 12:31:36 2009 -0700
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+  @test
+  @bug 4463280
+  @summary No ClassCastException should occur.
+  @run main GetCopiesSupported
+*/
+
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class GetCopiesSupported {
+
+    public static void main(String args[]) {
+        PrintService service = PrintServiceLookup.lookupDefaultPrintService();
+        PrintService[] pservice;
+        if (service == null) {
+             pservice = PrintServiceLookup.lookupPrintServices(null, null);
+            if (pservice.length == 0) {
+                    throw new RuntimeException("No printer found.  TEST ABORTED");
+            }
+            service = pservice[0];
+        }
+
+        if (service != null) {
+            CopiesSupported c = (CopiesSupported)
+               service.getSupportedAttributeValues(Copies.class,
+                                                   null, null);
+
+           System.out.println("CopiesSupported : "+c);
+        }
+    }
+
+
+}
--- a/test/javax/print/attribute/PSCopiesFlavorTest.java	Wed Apr 15 08:47:21 2009 -0700
+++ b/test/javax/print/attribute/PSCopiesFlavorTest.java	Mon Apr 20 12:31:36 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2007-2009 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,26 +37,26 @@
    public static void main(String args[]) {
 
        DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
-       PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
-       if (!(ps.isDocFlavorSupported(flavor))) {
-           System.out.println("unsupported flavor :" + flavor);
-           return;
+       PrintService[] ps = PrintServiceLookup.lookupPrintServices(flavor, null);
+       if (ps.length > 0) {
+           System.out.println("found PrintService: "+ps[0]);
+           Copies c = new Copies(1);
+           PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+           aset.add(c);
+           boolean suppVal = ps[0].isAttributeValueSupported(c, flavor, null);
+           AttributeSet us = ps[0].getUnsupportedAttributes(flavor, aset);
+           if (suppVal || us == null) {
+               throw new RuntimeException("Copies should be unsupported value");
+           }
+
+           Object value = ps[0].getSupportedAttributeValues(Copies.class,
+                                                            flavor, null);
+
+            //Copies Supported
+            if(value instanceof CopiesSupported) {
+                throw new RuntimeException("Copies should have no supported values.");
+            }
        }
-       Copies c = new Copies(1);
-       PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
-       aset.add(c);
-       boolean suppVal = ps.isAttributeValueSupported(c, flavor, null);
-       AttributeSet us = ps.getUnsupportedAttributes(flavor, aset);
-       if (suppVal || us == null) {
-           throw new RuntimeException("Copies should be unsupported value");
-       }
-
-       Object value = ps.getSupportedAttributeValues(Copies.class, flavor, null);
-
-        //Copies Supported
-        if(value instanceof CopiesSupported) {
-            throw new RuntimeException("Copies should have no supported values.");
-        }
 
    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/print/attribute/SidesPageRangesTest.java	Mon Apr 20 12:31:36 2009 -0700
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+/*
+ * @test
+ * @bug 4903366
+ * @summary No crash should occur.
+ * @run main SidesPageRangesTest
+*/
+import java.awt.*;
+import javax.print.*;
+import javax.print.attribute.standard.*;
+import javax.print.attribute.*;
+import java.io.*;
+import java.util.Locale;
+import java.net.URL;
+
+public class SidesPageRangesTest {
+        /**
+         * Constructor
+         */
+         public SidesPageRangesTest() {
+                super();
+        }
+        /**
+         * Starts the application.
+         */
+        public static void main(java.lang.String[] args) {
+                SidesPageRangesTest pd = new SidesPageRangesTest();
+                PrintService defService = null;
+                DocFlavor flavors[]  = null;
+                PrintService[] pservice;
+                defService = PrintServiceLookup.lookupDefaultPrintService();
+                if (defService == null) {
+                    pservice = PrintServiceLookup.lookupPrintServices(null, null);
+                    if (pservice.length == 0) {
+                        throw new RuntimeException("Printer is required for this test.  TEST ABORTED");
+                    }
+                    defService = pservice[0];
+                }
+                System.out.println("Default Print Service "+defService);
+
+
+                if (defService.isAttributeCategorySupported(PageRanges.class)) {
+                        System.out.println("\nPageRanges Attribute category is supported");
+                } else {
+                        System.out.println("\nPageRanges Attribute category is not supported. terminating...");
+                        System.exit(1);
+                }
+
+                flavors = defService.getSupportedDocFlavors();
+                System.out.println("\nGetting Supported values for PageRanges for each supported DocFlavor");
+                System.out.println("===============================================================\n");
+                for (int y = 0; y < flavors.length; y ++) {
+                    System.out.println("\n\n");
+
+                    System.out.println("Doc Flavor: "+flavors[y]);
+                    System.out.println("-----------------------------");
+
+                    Object vals = defService.getSupportedAttributeValues(PageRanges.class, flavors[y], null);
+                    if (vals == null) {
+                        System.out.println("No supported values for PageRanges for this doc flavor. ");
+                    }
+
+                    PageRanges[] pr = null;
+                    if (vals instanceof PageRanges[]) {
+                        pr = (PageRanges[]) vals;
+                        for (int x = 0; x < pr.length; x ++) {
+                            System.out.println("\nSupported Value "+pr[x]);
+                            System.out.println("is "+pr[x]+" value supported? "+defService.isAttributeValueSupported(pr[x], flavors[y], null));
+
+                            if (!defService.isAttributeValueSupported(pr[x], flavors[y], null)) {
+                                throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
+                            }
+                        }
+                    } else if (vals instanceof PageRanges) {
+                        System.out.println(vals);
+                        System.out.println("is "+vals+" value supported? "+defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null));
+                        if (!defService.isAttributeValueSupported((javax.print.attribute.Attribute)vals, flavors[y], null)) {
+                            throw new RuntimeException("PageRanges contradicts getSupportedAttributeValues");
+                        }
+                    }
+
+                    // SIDES test
+                    vals = defService.getSupportedAttributeValues(Sides.class, flavors[y], null);
+                    if (vals == null) {
+                        System.out.println("No supported values for Sides for this doc flavor. ");
+                    }
+
+                    Sides[] s = null;
+                    if (vals instanceof Sides[]) {
+                        s = (Sides[]) vals;
+                        for (int x = 0; x < s.length; x ++) {
+                            System.out.println("\nSupported Value "+s[x]);
+                            System.out.println("is "+s[x]+" value supported? "+defService.isAttributeValueSupported(s[x], flavors[y], null));
+                            if  (!defService.isAttributeValueSupported(s[x], flavors[y], null)) {
+                                throw new RuntimeException("Sides contradicts getSupportedAttributeValues");
+                            }
+                        }
+                    }
+                }
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/print/attribute/SupportedPrintableAreas.java	Mon Apr 20 12:31:36 2009 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4762773 6289206 6324049 6362765
+ * @summary Tests that get non-null return list of printable areas.
+ * @run main SupportedPrintableAreas
+ */
+
+
+import javax.print.*;
+import javax.print.event.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class SupportedPrintableAreas {
+
+  public static void main(String[] args) {
+     PrintService[] svc;
+     PrintService printer = PrintServiceLookup.lookupDefaultPrintService();
+     if (printer == null) {
+         svc = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
+         if (svc.length == 0) {
+             throw new RuntimeException("Printer is required for this test.  TEST ABORTED");
+         }
+         printer = svc[0];
+     }
+     System.out.println("PrintService found : "+printer);
+
+     if (!printer.isAttributeCategorySupported(MediaPrintableArea.class)) {
+         return;
+     }
+     Object value = printer.getSupportedAttributeValues(
+                    MediaPrintableArea.class, null, null);
+     if (!value.getClass().isArray()) {
+         throw new RuntimeException("unexpected value");
+      }
+
+     PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+     value = printer.getSupportedAttributeValues(
+                    MediaPrintableArea.class, null, aset);
+     if (!value.getClass().isArray()) {
+         throw new RuntimeException("unexpected value");
+      }
+
+     Media media = (Media)printer.getDefaultAttributeValue(Media.class);
+     aset.add(media);
+     value = printer.getSupportedAttributeValues(
+                    MediaPrintableArea.class, null, aset);
+     if (!value.getClass().isArray()) {
+         throw new RuntimeException("unexpected value");
+     }
+
+     // test for 6289206
+     aset.add(MediaTray.MANUAL);
+     value = printer.getSupportedAttributeValues(
+                    MediaPrintableArea.class, null, aset);
+     if ((value != null) && !value.getClass().isArray()) {
+         throw new RuntimeException("unexpected value");
+     }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/print/attribute/autosense/PrintAutoSenseData.java	Mon Apr 20 12:31:36 2009 -0700
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 4468109
+ * @summary Test for printing AUTOSENSE DocFlavor.  No exception should be thrown.
+ * @run main PrintAutoSenseData
+*/
+
+import java.io.*;
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+import java.net.URL;
+
+public class PrintAutoSenseData
+{
+  private DocFlavor flavor = DocFlavor.URL.AUTOSENSE; //represents the docflavor.
+  private PrintService[] service = PrintServiceLookup.lookupPrintServices(flavor, null);
+
+
+  public PrintAutoSenseData()
+  {
+     if (service.length == 0)
+     {
+        System.out.println("No print service available...");
+        return;
+     }
+
+     System.out.println("selected PrintService: " + this.service[0]);
+     if (service[0].isDocFlavorSupported(flavor)) {
+         System.out.println("DocFlavor.URL.AUTOSENSE supported");
+     } else {
+         System.out.println("DocFlavor.URL.AUTOSENSE not supported. Testing aborted !!");
+         return;
+     }
+
+     DocPrintJob job = service[0].createPrintJob();
+     this.print();
+  }
+
+  // The print method prints sample file with DocFlavor.URL.AUTOSENSE.
+  void print()
+  {
+         String fileName = "./sample.txt";
+         DocPrintJob job = service[0].createPrintJob();
+
+         // The representation class is a URL.
+         System.out.println("printing " + fileName + " using doc flavor: " + this.flavor);
+         System.out.println("Rep. class name: " + this.flavor.getRepresentationClassName() + " MimeType: " + this.flavor.getMimeType());
+
+         Doc doc = new URLDoc(fileName, this.flavor);
+         HashPrintRequestAttributeSet prSet =
+             new HashPrintRequestAttributeSet();
+         prSet.add(new Destination(new File("./dest.prn").toURI()));
+         //print the document.
+         try {
+            job.print(doc, prSet);
+         } catch ( Exception e ) {
+            e.printStackTrace();
+         }
+  }
+
+  public static void main(String[] args) {
+     new PrintAutoSenseData();
+  }
+
+}
+
+/* This class is for reading autosense data with URL representation class */
+
+class URLDoc implements Doc
+{
+   protected String fileName = null;
+   protected DocFlavor flavor = null;
+   protected Object printData = null;
+   protected InputStream instream = null;
+
+   public URLDoc(String filename, DocFlavor docFlavor)
+   {
+      this.fileName = filename;
+      this.flavor = docFlavor;
+   }
+
+   public DocFlavor getDocFlavor() {
+       return DocFlavor.URL.AUTOSENSE;
+   }
+
+   public DocAttributeSet getAttributes()
+   {
+       HashDocAttributeSet hset = new HashDocAttributeSet();
+       return hset;
+   }
+
+   public Object getPrintData()
+   {
+     if ( this.printData == null )
+     {
+        this.printData = URLDoc.class.getResource(this.fileName);
+        System.out.println("getPrintData(): " + this.printData);
+     }
+     return this.printData;
+   }
+
+   public Reader getReaderForText()
+   {
+     return null;
+   }
+
+   public InputStream getStreamForBytes()
+   {
+     System.out.println("getStreamForBytes(): " + this.printData);
+     try
+     {
+        if ( (this.printData != null) && (this.printData instanceof URL) )
+        {
+           this.instream = ((URL)this.printData).openStream();
+        }
+        if (this.instream == null)
+        {
+           URL url = URLDoc.class.getResource(this.fileName);
+           this.instream = url.openStream();
+        }
+      }
+      catch ( IOException ie )
+      {
+         System.out.println("URLDoc: exception: " + ie.toString());
+      }
+      return this.instream;
+   }
+}