harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r468988 - in /incubator/harmony/enhanced/classlib/trunk/modules/print/src: main/java/common/javax/print/PrintService.java test/api/java/common/javax/print/GetAttributeTest.java test/api/java/common/javax/print/GetDefaultAttributeValueTest.java
Date Sun, 29 Oct 2006 20:53:58 GMT
Author: ndbeyer
Date: Sun Oct 29 12:53:57 2006
New Revision: 468988

URL: http://svn.apache.org/viewvc?view=rev&rev=468988
Log:
Uplift PrintService to meet Java 5 specification; correct affected test cases and clean them
up a bit.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/PrintService.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/GetAttributeTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/GetDefaultAttributeValueTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/PrintService.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/PrintService.java?view=diff&rev=468988&r1=468987&r2=468988
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/PrintService.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/PrintService.java
Sun Oct 29 12:53:57 2006
@@ -35,19 +35,19 @@
 
     boolean equals(Object object);
 
-    PrintServiceAttribute getAttribute(Class category);
+    <T extends PrintServiceAttribute> T getAttribute(Class<T> category);
 
     PrintServiceAttributeSet getAttributes();
 
-    Object getDefaultAttributeValue(Class category);
+    Object getDefaultAttributeValue(Class<? extends Attribute> category);
 
     String getName();
 
     ServiceUIFactory getServiceUIFactory();
 
-    Class[] getSupportedAttributeCategories();
+    Class<?>[] getSupportedAttributeCategories();
 
