changeset 2043:b428c8f80209

6915906: tests in closed/javax/print/ should not be calling System.exit() Reviewed-by: igor, prr
author jgodinez
date Fri, 15 Jan 2010 09:06:57 -0800
parents 756ab2266ffb
children 049cfaaa9a73 64f7b789aecc
files test/ProblemList.txt test/javax/print/DialogMargins.java test/javax/print/StreamPrintingOrientation.java test/javax/print/attribute/AttributeTest.java test/javax/print/attribute/ServiceDialogTest.java test/javax/print/attribute/SidesPageRangesTest.java
diffstat 6 files changed, 743 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test/ProblemList.txt	Thu Jan 14 15:48:36 2010 -0800
+++ b/test/ProblemList.txt	Fri Jan 15 09:06:57 2010 -0800
@@ -571,6 +571,7 @@
 javax/print/attribute/GetCopiesSupported.java			generic-all
 javax/print/attribute/SidesPageRangesTest.java			generic-all
 javax/print/attribute/SupportedPrintableAreas.java		generic-all
+javax/print/attribute/AttributeTest.java                        generic-all
 
 # Only print test left, excluding just because all print tests have been
 javax/print/attribute/MediaMappingsTest.java 			generic-all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/print/DialogMargins.java	Fri Jan 15 09:06:57 2010 -0800
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2001-2010 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * 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 4485755 6361370 6448717 5080051
+ * @summary dialog doesn't have way to specify margins
+ *          for 6361370, verify exception for offline printer in Windows
+ *          for 6448717, faster display of print dialog
+ *          for 6500903, verify status of printer if accepting jobs or not
+ * @author prr
+ * @run main/manual DialogMargins
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.print.*;
+import javax.print.*;
+import javax.print.attribute.*;
+import javax.print.attribute.standard.*;
+
+public class DialogMargins extends Frame {
+
+  public DialogMargins() {
+     super("Dialog Margins Test");
+
+    Button printButton = new Button ("Print ...");
+    add("Center", printButton);
+    printButton.addActionListener(new ActionListener() {
+                public void actionPerformed (ActionEvent e) {
+                     new MarginsPrinter();
+                }
+    });
+
+    addWindowListener (new WindowAdapter() {
+         public void windowClosing (WindowEvent e) {
+            dispose();
+         }
+
+     });
+
+     pack();
+     setVisible (true);
+  }
+
+class MarginsPrinter implements Printable {
+
+  PrinterJob myPrinterJob;
+  PageFormat myPageFormat;
+
+  public MarginsPrinter() {
+      PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+      //aset.add(MediaSizeName.ISO_A4);
+      //aset.add(new MediaPrintableArea(0f,0f,210f,297f,MediaPrintableArea.MM));
+      myPrinterJob = PrinterJob.getPrinterJob();
+      myPageFormat = myPrinterJob.pageDialog(aset);
+      myPrinterJob.setPrintable(this, myPageFormat);
+      //myPrinterJob.setPrintable(this);
+      if (myPrinterJob.printDialog(aset)) {
+          try {
+             //PrintRequestAttributeSet newaset =
+                   //new HashPrintRequestAttributeSet();
+              myPrinterJob.print(aset);
+
+          } catch (PrinterException pe ) {
+              System.out.println("DialogMargins Exception caught:" + pe);
+          }
+      }
+   }
+
+  public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) {
+
+     if (pageIndex > 0) {
+        return Printable.NO_SUCH_PAGE;
+     }
+
+     Graphics2D g2d = (Graphics2D)graphics;
+     g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
+     g2d.drawString("ORIGIN("+pageFormat.getImageableX()+","+
+                             pageFormat.getImageableY()+")", 20, 20);
+     g2d.drawString("X THIS WAY", 200, 50);
+     g2d.drawString("Y THIS WAY", 60 , 200);
+     g2d.drawString("Graphics is " + g2d.getClass().getName(), 100, 100);
+     g2d.drawRect(0,0,(int)pageFormat.getImageableWidth(),
+                      (int)pageFormat.getImageableHeight());
+     g2d.setColor(Color.black);
+     g2d.drawRect(1,1,(int)pageFormat.getImageableWidth()-2,
+                      (int)pageFormat.getImageableHeight()-2);
+
+     return  Printable.PAGE_EXISTS;
+  }
+
+}
+  public static void main( String[] args) {
+
+  String[] instructions =
+        {
+         "You must have a printer available to perform this test",
+         "Specify various pageformats and compare the printed results with the",
+         "request."
+       };
+      Sysout.createDialog( );
+      Sysout.printInstructions( instructions );
+
+     new DialogMargins();
+  }
+}
+
+
+class Sysout {
+   private static TestDialog dialog;
+
+   public static void createDialogWithInstructions( String[] instructions )
+    {
+      dialog = new TestDialog( new Frame(), "Instructions" );
+      dialog.printInstructions( instructions );
+      dialog.show();
+      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.show();
+      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();
+
+      show();
+    }// 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/javax/print/StreamPrintingOrientation.java	Fri Jan 15 09:06:57 2010 -0800
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2003-2010 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * 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 4904236
+ * @summary You would see a cross-platform print dialog being popped up. Check whether orientation is shown as LANDSCAPE. Click 'OK'. 'streamexample.ps' will be created in the same dir where this application was executed. Pass if the orientation in the ps file is landscape.
+ * @run main/manual StreamPrintingOrientation
+ */
+
+import java.awt.*;
+import java.awt.print.*;
+import javax.print.*;
+import javax.print.attribute.standard.*;
+import javax.print.attribute.*;
+import java.io.FileOutputStream;
+import java.io.File;
+import java.util.Locale;
+
+class StreamPrintingOrientation implements Printable {
+        /**
+         * Constructor
+         */
+         public StreamPrintingOrientation() {
+                super();
+        }
+        /**
+         * Starts the application.
+         */
+        public static void main(java.lang.String[] args) {
+                StreamPrintingOrientation pd = new StreamPrintingOrientation();
+                PrinterJob pj = PrinterJob.getPrinterJob();
+                HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
+                PrintService service = null;
+
+                FileOutputStream fos = null;
+                File f = null, f1 = null;
+                String mType = "application/postscript";
+
+                try {
+                        f = new File("streamexample.ps");
+                        fos = new FileOutputStream(f);
+                        StreamPrintServiceFactory[] factories = PrinterJob.lookupStreamPrintServices(mType);
+                        if (factories.length > 0)
+                                service = factories[0].getPrintService(fos);
+
+                        if (service != null) {
+                                System.out.println("Stream Print Service "+service);
+                                pj.setPrintService(service);
+                        } else {
+                                throw new RuntimeException("No stream Print Service available.");
+                        }
+                } catch (Exception e) {
+                        e.printStackTrace();
+                }
+
+                pj.setPrintable(pd);
+                prSet.add(OrientationRequested.LANDSCAPE);
+                prSet.add(new Copies(3));
+                prSet.add(new JobName("orientation test", null));
+                System.out.println("open PrintDialog..");
+                if (pj.printDialog(prSet)) {
+                        try {
+                                System.out.println("\nValues in attr set passed to print method");
+                                Attribute attr[] = prSet.toArray();
+                                for (int x = 0; x < attr.length; x ++) {
+                                        System.out.println("Name "+attr[x].getName()+"  "+attr[x]);
+                                }
+                                System.out.println("About to print the data ...");
+                                if (service != null) {
+                                        System.out.println("TEST: calling Print");
+                                        pj.print(prSet);
+                                        System.out.println("TEST: Printed");
+                                }
+                        }
+                        catch (PrinterException pe) {
+                                pe.printStackTrace();
+                        }
+                }
+
+        }
+
+        //printable interface
+        public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {
+
+                if (pi > 0) {
+                        return Printable.NO_SUCH_PAGE;
+                }
+                // Simply draw two rectangles
+                Graphics2D g2 = (Graphics2D)g;
+                g2.setColor(Color.black);
+                g2.translate(pf.getImageableX(), pf.getImageableY());
+                System.out.println("StreamPrinting Test Width "+pf.getWidth()+" Height "+pf.getHeight());
+                g2.drawRect(1,1,200,300);
+                g2.drawRect(1,1,25,25);
+                return Printable.PAGE_EXISTS;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/print/attribute/AttributeTest.java	Fri Jan 15 09:06:57 2010 -0800
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006-2010 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 6387255
+ * @summary  Tests conflict of Media values returned by isAttrValueSupported and getSupportedAttrValues.  No runtime exception should be thrown.
+ * @run main AttributeTest
+ */
+import javax.print.*;
+import javax.print.attribute.standard.*;
+import javax.print.attribute.*;
+
+public class AttributeTest {
+
+        public AttributeTest() {
+
+                PrintService service[] = PrintServiceLookup.lookupPrintServices(null, null);
+
+                if (service.length == 0) {
+                        throw new RuntimeException("No printer found.  TEST ABORTED");
+                }
+
+                for (int x = 0; x < service.length; x ++) {
+                        DocFlavor flavors[] = service[x].getSupportedDocFlavors();
+
+                        for (int y = 0; y < flavors.length; y ++) {
+                                Object attrVal = service[x].getSupportedAttributeValues(Media.class, flavors[y], null);
+                                if (attrVal == null) {
+                                        continue;
+                                }
+                                Media attr[] = (Media[]) attrVal;
+                                for (int z = 0; z < attr.length; z ++) {
+                                        if (!service[x].isAttributeValueSupported(attr[z], flavors[y], null)) {
+                                                throw new RuntimeException("ERROR: There is a conflict between getSupportedAttrValues " +
+                                                " and isAttributeValueSupported, for the attribute: " + attr[z] +
+                                                ", where the flavor is: " + flavors[y] + " and the print service is: " +
+                                                service[x] + "\n");
+                                        }
+                                }
+                        }
+                }
+
+                System.out.println("Test Passed");
+        }
+
+        public static void main (String args[]) {
+                AttributeTest test = new AttributeTest();
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/print/attribute/ServiceDialogTest.java	Fri Jan 15 09:06:57 2010 -0800
@@ -0,0 +1,307 @@
+/*
+ * 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
+ * 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 4910388 4871089 4998624
+ * @summary Confirm that
+ *      1. After choosing Reverse Landscape in the system default print
+ *       Print Service (2nd in the list), it
+ *          will reset to portrait in "Test Printer"
+ *      2. Print To File button is not cleared when switching between the
+ *         2nd service (system default printer) and Test Printer.
+ *      3. Make sure "Postscript" printer is the default and make sure the
+ *         "print to file" button is disabled.  File Dialog should not be
+ *         shown after pressing print button.
+ *
+ * @run main/manual ServiceDialogTest
+ */
+import java.awt.*;
+import javax.print.*;
+import javax.print.attribute.standard.*;
+import javax.print.attribute.*;
+import javax.print.event.*;
+import java.io.*;
+import java.util.Locale;
+
+public class ServiceDialogTest {
+        /**
+         * Constructor
+         */
+         public ServiceDialogTest() {
+                super();
+        }
+        /**
+         * Starts the application.
+         */
+        public static void main(java.lang.String[] args) {
+                ServiceDialogTest pd = new ServiceDialogTest();
+                PrintService services[] = new PrintService[3];
+                services[1] = PrintServiceLookup.lookupDefaultPrintService();
+
+                FileOutputStream fos = null;
+                File f = null;
+                String mType = "application/postscript";
+                DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;
+                try {
+                        f = new File("streamexample.ps");
+                        fos = new FileOutputStream(f);
+                        StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mType);
+                        if (factories.length > 0) {
+                                services[0] = factories[0].getPrintService(fos);
+                        } else {
+                                throw new RuntimeException("No StreamPrintService available which would support "+flavor");
+                        }
+
+                        services[2] = new TestPrintService("Test Printer");
+
+            //System.out.println("is "+flavor+" supported? "+services[0].isDocFlavorSupported(flavor));
+            //System.out.println("is Orientation supported? "+services[0].isAttributeCategorySupported(OrientationRequested.class));
+            //System.out.println("is REVERSE PORTRAIT supported ? "+services[0].isAttributeValueSupported(OrientationRequested.REVERSE_PORTRAIT, flavor, null));
+
+            HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
+            prSet.add(new Destination(new File("./dest.prn").toURI()));
+            PrintService selService = ServiceUI.printDialog(null, 200, 200, services, services[0], flavor, prSet);
+                        Attribute attr[] = prSet.toArray();
+                        for (int x = 0; x < attr.length; x ++) {
+                                System.out.println(attr[x]);
+                        }
+
+                        //DocPrintJob pj = service.createPrintJob();
+                        //PrintDocument prDoc = new PrintDocument();
+                        //pj.print(prDoc, null);
+
+                } catch (Exception e) {
+                        e.printStackTrace();
+                }
+        }
+}
+
+
+class TestPrintService implements PrintService
+{
+
+    private static DocFlavor textByteFlavor = null;
+    private static final DocFlavor supportedDocFlavors[] = (new DocFlavor[] {
+             javax.print.DocFlavor.INPUT_STREAM.JPEG
+    });
+
+    private static final Class serviceAttrCats[] = (new Class[] {
+             javax.print.attribute.standard.PrinterName.class
+    });
+
+    private static final Class otherAttrCats[] = (new Class [] {
+             javax.print.attribute.standard.Copies.class,
+             javax.print.attribute.standard.OrientationRequested.class,
+             javax.print.attribute.standard.Destination.class,
+    });
+
+    private String printer = null;
+
+    public TestPrintService() {
+    }
+
+    public TestPrintService(String printerName) {
+        if (printerName == null) {
+            throw new IllegalArgumentException("null printer name");
+        } else {
+            printer = printerName;
+        }
+    }
+
+    public String getName()
+    {
+        return printer;
+    }
+
+
+    public DocPrintJob createPrintJob()
+    {
+        return  null;
+    }
+
+    public PrintServiceAttributeSet getUpdatedAttributes()
+    {
+        return null;
+    }
+
+
+    public void addPrintServiceAttributeListener(PrintServiceAttributeListener printserviceattributelistener)
+    {
+    }
+
+    public void removePrintServiceAttributeListener(PrintServiceAttributeListener printserviceattributelistener)
+    {
+    }
+
+    public PrintServiceAttribute getAttribute(Class category)
+    {
+        return null;
+    }
+
+    public PrintServiceAttributeSet getAttributes()
+    {
+        HashPrintServiceAttributeSet aSet = new HashPrintServiceAttributeSet();
+            return aSet;
+    }
+
+    public DocFlavor[] getSupportedDocFlavors()
+    {
+        int i = supportedDocFlavors.length;
+        DocFlavor adocflavor[] = new DocFlavor[i];
+        System.arraycopy(supportedDocFlavors, 0, adocflavor, 0, i);
+        return adocflavor;
+    }
+
+    public boolean isDocFlavorSupported(DocFlavor docflavor)
+    {
+        for (int i = 0; i < supportedDocFlavors.length; i++) {
+            if (docflavor.equals(supportedDocFlavors[i])) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public Class[] getSupportedAttributeCategories()
+    {
+        int i = otherAttrCats.length;
+        Class aclass[] = new Class[i];
+        System.arraycopy(otherAttrCats, 0, aclass, 0, otherAttrCats.length);
+        return aclass;
+    }
+
+    public boolean isAttributeCategorySupported(Class category)
+    {
+        if (category == null) {
+            throw new NullPointerException("null category");
+        }
+
+        for (int i = 0; i < otherAttrCats.length; i++) {
+            if (category == otherAttrCats[i]) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public boolean isAttributeValueSupported(Attribute attrval, DocFlavor flavor, AttributeSet attributes) {
+
+        if (attrval == OrientationRequested.PORTRAIT)
+                return true;
+        else if (attrval == OrientationRequested.LANDSCAPE)
+                return true;
+                else
+                        return false;
+    }
+
+    public Object getDefaultAttributeValue(Class category)
+    {
+        if (category == null) {
+            throw new NullPointerException("null category");
+        }
+        if (category == javax.print.attribute.standard.Copies.class)
+                return new Copies(1);
+
+        if (category == javax.print.attribute.standard.OrientationRequested.class)
+                return OrientationRequested.PORTRAIT;
+
+        return null;
+    }
+
+    public Object getSupportedAttributeValues(Class category, DocFlavor docflavor, AttributeSet attributeset)
+    {
+        if (category == null) {
+            throw new NullPointerException("null category");
+        }
+
+        if (docflavor != null) {
+            if (!isDocFlavorSupported(docflavor)) {
+                throw new IllegalArgumentException(docflavor + " is an unsupported flavor");
+            }
+        }
+        if (!isAttributeCategorySupported(category)) {
+            return null;
+        }
+        if (category == javax.print.attribute.standard.Copies.class ) {
+               return new CopiesSupported(1, 5);
+        }
+        if (category == javax.print.attribute.standard.OrientationRequested.class ) {
+               OrientationRequested req[] = { OrientationRequested.PORTRAIT, OrientationRequested.LANDSCAPE };
+               return req;
+        }
+
+        return null;
+    }
+
+    public AttributeSet getUnsupportedAttributes(DocFlavor docflavor, AttributeSet attributeset) {
+
+        if (docflavor != null && !isDocFlavorSupported(docflavor)) {
+            throw new IllegalArgumentException("flavor " + docflavor + "is not supported");
+        }
+        if (attributeset == null) {
+            return null;
+        }
+
+        HashAttributeSet hashattributeset = new HashAttributeSet();
+        Attribute attributearray[] = attributeset.toArray();
+        for (int i = 0; i < attributearray.length; i++) {
+            try {
+                Attribute attribute = attributearray[i];
+                if (!isAttributeCategorySupported(attribute.getCategory())) {
+                     hashattributeset.add(attribute);
+                } else {
+                  if (!isAttributeValueSupported(attribute, docflavor, attributeset)) {
+                     hashattributeset.add(attribute);
+                  }
+                }
+            }
+            catch (ClassCastException classcastexception) {
+
+            }
+        }
+
+        if (hashattributeset.isEmpty()) {
+            return null;
+        }
+        return hashattributeset;
+    }
+
+    public ServiceUIFactory getServiceUIFactory() {
+        return null;
+    }
+
+    public String toString() {
+        return "Printer : " + getName();
+    }
+
+    public boolean equals(Object obj) {
+        return obj == this || (obj instanceof TestPrintService) && ((TestPrintService)obj).getName().equals(getName());
+    }
+
+    public int hashCode() {
+        return getClass().hashCode() + getName().hashCode();
+    }
+
+}
--- a/test/javax/print/attribute/SidesPageRangesTest.java	Thu Jan 14 15:48:36 2010 -0800
+++ b/test/javax/print/attribute/SidesPageRangesTest.java	Fri Jan 15 09:06:57 2010 -0800
@@ -64,7 +64,7 @@
                         System.out.println("\nPageRanges Attribute category is supported");
                 } else {
                         System.out.println("\nPageRanges Attribute category is not supported. terminating...");
-                        System.exit(1);
+                        return;
                 }
 
                 flavors = defService.getSupportedDocFlavors();