harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r468246 - in /incubator/harmony/enhanced/classlib/trunk/modules/print/src: main/java/common/javax/print/DocFlavor.java test/api/java/common/javax/print/DocFlavorTest.java
Date Fri, 27 Oct 2006 03:03:10 GMT
Author: ndbeyer
Date: Thu Oct 26 20:03:09 2006
New Revision: 468246

URL: http://svn.apache.org/viewvc?view=rev&rev=468246
Log:
Add explicit serialVersionUID fields, add missing annotations and type variables, clean up
test case (proper assert usage)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/DocFlavor.java
    incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/DocFlavorTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/DocFlavor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/DocFlavor.java?view=diff&rev=468246&r1=468245&r2=468246
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/DocFlavor.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/main/java/common/javax/print/DocFlavor.java
Thu Oct 26 20:03:09 2006
@@ -14,18 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Irina A. Arkhipets 
- * @version $Revision: 1.5 $ 
- */ 
-
-/*
- * DocFlavor.java 
- *  
- * Encapsulates an object that specifies the format to a DocPrintJob print 
- * data.
- * 
- */
 
 package javax.print;
 
@@ -35,317 +23,310 @@
 import java.io.Serializable;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-
 import org.apache.harmony.x.print.MimeType;
 
-
+/** 
+ * Encapsulates an object that specifies the format to a DocPrintJob print 
+ * data.
+ * @author Irina A. Arkhipets
+ */
 public class DocFlavor implements Serializable, Cloneable {
+    private static final long serialVersionUID = -4512080796965449721L;
 
-public static final String hostEncoding;
-
-static {
-    /* Host encoding. Need to change it to 
-       "hostEncoding = Charset.defaultCharset().toString" */ 
-    hostEncoding = (String) 
-            (AccessController.doPrivileged(new PrivilegedAction() {
-        public Object run() {
-            return (System.getProperty("file.encoding"));
-        }
-    }));
-}
-
-//Document media type (as defined in RFC 2045,2046, 822)
-private transient org.apache.harmony.x.print.MimeType aType;
-
-private String aClass;      // Representation class name
-
-public DocFlavor(String mimeType, String className) {
-    if ((mimeType == null) || (className == null)) {
-        throw new NullPointerException();
+    public static final String hostEncoding;
+    static {
+        /*
+         * Host encoding. Need to change it to "hostEncoding =
+         * Charset.defaultCharset().toString"
+         */
+        hostEncoding = AccessController.doPrivileged(new PrivilegedAction<String>()
{
+            public String run() {
+                return System.getProperty("file.encoding");
+            }
+        });
     }
-    aType = new MimeType(mimeType);
-    aClass = className;
-}
 
-public boolean equals(Object obj) {
-    return (obj != null) && (obj instanceof DocFlavor) &&
-           (getCanonicalForm().equals(((DocFlavor) obj).getCanonicalForm()));
-}
+    // Document media type (as defined in RFC 2045,2046, 822)
+    private transient MimeType aType;
 
-public String getMediaSubtype() {
-    return aType.getSubtype();
-}
+    private String aClass; // Representation class name
 
-public String getMediaType() {
-    return aType.getType();
-}
+    public DocFlavor(String mimeType, String className) {
+        if ((mimeType == null) || (className == null)) {
+            throw new NullPointerException();
+        }
+        aType = new MimeType(mimeType);
+        aClass = className;
+    }
 
-public String getMimeType() {
-    return aType.toString();
-}
+    @Override
+    public boolean equals(Object obj) {
+        return (obj != null) && (obj instanceof DocFlavor)
+                && (getCanonicalForm().equals(((DocFlavor) obj).getCanonicalForm()));
+    }
 
-public String getParameter(String paramName) {
-    if (paramName == null) {
-        throw new NullPointerException();
+    public String getMediaSubtype() {
+        return aType.getSubtype();
     }
-    return aType.getParameter(paramName);
-}
 
-public String getRepresentationClassName() {
-    return aClass;
-}
+    public String getMediaType() {
+        return aType.getType();
+    }
 
-public int hashCode() {
-    return getCanonicalForm().hashCode();
-}
+    public String getMimeType() {
+        return aType.toString();
+    }
 
-public String toString() {
-    return getCanonicalForm();
-}
+    public String getParameter(String paramName) {
+        if (paramName == null) {
+            throw new NullPointerException();
+        }
+        return aType.getParameter(paramName);
+    }
 
-//--------------------------------------------------------------
+    public String getRepresentationClassName() {
+        return aClass;
+    }
 
-private void readObject(ObjectInputStream s) 
-        throws ClassNotFoundException, IOException {
-    s.defaultReadObject();
-    aType = new MimeType((String)(s.readObject()));
-}
+    @Override
+    public int hashCode() {
+        return getCanonicalForm().hashCode();
+    }
 
-private void writeObject(ObjectOutputStream s) 
-        throws IOException {
-    s.defaultWriteObject();
-    s.writeObject(aType.getCanonicalForm());
-}
+    @Override
+    public String toString() {
+        return getCanonicalForm();
+    }
 
-private String getCanonicalForm() {
-    return aType.toString()+"; class=\""+aClass+"\"";
-}
+    // --------------------------------------------------------------
+    private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
{
+        s.defaultReadObject();
+        aType = new MimeType((String) (s.readObject()));
+    }
 
-//--------------------------------------------------------------
+    private void writeObject(ObjectOutputStream s) throws IOException {
+        s.defaultWriteObject();
+        s.writeObject(aType.getCanonicalForm());
+    }
 
-public static class BYTE_ARRAY extends DocFlavor {
+    private String getCanonicalForm() {
+        return aType.toString() + "; class=\"" + aClass + "\"";
+    }
 
-public BYTE_ARRAY(String mimeType) {
-    super(mimeType, "[B");
-}
+    // --------------------------------------------------------------
+    public static class BYTE_ARRAY extends DocFlavor {
+        private static final long serialVersionUID = -9065578006593857475L;
 
-public static final BYTE_ARRAY AUTOSENSE =
-        new BYTE_ARRAY("application/octet-stream");
+        public BYTE_ARRAY(String mimeType) {
+            super(mimeType, "[B");
+        }
 
-public static final BYTE_ARRAY GIF = new BYTE_ARRAY("image/gif");
+        public static final BYTE_ARRAY AUTOSENSE = new BYTE_ARRAY("application/octet-stream");
 
-public static final BYTE_ARRAY JPEG = new BYTE_ARRAY("image/jpeg");
+        public static final BYTE_ARRAY GIF = new BYTE_ARRAY("image/gif");
 
-public static final BYTE_ARRAY PCL = new BYTE_ARRAY("application/vnd.hp-pcl");
+        public static final BYTE_ARRAY JPEG = new BYTE_ARRAY("image/jpeg");
 
-public static final BYTE_ARRAY PDF = new BYTE_ARRAY("application/pdf");
+        public static final BYTE_ARRAY PCL = new BYTE_ARRAY("application/vnd.hp-pcl");
 
+        public static final BYTE_ARRAY PDF = new BYTE_ARRAY("application/pdf");
 
-public static final BYTE_ARRAY PNG = new BYTE_ARRAY("image/png");
+        public static final BYTE_ARRAY PNG = new BYTE_ARRAY("image/png");
 
-public static final BYTE_ARRAY POSTSCRIPT = 
-        new BYTE_ARRAY("application/postscript");
+        public static final BYTE_ARRAY POSTSCRIPT = new BYTE_ARRAY("application/postscript");
 
-public static final BYTE_ARRAY TEXT_HTML_HOST = 
-        new BYTE_ARRAY("text/html;charset=" + hostEncoding);
+        public static final BYTE_ARRAY TEXT_HTML_HOST = new BYTE_ARRAY("text/html;charset="
+                + hostEncoding);
 
-public static final BYTE_ARRAY TEXT_HTML_US_ASCII = 
-        new BYTE_ARRAY("text/html;charset=us-ascii");
+        public static final BYTE_ARRAY TEXT_HTML_US_ASCII = new BYTE_ARRAY(
+                "text/html;charset=us-ascii");
 
-public static final BYTE_ARRAY TEXT_HTML_UTF_16 = 
-        new BYTE_ARRAY("text/html;charset=utf-16");
+        public static final BYTE_ARRAY TEXT_HTML_UTF_16 = new BYTE_ARRAY(
+                "text/html;charset=utf-16");
 
-public static final BYTE_ARRAY TEXT_HTML_UTF_16BE = 
-        new BYTE_ARRAY("text/html;charset=utf-16be");
+        public static final BYTE_ARRAY TEXT_HTML_UTF_16BE = new BYTE_ARRAY(
+                "text/html;charset=utf-16be");
 
-public static final BYTE_ARRAY TEXT_HTML_UTF_16LE = 
-        new BYTE_ARRAY("text/html;charset=utf-16le");
+        public static final BYTE_ARRAY TEXT_HTML_UTF_16LE = new BYTE_ARRAY(
+                "text/html;charset=utf-16le");
 
-public static final BYTE_ARRAY TEXT_HTML_UTF_8 = 
-        new BYTE_ARRAY("text/html;charset=utf-8");
+        public static final BYTE_ARRAY TEXT_HTML_UTF_8 = new BYTE_ARRAY(
+                "text/html;charset=utf-8");
 
-public static final BYTE_ARRAY TEXT_PLAIN_HOST = 
-        new BYTE_ARRAY("text/plain;charset=" + hostEncoding);
+        public static final BYTE_ARRAY TEXT_PLAIN_HOST = new BYTE_ARRAY("text/plain;charset="
+                + hostEncoding);
 
-public static final BYTE_ARRAY TEXT_PLAIN_US_ASCII = 
-        new BYTE_ARRAY("text/plain;charset=us-ascii");
+        public static final BYTE_ARRAY TEXT_PLAIN_US_ASCII = new BYTE_ARRAY(
+                "text/plain;charset=us-ascii");
 
-public static final BYTE_ARRAY TEXT_PLAIN_UTF_16 = 
-        new BYTE_ARRAY("text/plain;charset=utf-16");
+        public static final BYTE_ARRAY TEXT_PLAIN_UTF_16 = new BYTE_ARRAY(
+                "text/plain;charset=utf-16");
 
-public static final BYTE_ARRAY TEXT_PLAIN_UTF_16BE = 
-        new BYTE_ARRAY("text/plain;charset=utf-16be");
+        public static final BYTE_ARRAY TEXT_PLAIN_UTF_16BE = new BYTE_ARRAY(
+                "text/plain;charset=utf-16be");
 
-public static final BYTE_ARRAY TEXT_PLAIN_UTF_16LE = 
-        new BYTE_ARRAY("text/plain;charset=utf-16le");
+        public static final BYTE_ARRAY TEXT_PLAIN_UTF_16LE = new BYTE_ARRAY(
+                "text/plain;charset=utf-16le");
 
-public static final BYTE_ARRAY TEXT_PLAIN_UTF_8 = 
-        new BYTE_ARRAY("text/plain;charset=utf-8");
-}
+        public static final BYTE_ARRAY TEXT_PLAIN_UTF_8 = new BYTE_ARRAY(
+                "text/plain;charset=utf-8");
+    }
 
-public static class CHAR_ARRAY extends DocFlavor {
+    public static class CHAR_ARRAY extends DocFlavor {
+        private static final long serialVersionUID = -8720590903724405128L;
 
-public CHAR_ARRAY(String mimeType) {
-    super(mimeType, "[C");
-}
+        public CHAR_ARRAY(String mimeType) {
+            super(mimeType, "[C");
+        }
 
-public static final CHAR_ARRAY TEXT_HTML = 
-        new CHAR_ARRAY("text/html;charset=utf-16");
+        public static final CHAR_ARRAY TEXT_HTML = new CHAR_ARRAY("text/html;charset=utf-16");
 
-public static final CHAR_ARRAY TEXT_PLAIN = 
-        new CHAR_ARRAY("text/plain;charset=utf-16");
-}
+        public static final CHAR_ARRAY TEXT_PLAIN = new CHAR_ARRAY("text/plain;charset=utf-16");
+    }
 
-public static class INPUT_STREAM extends DocFlavor {
+    public static class INPUT_STREAM extends DocFlavor {
+        private static final long serialVersionUID = -7045842700749194127L;
 
-public INPUT_STREAM(String mimeType) {
-    super(mimeType, "java.io.InputStream");
-}
+        public INPUT_STREAM(String mimeType) {
+            super(mimeType, "java.io.InputStream");
+        }
 
-public static final INPUT_STREAM AUTOSENSE = 
-        new INPUT_STREAM("application/octet-stream");
+        public static final INPUT_STREAM AUTOSENSE = new INPUT_STREAM(
+                "application/octet-stream");
 
-public static final INPUT_STREAM GIF = new INPUT_STREAM("image/gif");
+        public static final INPUT_STREAM GIF = new INPUT_STREAM("image/gif");
 
-public static final INPUT_STREAM JPEG = new INPUT_STREAM("image/jpeg");
+        public static final INPUT_STREAM JPEG = new INPUT_STREAM("image/jpeg");
 
-public static final INPUT_STREAM PCL = 
-        new INPUT_STREAM("application/vnd.hp-pcl");
+        public static final INPUT_STREAM PCL = new INPUT_STREAM("application/vnd.hp-pcl");
 
-public static final INPUT_STREAM PDF = new INPUT_STREAM("application/pdf");
+        public static final INPUT_STREAM PDF = new INPUT_STREAM("application/pdf");
 
-public static final INPUT_STREAM PNG = new INPUT_STREAM("image/png");
+        public static final INPUT_STREAM PNG = new INPUT_STREAM("image/png");
 
-public static final INPUT_STREAM POSTSCRIPT = 
-        new INPUT_STREAM("application/postscript");
+        public static final INPUT_STREAM POSTSCRIPT = new INPUT_STREAM("application/postscript");
 
-public static final INPUT_STREAM TEXT_HTML_HOST = 
-        new INPUT_STREAM("text/html;charset=" + hostEncoding);
+        public static final INPUT_STREAM TEXT_HTML_HOST = new INPUT_STREAM("text/html;charset="
+                + hostEncoding);
 
-public static final INPUT_STREAM TEXT_HTML_US_ASCII = 
-        new INPUT_STREAM("text/html;charset=us-ascii");
+        public static final INPUT_STREAM TEXT_HTML_US_ASCII = new INPUT_STREAM(
+                "text/html;charset=us-ascii");
 
-public static final INPUT_STREAM TEXT_HTML_UTF_16 = 
-        new INPUT_STREAM("text/html;charset=utf-16");
+        public static final INPUT_STREAM TEXT_HTML_UTF_16 = new INPUT_STREAM(
+                "text/html;charset=utf-16");
 
-public static final INPUT_STREAM TEXT_HTML_UTF_16BE = 
-        new INPUT_STREAM("text/html;charset=utf-16be");
+        public static final INPUT_STREAM TEXT_HTML_UTF_16BE = new INPUT_STREAM(
+                "text/html;charset=utf-16be");
 
-public static final INPUT_STREAM TEXT_HTML_UTF_16LE = 
-        new INPUT_STREAM("text/html;charset=utf-16le");
+        public static final INPUT_STREAM TEXT_HTML_UTF_16LE = new INPUT_STREAM(
+                "text/html;charset=utf-16le");
 
-public static final INPUT_STREAM TEXT_HTML_UTF_8 = 
-        new INPUT_STREAM("text/html;charset=utf-8");
+        public static final INPUT_STREAM TEXT_HTML_UTF_8 = new INPUT_STREAM(
+                "text/html;charset=utf-8");
 
-public static final INPUT_STREAM TEXT_PLAIN_HOST = 
-        new INPUT_STREAM("text/plain;charset=" + hostEncoding);
+        public static final INPUT_STREAM TEXT_PLAIN_HOST = new INPUT_STREAM(
+                "text/plain;charset=" + hostEncoding);
 
-public static final INPUT_STREAM TEXT_PLAIN_US_ASCII = 
-        new INPUT_STREAM("text/plain;charset=us-ascii");
+        public static final INPUT_STREAM TEXT_PLAIN_US_ASCII = new INPUT_STREAM(
+                "text/plain;charset=us-ascii");
 
-public static final INPUT_STREAM TEXT_PLAIN_UTF_16 = 
-        new INPUT_STREAM("text/plain;charset=utf-16");
+        public static final INPUT_STREAM TEXT_PLAIN_UTF_16 = new INPUT_STREAM(
+                "text/plain;charset=utf-16");
 
-public static final INPUT_STREAM TEXT_PLAIN_UTF_16BE = 
-        new INPUT_STREAM("text/plain;charset=utf-16be");
+        public static final INPUT_STREAM TEXT_PLAIN_UTF_16BE = new INPUT_STREAM(
+                "text/plain;charset=utf-16be");
 
-public static final INPUT_STREAM TEXT_PLAIN_UTF_16LE = 
-        new INPUT_STREAM("text/plain;charset=utf-16le");
+        public static final INPUT_STREAM TEXT_PLAIN_UTF_16LE = new INPUT_STREAM(
+                "text/plain;charset=utf-16le");
 
-public static final INPUT_STREAM TEXT_PLAIN_UTF_8 = 
-        new INPUT_STREAM("text/plain;charset=utf-8");
-}
+        public static final INPUT_STREAM TEXT_PLAIN_UTF_8 = new INPUT_STREAM(
+                "text/plain;charset=utf-8");
+    }
 
-public static class READER extends DocFlavor {
+    public static class READER extends DocFlavor {
+        private static final long serialVersionUID = 7100295812579351567L;
 
-public READER(String mimeType) {
-    super(mimeType, "java.io.Reader");
-}
+        public READER(String mimeType) {
+            super(mimeType, "java.io.Reader");
+        }
 
-public static final READER TEXT_HTML = new READER("text/html;charset=utf-16");
+        public static final READER TEXT_HTML = new READER("text/html;charset=utf-16");
 
-public static final READER TEXT_PLAIN = new READER("text/plain;charset=utf-16");
-}
+        public static final READER TEXT_PLAIN = new READER("text/plain;charset=utf-16");
+    }
 
-public static class SERVICE_FORMATTED extends DocFlavor {
+    public static class SERVICE_FORMATTED extends DocFlavor {
+        private static final long serialVersionUID = 6181337766266637256L;
 
-public SERVICE_FORMATTED(String className) {
-    super("application/x-java-jvm-local-objectref", className);
-}
+        public SERVICE_FORMATTED(String className) {
+            super("application/x-java-jvm-local-objectref", className);
+        }
 
-public static final SERVICE_FORMATTED PAGEABLE = 
-        new SERVICE_FORMATTED("java.awt.print.Pageable");
+        public static final SERVICE_FORMATTED PAGEABLE = new SERVICE_FORMATTED(
+                "java.awt.print.Pageable");
 
-public static final SERVICE_FORMATTED PRINTABLE = 
-        new SERVICE_FORMATTED("java.awt.print.Printable");
+        public static final SERVICE_FORMATTED PRINTABLE = new SERVICE_FORMATTED(
+                "java.awt.print.Printable");
 
-public static final SERVICE_FORMATTED RENDERABLE_IMAGE = 
-        new SERVICE_FORMATTED("java.awt.image.renderable.RenderableImage");
-}
+        public static final SERVICE_FORMATTED RENDERABLE_IMAGE = new SERVICE_FORMATTED(
+                "java.awt.image.renderable.RenderableImage");
+    }
 
-public static class STRING extends DocFlavor {
-public STRING(String mimeType) {
-    super(mimeType, "java.lang.String");
-}
+    public static class STRING extends DocFlavor {
+        private static final long serialVersionUID = 4414407504887034035L;
 
-public static final STRING TEXT_HTML = new STRING("text/html;charset=utf-16");
+        public STRING(String mimeType) {
+            super(mimeType, "java.lang.String");
+        }
 
-public static final STRING TEXT_PLAIN = new STRING("text/plain;charset=utf-16");
-}
+        public static final STRING TEXT_HTML = new STRING("text/html;charset=utf-16");
 
-public static class URL extends DocFlavor {
+        public static final STRING TEXT_PLAIN = new STRING("text/plain;charset=utf-16");
+    }
 
-public URL(String mimeType) {
-    super(mimeType, "java.net.URL");
-}
+    public static class URL extends DocFlavor {
+        private static final long serialVersionUID = 2936725788144902062L;
 
-public static final URL AUTOSENSE = new URL("application/octet-stream");
+        public URL(String mimeType) {
+            super(mimeType, "java.net.URL");
+        }
 
-public static final URL GIF = new URL("image/gif");
+        public static final URL AUTOSENSE = new URL("application/octet-stream");
 
-public static final URL JPEG = new URL("image/jpeg");
+        public static final URL GIF = new URL("image/gif");
 
-public static final URL PCL = new URL("application/vnd.hp-pcl");
+        public static final URL JPEG = new URL("image/jpeg");
 
-public static final URL PDF = new URL("application/pdf");
+        public static final URL PCL = new URL("application/vnd.hp-pcl");
 
-public static final URL PNG = new URL("image/png");
+        public static final URL PDF = new URL("application/pdf");
 
-public static final URL POSTSCRIPT = new URL("application/postscript");
+        public static final URL PNG = new URL("image/png");
 
-public static final URL TEXT_HTML_HOST = 
-        new URL("text/html;charset=" + hostEncoding);
+        public static final URL POSTSCRIPT = new URL("application/postscript");
 
-public static final URL TEXT_HTML_US_ASCII = 
-        new URL("text/html;charset=us-ascii");
+        public static final URL TEXT_HTML_HOST = new URL("text/html;charset=" + hostEncoding);
 
-public static final URL TEXT_HTML_UTF_16 = new URL("text/html;charset=utf-16");
+        public static final URL TEXT_HTML_US_ASCII = new URL("text/html;charset=us-ascii");
 
-public static final URL TEXT_HTML_UTF_16BE = 
-        new URL("text/html;charset=utf-16be");
+        public static final URL TEXT_HTML_UTF_16 = new URL("text/html;charset=utf-16");
 
-public static final URL TEXT_HTML_UTF_16LE =
-        new URL("text/html;charset=utf-16le");
+        public static final URL TEXT_HTML_UTF_16BE = new URL("text/html;charset=utf-16be");
 
-public static final URL TEXT_HTML_UTF_8 = new URL("text/html;charset=utf-8");
+        public static final URL TEXT_HTML_UTF_16LE = new URL("text/html;charset=utf-16le");
 
-public static final URL TEXT_PLAIN_HOST = 
-        new URL("text/plain;charset=" +hostEncoding);
+        public static final URL TEXT_HTML_UTF_8 = new URL("text/html;charset=utf-8");
 
-public static final URL TEXT_PLAIN_US_ASCII = 
-        new URL("text/plain;charset=us-ascii");
+        public static final URL TEXT_PLAIN_HOST = new URL("text/plain;charset=" + hostEncoding);
 
-public static final URL TEXT_PLAIN_UTF_16 = 
-        new URL("text/plain;charset=utf-16");
+        public static final URL TEXT_PLAIN_US_ASCII = new URL("text/plain;charset=us-ascii");
 
-public static final URL TEXT_PLAIN_UTF_16BE =
-        new URL("text/plain;charset=utf-16be");
+        public static final URL TEXT_PLAIN_UTF_16 = new URL("text/plain;charset=utf-16");
 
-public static final URL TEXT_PLAIN_UTF_16LE =
-        new URL("text/plain;charset=utf-16le");
+        public static final URL TEXT_PLAIN_UTF_16BE = new URL("text/plain;charset=utf-16be");
 
-public static final URL TEXT_PLAIN_UTF_8 =
-        new URL("text/plain;charset=utf-8");
-}
+        public static final URL TEXT_PLAIN_UTF_16LE = new URL("text/plain;charset=utf-16le");
 
-} /* End of DocFlavor class */ 
+        public static final URL TEXT_PLAIN_UTF_8 = new URL("text/plain;charset=utf-8");
+    }
+} /* End of DocFlavor class */

Modified: incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/DocFlavorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/DocFlavorTest.java?view=diff&rev=468246&r1=468245&r2=468246
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/DocFlavorTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/print/src/test/api/java/common/javax/print/DocFlavorTest.java
Thu Oct 26 20:03:09 2006
@@ -14,112 +14,79 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
- * @author Irina A. Arkhipets 
- * @version $Revision: 1.3 $ 
- */ 
-
-/*
- * DocFlavorTest.java
- * 
- * JUnit tests for javax.print.DocFlavor class.
- * 
- */
 
 package javax.print;
 
 import junit.framework.TestCase;
 
 public class DocFlavorTest extends TestCase {
-
-static public void testStatic() {
-    System.out.println("----------------------------------------");
-    System.out.println("Static variables testing...");
-    try {
+    public void testStatic() {
         String encoding = System.getProperty("file.encoding");
-        if ((encoding != null) && (encoding.length() > 0)) {
-            assertEquals(DocFlavor.hostEncoding, encoding);
-        } else {
-            System.out.println(
-                    "WARNING: Can not get system file.encoding property!");
+        assertEquals(encoding, DocFlavor.hostEncoding);
+    }
+
+    public void testHashCode() {
+        DocFlavor f1 = new DocFlavor("text/plain; charset=us-ascii", "[B");
+        DocFlavor f2 = new DocFlavor("text/plain; charset=us-ascii (comments)", "[B");
+        assertEquals(f1.hashCode(), f1.hashCode());
+        assertEquals(f1.hashCode(), f2.hashCode());
+    }
+
+    public void testMyDocFlavor() {
+        tryNullPointer(null, "[B");
+        tryNullPointer("text/plain", null);
+    }
+
+    public void testEqualsObject() {
+        DocFlavor f1 = new DocFlavor("text/plain; charset=us-ascii", "[B");
+        DocFlavor f2 = new DocFlavor("text/plain; charset=us-ascii (comments)", "[B");
+        DocFlavor f3 = new DocFlavor("image/gif", "[B");
+        DocFlavor f4 = new DocFlavor("text/plain", "[B");
+        DocFlavor f5 = new DocFlavor("text/plain; charset=us-ascii", "[C");
+        assertEquals(f1, f1);
+        assertEquals(f1, f2);
+        assertFalse(f1.equals(f3));
+        assertFalse(f1.equals(f4));
+        assertFalse(f1.equals(f5));
+    }
+
+    public void testGetMediaSubtype() {
+        DocFlavor f = new DocFlavor("text/plain; charset=us-ascii", "[B");
+        assertEquals("plain",f.getMediaSubtype());
+    }
+
+    public void testGetMediaType() {
+        DocFlavor f = new DocFlavor("text/plain; charset=us-ascii", "[B");
+        assertEquals("text", f.getMediaType());
+    }
+
+    public void testGetMimeType() {
+        DocFlavor f = new DocFlavor("TEXT/plain; BBB=par1; aaa=par2 (comments)", "[B");
+        assertEquals("text/plain; aaa=\"par2\"; bbb=\"par1\"", f.getMimeType());
+    }
+
+    public void testGetParameter() {
+        DocFlavor f = new DocFlavor("TEXT/plain; BBB=par1; aaa=par2 (comments)", "[B");
+        assertEquals("par1", f.getParameter("bbb"));
+        assertNull(f.getParameter("absent"));
+    }
+
+    public void testGetRepresentationClassName() {
+        DocFlavor f = new DocFlavor("TEXT/plain; BBB=par1; aaa=par2 (comments)", "[B");
+        assertEquals("[B", f.getRepresentationClassName());
+    }
+
+    public void testToString() {
+        DocFlavor f = new DocFlavor("TEXT/plain; BBB=par1; aaa=par2 (comments)", "[B");
+        assertEquals("text/plain; aaa=\"par2\"; bbb=\"par1\"; class=\"[B\"", f.toString());
+    }
+
+    void tryNullPointer(String s1, String s2) {
+        try {
+            new DocFlavor(s1, s2);
+            fail();
+        } catch (NullPointerException e) {
+            /* NullPointerException is expected here, so the test passes */
         }
-    } catch (Exception e) {
-        System.out.println(
-                "WARNING: Can not get system file.encoding property!");
-        e.printStackTrace();
-    }
-}
-
-public void testHashCode() {
-    DocFlavor f1 = new DocFlavor("text/plain; charset=us-ascii", "[B");
-    DocFlavor f2 = 
-            new DocFlavor("text/plain; charset=us-ascii (comments)", "[B");
-    assertEquals(f1.hashCode(), f1.hashCode());
-    assertEquals(f1.hashCode(), f2.hashCode());
-}
-
-public void testMyDocFlavor() {
-    tryNullPointer(null, "[B");
-    tryNullPointer("text/plain", null);
-}
-
-public void testEqualsObject() {
-    DocFlavor f1 = new DocFlavor("text/plain; charset=us-ascii", "[B");
-    DocFlavor f2 = 
-            new DocFlavor("text/plain; charset=us-ascii (comments)", "[B");
-    DocFlavor f3 = new DocFlavor("image/gif", "[B");
-    DocFlavor f4 = new DocFlavor("text/plain", "[B");
-    DocFlavor f5 = new DocFlavor("text/plain; charset=us-ascii", "[C");
-    assertTrue(f1.equals(f1));
-    assertTrue(f1.equals(f2));
-    assertFalse(f1.equals(f3));
-    assertFalse(f1.equals(f4));
-    assertFalse(f1.equals(f5));
-}
-
-public void testGetMediaSubtype() {
-    DocFlavor f = new DocFlavor("text/plain; charset=us-ascii", "[B");
-    assertTrue(f.getMediaSubtype().equals(new String("plain")));
-}
-
-public void testGetMediaType() {
-    DocFlavor f = new DocFlavor("text/plain; charset=us-ascii", "[B");
-    assertTrue(f.getMediaType().equals(new String("text")));
-}
-
-public void testGetMimeType() {
-    DocFlavor f = 
-            new DocFlavor("TEXT/plain; BBB=par1; aaa=par2 (comments)", "[B");
-    assertTrue((f.getMimeType()).equals(
-            new String("text/plain; aaa=\"par2\"; bbb=\"par1\"")));
-}
-
-public void testGetParameter() {
-    DocFlavor f =
-            new DocFlavor("TEXT/plain; BBB=par1; aaa=par2 (comments)", "[B");
-    assertEquals(f.getParameter("bbb"), new String("par1"));
-    assertNull(f.getParameter("absent"));
-}
-
-public void testGetRepresentationClassName() {
-    DocFlavor f = 
-            new DocFlavor("TEXT/plain; BBB=par1; aaa=par2 (comments)", "[B");
-    assertEquals(f.getRepresentationClassName(), new String("[B"));
-}
-
-public void testToString() {
-    DocFlavor f = 
-            new DocFlavor("TEXT/plain; BBB=par1; aaa=par2 (comments)", "[B");
-    assertEquals(f.toString(), new String(
-            "text/plain; aaa=\"par2\"; bbb=\"par1\"; class=\"[B\""));
-}
-
-void tryNullPointer(String s1, String s2) {
-    try {
-        new DocFlavor(s1, s2);
-        fail();
-    } catch (NullPointerException e) {
-        /* NullPointerException is expected here, so the test passes */
     }
-}
 }



Mime
View raw message