-    Object getSupportedAttributeValues(Class category, DocFlavor flavor,
+    Object getSupportedAttributeValues(Class<? extends Attribute> category, DocFlavor
flavor,
             AttributeSet attributes);
 
     DocFlavor[] getSupportedDocFlavors();
@@ -57,7 +57,7 @@
 
     int hashCode();
 
-    boolean isAttributeCategorySupported(Class category);
+    boolean isAttributeCategorySupported(Class<? extends Attribute> category);
 
     boolean isAttributeValueSupported(Attribute attrval, DocFlavor flavor, 
             AttributeSet attributes);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/GetAttributeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/GetAttributeTest.java?view=diff&rev=468988&r1=468987&r2=468988
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/GetAttributeTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/GetAttributeTest.java
Sun Oct 29 12:53:57 2006
@@ -14,10 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Igor A. Pyankov 
- * @version $Revision: 1.2 $ 
- */ 
 
 package javax.print;
 
@@ -29,33 +25,23 @@
 import javax.print.attribute.standard.PrinterState;
 import javax.print.attribute.standard.QueuedJobCount;
 import javax.print.attribute.standard.RequestingUserName;
-
 import junit.framework.TestCase;
 
 public class GetAttributeTest extends TestCase {
-
+    @SuppressWarnings("unchecked")
     public void testGetAttribute() {
-        System.out
-                .println("============= START testGetAttribute ================");
-
         PrintService[] services;
         Object probe;
-        Class[] clazz = new Class[] { PrinterIsAcceptingJobs.ACCEPTING_JOBS
-                .getCategory(),
-                PrinterState.IDLE.getCategory(),
-                QueuedJobCount.class,
-                Destination.class,
-                JobName.class,
-                RequestingUserName.class };
+        Class[] clazz = new Class[] { PrinterIsAcceptingJobs.ACCEPTING_JOBS.getCategory(),
+                PrinterState.IDLE.getCategory(), QueuedJobCount.class, Destination.class,
+                JobName.class, RequestingUserName.class };
         services = PrintServiceLookup.lookupPrintServices(null, null);
         TestUtil.checkServices(services);
-
         for (int i = 0, ii = services.length; i < ii; i++) {
-            System.out.println("----" + services[i].getName() + "----");
             for (int j = 0, jj = clazz.length; j < jj; j++) {
                 if (PrintServiceAttribute.class.isAssignableFrom(clazz[j])) {
                     probe = services[i].getAttribute(clazz[j]);
-                    System.out.println(clazz[j] + ": " + probe);
+                    assertNotNull(probe);
                 }
             }
             try {
@@ -65,17 +51,13 @@
                 // OK
             }
             try {
-                probe = services[i].getAttribute(Copies.class);
+                Class<?> invalidClass = Copies.class;
+                probe = services[i]
+                        .getAttribute((Class<? extends PrintServiceAttribute>) invalidClass);
                 fail("IllegalArgumentException must be thrown - category is not a Class that
implements interface PrintServiceAttribute.");
             } catch (IllegalArgumentException e) {
                 // OK
-            } catch (Exception e) {
-                fail("Exception " + e + "is thrown - something is wrong");
             }
         }
-
-        System.out
-                .println("============= END testGetAttribute ================");
     }
-
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/GetDefaultAttributeValueTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/GetDefaultAttributeValueTest.java?view=diff&rev=468988&r1=468987&r2=468988
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/GetDefaultAttributeValueTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/GetDefaultAttributeValueTest.java
Sun Oct 29 12:53:57 2006
@@ -14,63 +14,49 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Igor A. Pyankov 
- * @version $Revision: 1.2 $ 
- */ 
 
 package javax.print;
 
+import javax.print.attribute.PrintServiceAttribute;
 import javax.print.attribute.standard.Destination;
 import javax.print.attribute.standard.DocumentName;
 import javax.print.attribute.standard.JobName;
 import javax.print.attribute.standard.Media;
 import javax.print.attribute.standard.RequestingUserName;
-
 import junit.framework.TestCase;
 
 public class GetDefaultAttributeValueTest extends TestCase {
-
+    @SuppressWarnings("unchecked")
     public void testGetDefaultAttributeValue() {
-        System.out.println("============= START testGetDefaultAttributeValue ================");
-
         PrintService[] services;
         Object probe;
-        Class claz;
         services = PrintServiceLookup.lookupPrintServices(null, null);
         TestUtil.checkServices(services);
-        try {
-            for (int i = 0, ii = services.length; i < ii; i++) {
-                System.out.println("------------------" + services[i].getName()
-                        + "-------------------");
-                probe = services[i].getDefaultAttributeValue(claz = Media.class);
-                System.out.println(claz + ": " + probe);
-                probe = services[i].getDefaultAttributeValue(claz = Destination.class);
-                System.out.println(claz + ": " + probe);
-                probe = services[i].getDefaultAttributeValue(claz = JobName.class);
-                System.out.println(claz + ": " + probe);
-                probe = services[i].getDefaultAttributeValue(claz = RequestingUserName.class);
-                System.out.println(claz + ": " + probe);
-                probe = services[i].getDefaultAttributeValue(claz = DocumentName.class);
-                System.out.println(claz + ": " + probe);
-                try {
-                    probe = services[i].getDefaultAttributeValue(null);
-                    fail("NullPointerException must be thrown - the category is null");
-                } catch (Exception e) {
-                    // OK
-                }
-                try {
-                    probe = services[i].getDefaultAttributeValue(this.getClass());
-                    fail("IllegalArgumentException must be thrown - category is not a Class
that implements interface Attribute.");
-                } catch (IllegalArgumentException e) {
-                    // OK
-                }
+        for (int i = 0, ii = services.length; i < ii; i++) {
+            probe = services[i].getDefaultAttributeValue(Media.class);
+            assertNotNull(probe);
+            probe = services[i].getDefaultAttributeValue(Destination.class);
+            assertNotNull(probe);
+            probe = services[i].getDefaultAttributeValue(JobName.class);
+            assertNotNull(probe);
+            probe = services[i].getDefaultAttributeValue(RequestingUserName.class);
+            assertNotNull(probe);
+            probe = services[i].getDefaultAttributeValue(DocumentName.class);
+            assertNotNull(probe);
+            try {
+                probe = services[i].getDefaultAttributeValue(null);
+                fail("NullPointerException must be thrown - the category is null");
+            } catch (Exception e) {
+                // OK
+            }
+            try {
+                Class<?> invalidClass = this.getClass();
+                probe = services[i]
+                        .getDefaultAttributeValue((Class<? extends PrintServiceAttribute>)
invalidClass);
+                fail("IllegalArgumentException must be thrown - category is not a Class that
implements interface Attribute.");
+            } catch (IllegalArgumentException e) {
+                // OK
             }
-        } catch (RuntimeException e) {
-            fail("Exception "+e+" thrown");
         }
-
-        System.out.println("============= END testGetDefaultAttributeValue ================");
     }
-
 }



Mime
View raw message