harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r454289 [22/22] - in /incubator/harmony/enhanced/classlib/trunk/modules/H-1609: ./ modules/ modules/applet/ modules/applet/src/ modules/applet/src/main/ modules/applet/src/main/java/ modules/applet/src/main/java/java/ modules/applet/src/mai...
Date Mon, 09 Oct 2006 05:33:21 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaSizeNameTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaSizeNameTest.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaSizeNameTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaSizeNameTest.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,91 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Elena V. Sayapina 
+ * @version $Revision: 1.3 $ 
+ */ 
+ 
+package javax.print.attribute.standard;
+
+import javax.print.attribute.EnumSyntax;
+
+import junit.framework.TestCase;
+
+public class MediaSizeNameTest extends TestCase {
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(MediaSizeNameTest.class);
+    }
+
+    static {
+        System.out.println("MediaSizeName testing...");
+    }
+
+    /*
+     * MediaSizeName constructor testing.
+     */
+    public final void testMediaName() {
+        MediaSizeName msn = new mediaSizeName(0);
+        assertEquals(0, msn.getValue());
+        assertEquals("iso-a0", msn.toString());
+
+        msn = mediaSizeName.A;
+        assertEquals("a", msn.toString());
+
+        msn = mediaSizeName.FOLIO;
+        assertEquals("folio", msn.toString());
+    }
+
+
+    /*
+     * getStringTable(), getEnumValueTable() method testing.
+     */
+    public void testGetStringTable() {
+        mediaSizeName msn = new mediaSizeName(1);
+        String[] str = msn.getStringTableEx();
+        EnumSyntax[] table = msn.getEnumValueTableEx();
+        assertEquals(str.length, table.length);
+        assertEquals(73, str.length);
+
+        //Tests that StringTable isn't changed for MediaSizeName class
+        msn = new mediaSizeName(1);
+        str = msn.getStringTableEx();
+        str[1] = "MediaSizeName1";
+        //System.out.println(msn.getStringTable()[1]);
+        assertFalse(msn.getStringTableEx()[1].equals("MediaSizeName1"));
+    }
+
+
+    /*
+     * Auxiliary class
+     */
+    public class mediaSizeName extends MediaSizeName {
+
+        public mediaSizeName(int value) {
+            super(value);
+        }
+
+        public String[] getStringTableEx() {
+            return getStringTable();
+        }
+
+        public EnumSyntax[] getEnumValueTableEx() {
+            return getEnumValueTable();
+        }
+    }
+
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaSizeNameTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaSizeTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaSizeTest.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaSizeTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaSizeTest.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,230 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Elena V. Sayapina 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print.attribute.standard;
+
+import org.apache.harmony.x.print.attributes.PPDMediaSizeName;
+
+import junit.framework.TestCase;
+
+
+public class MediaSizeTest extends TestCase {
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(MediaSizeTest.class);
+    }
+
+    static {
+        System.out.println("MediaSize testing...");
+    }
+
+
+    /*
+     * MediaSize constructor testing.
+     */
+    public final void testMediaSize() {
+        MediaSize  ms = new MediaSize(200, 300, 1000, MediaSizeName.A);
+        assertEquals(200, (int) ms.getX(1000));
+        assertEquals(300, (int) ms.getY(1000));
+
+        assertFalse(200 == (int) MediaSize.Engineering.A.getX(1000));
+        assertFalse(300 == (int) MediaSize.Engineering.A.getY(1000));
+    }
+
+    /*
+     * equals(Object object) method testing.
+     */
+    public final void testEquals() {
+
+        MediaSize ms1 = MediaSize.ISO.B0;
+        MediaSize ms2 = MediaSize.ISO.B0;
+        assertTrue(ms1.equals(ms1));
+        ms2 = MediaSize.JIS.B0;
+        assertFalse(ms1.equals(ms2));
+        ms2 = null;
+        assertFalse(ms1.equals(ms2));
+    }
+
+
+    /*
+     * findMedia(float x, float y, int units) method testing.
+     * Tests that findMedia(..) gives correct results on big figures.
+     */
+    public final void testFindMedia() {
+
+        MediaSizeName msn1 = new mediaSizeName(111);
+        MediaSizeName msn2 = new mediaSizeName(112);
+        MediaSizeName msn3 = new mediaSizeName(113);
+        MediaSize ms1 = new MediaSize(Integer.MAX_VALUE / 15,
+                Integer.MAX_VALUE / 15, 1, msn1);
+        MediaSize ms2 = new MediaSize(Integer.MAX_VALUE / 5,
+                Integer.MAX_VALUE / 5, 1, msn2);
+        MediaSize ms3 = new MediaSize(Integer.MAX_VALUE, Integer.MAX_VALUE, 1,
+                msn3);
+        assertEquals(msn2,
+            MediaSize.findMedia(Integer.MAX_VALUE/4, Integer.MAX_VALUE/4, 1));
+        assertEquals(msn3,
+            MediaSize.findMedia(Float.MAX_VALUE, Float.MAX_VALUE, 1));
+    }
+
+    /*
+     * findMedia(float x, float y, int units) method testing.
+     * Tests that JIS_B0 is found as the biggest media from all 
+     * standard media sheets and ISO_A10 is found as the smallest 
+     * media from all standard media sheets. 
+     */
+    public final void testFindMedia1() {
+
+        assertTrue((MediaSizeName.JIS_B0 ==
+                MediaSize.findMedia(5000, 5000, MediaSize.MM)) ||
+                ((MediaSizeName) PPDMediaSizeName.B0 ==
+                MediaSize.findMedia(5000, 5000, MediaSize.MM)));
+
+        assertTrue((MediaSizeName.ISO_A10 ==
+            MediaSize.findMedia(20, 20, MediaSize.MM)) ||
+            ((MediaSizeName) PPDMediaSizeName.A10 ==
+            MediaSize.findMedia(20, 20, MediaSize.MM)));
+    }
+
+    /*
+     * findMedia(float x, float y, int units) method testing. 
+     * Simple check on standard media sheets.
+     */
+    public final void testFindMedia2() {
+
+        assertEquals(MediaSizeName.EXECUTIVE,
+            MediaSize.findMedia(7.25f, 10.5f, MediaSize.INCH));
+
+        MediaSizeName found = MediaSize.findMedia(8.5f, 11f, MediaSize.INCH);
+        if(found != MediaSizeName.A && found != MediaSizeName.NA_LETTER) {
+            fail("MediaSize.findMedia(8.5f, 11f, MediaSize.INCH) = " +
+                    MediaSize.findMedia(8.5f, 11f, MediaSize.INCH));
+        }
+
+        assertEquals(MediaSizeName.JAPANESE_DOUBLE_POSTCARD,
+                MediaSize.findMedia(148, 200, MediaSize.MM));
+
+        found = MediaSize.findMedia(11, 17, MediaSize.INCH);
+        if(found != MediaSizeName.TABLOID && found != MediaSizeName.LEDGER
+                                                && found != MediaSizeName.B) {
+            fail("MediaSize.findMedia(11, 17, MediaSize.INCH) = " +
+                    MediaSize.findMedia(8.5f, 11f, MediaSize.INCH));
+        }
+
+        assertEquals(MediaSizeName.NA_5X7,
+                MediaSize.findMedia(5, 7, MediaSize.INCH));
+
+    }
+
+    /*
+     * findMedia(float x, float y, int units) method testing.
+     * Tests that findMedia(..) finds the closest media sheet. 
+     */
+    public final void testFindMedia3() {
+
+        assertEquals(MediaSizeName.ISO_A4,
+            MediaSize.findMedia(MediaSize.ISO.A4.getX(MediaSize.MM)+1,
+                                MediaSize.ISO.A4.getY(MediaSize.MM)+1,
+                                MediaSize.MM));
+
+        MediaSizeName msn1 = new mediaSizeName(91);
+        MediaSizeName msn2 = new mediaSizeName(92);
+        MediaSize  ms1 = new MediaSize(0.01f, 0.01f, 100, msn1);
+        MediaSize  ms2 = new MediaSize(0.02f, 0.02f, 10, msn2);
+
+        assertEquals(msn2,
+            MediaSize.findMedia(0.00017f, 0.00017f, 1));
+    }
+
+    /*
+     * getCategory() method testing.
+     */
+    public final void testGetCategory() {
+        MediaSize ms = MediaSize.ISO.A0;
+        assertEquals(MediaSize.class, ms.getCategory());
+    }
+
+    /*
+     * getMediaSizeForName(MediaSizeName media) method testing.
+     * Tests that getMediaSizeForName(..) did mapping between MediaSize
+     * and MediaSizeName, but standard media sizes didn't remove.
+     */
+    public final void testGetMediaSizeForName() {
+
+        //new mapping
+        MediaSize  ms1 = new MediaSize(1, 1, 100000, MediaSizeName.A);
+
+        assertEquals(ms1,
+            MediaSize.getMediaSizeForName(MediaSizeName.A));
+
+
+        assertEquals(MediaSizeName.A,
+            MediaSize.findMedia(1, 1, 100000));
+        //System.out.println("findMedia(1, 1, 100000) " +
+        //MediaSize.findMedia(1, 1 , 100000));
+
+        MediaSizeName found = MediaSize.findMedia(8.5f, 11f, MediaSize.INCH);
+        //System.out.println("findMedia(8.5, 11, MediaSize.INCH) = " +
+        //MediaSize.findMedia(8.5f, 11f, MediaSize.INCH));
+        if(found != MediaSizeName.A && found != MediaSizeName.NA_LETTER) {
+            fail("findMedia(8.5, 11, MediaSize.INCH) = " +
+                    MediaSize.findMedia(8.5f, 11f, MediaSize.INCH));
+        }
+
+        assertEquals(MediaSize.NA.LEGAL,
+                MediaSize.getMediaSizeForName(MediaSizeName.NA_LEGAL));
+        assertEquals(MediaSize.Other.LEDGER,
+                MediaSize.getMediaSizeForName(MediaSizeName.LEDGER));
+
+    }
+
+    /*
+     * getMediaSizeName() method testing.
+     */
+    public final void testGetMediaSizeName() {
+        MediaSize ms = MediaSize.ISO.A0;
+        assertEquals(MediaSizeName.ISO_A0, ms.getMediaSizeName());
+        ms = MediaSize.JIS.B0;
+        assertEquals(MediaSizeName.JIS_B0, ms.getMediaSizeName());
+
+        ms = new MediaSize(30, 30, MediaSize.INCH);
+        assertEquals(null, ms.getMediaSizeName());
+    }
+
+    /*
+     * getName() method testing.
+     */
+    public final void testGetName() {
+        MediaSize ms = MediaSize.ISO.A0;
+        assertEquals("media-size", ms.getName());
+    }
+
+
+    /*
+     * Auxiliary class
+     */
+    public class mediaSizeName extends MediaSizeName {
+
+        public mediaSizeName(int value) {
+            super(value);
+        }
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaSizeTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaTest.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaTest.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,129 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Elena V. Sayapina 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print.attribute.standard;
+
+import javax.print.attribute.HashAttributeSet;
+
+import junit.framework.TestCase;
+
+public class MediaTest extends TestCase {
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(MediaTest.class);
+    }
+
+    static {
+        System.out.println("Media testing...");
+    }
+
+    /*
+     * equals(Object object) method testing.
+     */
+    public final void testEqualsObject() {
+        Media name = MediaName.NA_LETTER_WHITE;
+        Media sizename = MediaSizeName.INVOICE;
+        assertTrue(name.equals(MediaName.NA_LETTER_WHITE));
+        assertFalse(name.equals(sizename));
+
+        name = new mediaName(1);
+        Media tray = new mediaTray(1);
+        assertFalse(name.equals(tray));
+
+        try {
+            sizename = null;
+            assertFalse(name.equals(sizename));
+        } catch (Exception e) {
+            fail("Unexpected exception ocurred " + e);
+        }
+    }
+
+    /*
+     * getCategory() method testing.
+     */
+    public final void testGetCategory() {
+        Media m = new media(1);
+        assertEquals(Media.class, m.getCategory());
+    }
+
+    /*
+     * getName() method testing.
+     */
+    public final void testGetName() {
+        Media m = new media(1);
+        assertEquals("media", m.getName());
+    }
+
+
+    /*
+     * Test that MadiaName, MediaSizeName, MediaTray are
+     * fall into the Media attribute Category
+     */
+    public final void testMediaCategory() {
+
+        HashAttributeSet aset = new HashAttributeSet();
+
+        MediaSizeName msn = MediaSizeName.ISO_A3;
+        aset.add(msn);
+        assertEquals(msn, aset.get(Media.class));
+        assertNull(aset.get(MediaSizeName.class));
+
+        MediaTray mt = MediaTray.BOTTOM;
+        aset.add(mt);
+        assertEquals(mt, aset.get(Media.class));
+        assertNull(aset.get(MediaTray.class));
+
+        MediaName mn = MediaName.ISO_A4_WHITE;
+        aset.add(mn);
+        assertEquals(mn, aset.get(Media.class));
+        assertNull(aset.get(MediaName.class));
+    }
+
+
+    /*
+     * Auxiliary class
+     */
+    public class media extends Media {
+
+        public media(int value) {
+            super(value);
+        }
+    }
+
+    /*
+     * Auxiliary class
+     */
+    public class mediaName extends MediaName {
+
+        public mediaName(int value) {
+            super(value);
+        }
+    }
+
+    /*
+     * Auxiliary class
+     */
+    public class mediaTray extends MediaTray {
+
+        public mediaTray(int value) {
+            super(value);
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/MediaTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/PrinterStateReasonTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/PrinterStateReasonTest.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/PrinterStateReasonTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/PrinterStateReasonTest.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,117 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Elena V. Sayapina 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print.attribute.standard;
+
+import javax.print.attribute.EnumSyntax;
+
+import junit.framework.TestCase;
+
+
+/*
+ * @author esayapin
+ */
+
+public class PrinterStateReasonTest extends TestCase {
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(PrinterStateReasonTest.class);
+    }
+    
+    static {
+        System.out.println("PrinterStateReason testing...");
+    }
+
+
+    printerStateReason reason;
+
+
+    /*
+     * JobStateReason constructor testing.
+     */
+    public final void testFinishings() {
+
+        reason = new printerStateReason(0);
+        assertEquals(0, reason.getValue());
+
+        reason = new printerStateReason(300);
+        assertEquals(300, reason.getValue());
+        assertEquals("300", reason.toString());
+    }
+
+    /*
+     * getEnumValueTable(), getStringTable() methods testing.
+     */
+    public final void testGetStringTable() {
+
+        int quantity = 0;
+        reason = new printerStateReason(1);
+        String[] str = reason.getStringTableEx();
+        EnumSyntax[] table = reason.getEnumValueTableEx();
+        assertEquals(str.length, table.length);
+        assertEquals(33, table.length);
+
+        //Tests that StringTable isn't changed for PrinterStateReason
+        str = reason.getStringTableEx();
+        str[1] = "reason1";
+        //System.out.println(reason.getStringTable()[1]);
+        assertFalse(reason.getStringTableEx()[1].equals("reason1"));
+    }
+
+    /*
+     * getCategory() method testing.
+     */
+    public final void testGetCategory() {
+        PrinterStateReason r = PrinterStateReason.DEVELOPER_LOW;
+        assertEquals(PrinterStateReason.class, r.getCategory());
+    }
+
+    /*
+     * getName() method testing.
+     */
+    public final void testGetName() {
+        PrinterStateReason r = PrinterStateReason.COVER_OPEN;
+        assertEquals("printer-state-reason", r.getName());
+    }
+
+
+    /*
+     * Auxiliary class
+     */
+    public class printerStateReason extends PrinterStateReason {
+
+        public printerStateReason(int value) {
+            super(value);
+        }
+
+        public String[] getStringTableEx() {
+            return getStringTable();
+        }
+
+        public EnumSyntax[] getEnumValueTableEx() {
+            return getEnumValueTable();
+        }
+    }
+
+
+}
+
+
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/PrinterStateReasonTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/PrinterStateReasonsTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/PrinterStateReasonsTest.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/PrinterStateReasonsTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/PrinterStateReasonsTest.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,190 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/** 
+ * @author Elena V. Sayapina 
+ * @version $Revision: 1.3 $ 
+ */ 
+
+package javax.print.attribute.standard;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+
+public class PrinterStateReasonsTest extends TestCase {
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(PrinterStateReasonsTest.class);
+    }
+
+    static {
+        System.out.println("PrinterStateReasons testing...");
+    }
+
+    PrinterStateReasons reasons;
+
+    /*
+     * PrinterStateReasons() constructor testing. 
+     */
+    public final void testPrinterStateReasons() {
+        reasons = new PrinterStateReasons();
+        assertEquals(0, reasons.size());
+    }
+
+    /*
+     * PrinterStateReasons(int initialCapacity) constructor testing. 
+     */
+    public final void testPrinterStateReasonsint() {
+        try {
+            reasons = new PrinterStateReasons(-1);
+            fail("Constructor doesn't throw IllegalArgumentException if " +
+            "initialCapacity < 0");
+        } catch (IllegalArgumentException e) {
+        }
+    }
+
+    /*
+     * PrinterStateReasons(Map map) constructor testing. 
+     */
+    public final void testPrinterStateReasonsMap() {
+        HashMap map = new HashMap();
+        map.put(PrinterStateReason.TONER_LOW, Severity.WARNING);
+        map.put(PrinterStateReason.DEVELOPER_LOW, Severity.WARNING);
+        map.put(PrinterStateReason.MEDIA_LOW, Severity.ERROR);
+        reasons = new PrinterStateReasons(map);
+
+        assertEquals(3, reasons.size());
+        assertTrue(reasons.containsKey(PrinterStateReason.TONER_LOW));
+        assertTrue(reasons.containsKey(PrinterStateReason.DEVELOPER_LOW));
+        assertTrue(reasons.containsKey(PrinterStateReason.MEDIA_LOW));
+
+        try {
+            map = new HashMap();
+            map.put(PrinterStateReason.MEDIA_LOW, PrinterState.IDLE);
+            reasons = new PrinterStateReasons(map);
+            fail("Constructor doesn't throw ClassCastException if " +
+                    "some value in the map isn't Severity");
+        } catch (ClassCastException e) {
+        }
+
+        try {
+            map = new HashMap();
+            map.put(PrinterState.IDLE, Severity.ERROR);
+            reasons = new PrinterStateReasons(map);
+            fail("Constructor doesn't throw ClassCastException if " +
+                    "some key in the map isn't PrinterStateReason");
+        } catch (ClassCastException e) {
+        }
+
+        try {
+            map = new HashMap();
+            Severity severity = null;
+            map.put(PrinterStateReason.COVER_OPEN, severity);
+            reasons = new PrinterStateReasons(map);
+            fail("Constructor doesn't throw NullPointerException if " +
+                    "some key in the map is null");
+        } catch (NullPointerException e) {
+        }
+
+        try {
+            map.put(null, Severity.REPORT);
+            reasons = new PrinterStateReasons(map);
+            fail("Constructor doesn't throw NullPointerException if " +
+                    "some value in the map is null");
+        } catch (NullPointerException e) {
+        }
+
+        try {
+            map = null;
+            reasons = new PrinterStateReasons(map);
+            fail("Constructor doesn't throw NullPointerException if " +
+                    "map is null");
+        } catch (NullPointerException e) {
+        }
+
+    }
+
+    /*
+     * getCategory() method testing.
+     */
+    public final void testGetCategory() {
+        reasons = new PrinterStateReasons();
+        assertEquals(PrinterStateReasons.class, reasons.getClass());
+    }
+
+    /*
+     * getName() method testing.
+     */
+    public final void testGetName() {
+        reasons = new PrinterStateReasons();
+        assertEquals("printer-state-reasons", reasons.getName());
+    }
+
+    /*
+     * put(PrinterStateReason reason, Severity severity) method testing.
+     */
+    public final void testPutPrinterStateReasonSeverity() {
+
+        try {
+            reasons = new PrinterStateReasons();
+            reasons.put(PrinterStateReason.MEDIA_LOW, PrintQuality.DRAFT);
+            fail("Metho doesn't throw ClassCastException if " +
+                    "adding value isn't Severity");
+        } catch (ClassCastException e) {
+        }
+    }
+
+    /*
+     * printerStateReasonSet(Severity severity) method testing.
+     */
+    public final void testPrinterStateReasonSet() {
+        reasons = new PrinterStateReasons();
+        reasons.put(PrinterStateReason.MEDIA_LOW, Severity.ERROR);
+        HashSet set = new HashSet();
+        set.add(PrinterStateReason.MEDIA_LOW);
+        assertEquals(set, reasons.printerStateReasonSet(Severity.ERROR));
+        set = new HashSet();
+        assertEquals(set, reasons.printerStateReasonSet(Severity.REPORT));
+    }
+
+    /*
+     * printerStateReasonSet(Severity severity) method testing.
+     */
+    public final void testPrinterStateReasonSet1() {
+        reasons = new PrinterStateReasons();
+        reasons.put(PrinterStateReason.COVER_OPEN, Severity.ERROR);
+        reasons.put(PrinterStateReason.MEDIA_LOW, Severity.WARNING);
+        reasons.put(PrinterStateReason.DOOR_OPEN, Severity.ERROR);
+        reasons.put(PrinterStateReason.INPUT_TRAY_MISSING, Severity.ERROR);
+
+        Set set = reasons.printerStateReasonSet(Severity.ERROR);
+        try {
+            set.iterator().remove();
+            fail("Unmodifiable set was changed");
+        } catch (UnsupportedOperationException e) {
+        }
+
+        try {
+            set.add(PrinterStateReason.COVER_OPEN);
+            fail("Unmodifiable set was changed");
+        } catch (UnsupportedOperationException e) {
+
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/print/src/test/api/java/common/javax/print/attribute/standard/PrinterStateReasonsTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/swing/src/main/java/common/javax/swing/JApplet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/swing/src/main/java/common/javax/swing/JApplet.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/swing/src/main/java/common/javax/swing/JApplet.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/swing/src/main/java/common/javax/swing/JApplet.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,174 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Vadim L. Bogdanov
+ * @version $Revision: 1.1 $
+ */
+
+package javax.swing;
+
+import java.applet.Applet;
+
+import java.awt.AWTEvent;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Graphics;
+import java.awt.HeadlessException;
+import java.awt.KeyboardFocusManager;
+import java.awt.LayoutManager;
+
+import javax.accessibility.Accessible;
+import javax.accessibility.AccessibleContext;
+
+public class JApplet extends Applet implements Accessible, RootPaneContainer {
+    protected JRootPane rootPane;
+    protected boolean rootPaneCheckingEnabled;
+    protected AccessibleContext accessibleContext;
+
+    public JApplet() throws HeadlessException {
+        setLayout(new BorderLayout());
+
+        setRootPaneCheckingEnabled(true);
+
+        setRootPane(createRootPane());
+
+        setLocale(JComponent.getDefaultLocale());
+
+        setBackground(Color.white);
+
+        // enable events
+        enableEvents(AWTEvent.KEY_EVENT_MASK);
+
+        setFocusTraversalPolicyProvider(true);
+
+        setFocusTraversalPolicy(KeyboardFocusManager.
+                getCurrentKeyboardFocusManager().
+                getDefaultFocusTraversalPolicy());
+    }
+
+    protected class AccessibleJApplet extends AccessibleApplet {
+        protected AccessibleJApplet() {
+        }
+    }
+
+    protected void addImpl(final Component comp, final Object constraints,
+                           final int index) {
+        if (isRootPaneCheckingEnabled()) {
+            getContentPane().add(comp, constraints, index);
+            return;
+        }
+
+        super.addImpl(comp, constraints, index);
+    }
+
+    protected void setRootPane(final JRootPane root) {
+        if (rootPane != null) {
+            remove(rootPane);
+        }
+
+        rootPane = root;
+
+        if (root != null) {
+            super.addImpl(root, null, 0);
+        }
+    }
+
+    public JRootPane getRootPane() {
+        return rootPane;
+    }
+
+    protected JRootPane createRootPane() {
+        return new JRootPane();
+    }
+
+    public void setJMenuBar(final JMenuBar menuBar) {
+        getRootPane().setJMenuBar(menuBar);
+    }
+
+    public JMenuBar getJMenuBar() {
+        return getRootPane().getJMenuBar();
+    }
+
+    public void setLayeredPane(final JLayeredPane layeredPane) {
+        getRootPane().setLayeredPane(layeredPane);
+    }
+
+    public JLayeredPane getLayeredPane() {
+        return getRootPane().getLayeredPane();
+    }
+
+    public AccessibleContext getAccessibleContext() {
+        if (accessibleContext == null) {
+            accessibleContext = new AccessibleJApplet();
+        }
+
+        return accessibleContext;
+    }
+
+    public void setLayout(final LayoutManager layout) {
+        if (isRootPaneCheckingEnabled()) {
+            getContentPane().setLayout(layout);
+        } else {
+            super.setLayout(layout);
+        }
+    }
+
+    /**
+     * Just calls paint(g). This method was overridden to prevent
+     * an unnecessary call to clear the background.
+     *
+     * @param g - the graphics context to paint
+     */
+    public void update(final Graphics g) {
+        paint(g);
+    }
+
+    public void setContentPane(final Container contentPane) {
+        getRootPane().setContentPane(contentPane);
+    }
+
+    public Container getContentPane() {
+        return getRootPane().getContentPane();
+    }
+
+    public void setGlassPane(final Component glassPane) {
+        getRootPane().setGlassPane(glassPane);
+    }
+
+    public void remove(final Component comp) {
+        if (comp == getRootPane()) {
+            // remove directly from JApplet
+            super.remove(comp);
+        } else {
+            getContentPane().remove(comp);
+        }
+    }
+
+    public Component getGlassPane() {
+        return getRootPane().getGlassPane();
+    }
+
+    protected void setRootPaneCheckingEnabled(final boolean enabled) {
+        rootPaneCheckingEnabled = enabled;
+    }
+
+    protected boolean isRootPaneCheckingEnabled() {
+        return rootPaneCheckingEnabled;
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/swing/src/main/java/common/javax/swing/JApplet.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/swing/src/test/api/java.injected/javax/swing/JAppletTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/swing/src/test/api/java.injected/javax/swing/JAppletTest.java?view=auto&rev=454289
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/swing/src/test/api/java.injected/javax/swing/JAppletTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/swing/src/test/api/java.injected/javax/swing/JAppletTest.java Sun Oct  8 22:33:09 2006
@@ -0,0 +1,448 @@
+/*
+ *  Copyright 2005 - 2006 The Apache Software Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Vadim L. Bogdanov
+ * @version $Revision: 1.1 $
+ */
+
+package javax.swing;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.FlowLayout;
+import java.awt.IllegalComponentStateException;
+import java.awt.KeyboardFocusManager;
+import java.awt.LayoutManager;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import javax.accessibility.AccessibleContext;
+import javax.accessibility.AccessibleRole;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class JAppletTest extends SwingTestCase {
+    /*
+     * This class is used to test protected methods
+     */
+    private static class TestApplet extends JApplet {
+        public static boolean createRootPaneCalled = false;
+        public static boolean setRootPaneCalled = false;
+
+        public JRootPane createRootPane() {
+            createRootPaneCalled = true;
+            return super.createRootPane();
+        }
+
+        public void setRootPane(final JRootPane root) {
+            setRootPaneCalled = true;
+            super.setRootPane(root);
+        }
+
+        public void setRootPaneCheckingEnabled(final boolean enabled) {
+            super.setRootPaneCheckingEnabled(enabled);
+        }
+
+        public boolean isRootPaneCheckingEnabled() {
+            return super.isRootPaneCheckingEnabled();
+        }
+
+        public void addImpl(final Component comp, final Object constraints, final int index) {
+            super.addImpl(comp, constraints, index);
+        }
+
+        public static void initStaticVars() {
+            createRootPaneCalled = false;
+            setRootPaneCalled = false;
+        }
+
+        public String paramString() {
+            return super.paramString();
+        }
+    }
+
+    private JApplet applet;
+
+    /*
+     * This class is used to test that some property is (or is not) a bound property
+     */
+    private class MyPropertyChangeListener implements PropertyChangeListener {
+        public boolean ok;
+
+        MyPropertyChangeListener() {
+            ok = false;
+        }
+
+        public void propertyChange(final PropertyChangeEvent e) {
+            ok = true;
+        }
+    }
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(JAppletTest.class);
+        return suite;
+    }
+
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        applet = new JApplet();
+        TestApplet.initStaticVars();
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    /**
+     * Constructor for JAppletTest.
+     * @param name
+     */
+    public JAppletTest(final String name) {
+        super(name);
+    }
+
+    /*
+     * Class under test for void JApplet()
+     */
+    public void testJApplet() {
+        TestApplet applet = new TestApplet();
+
+        assertTrue("rootPaneCheckingEnabled is true", applet.isRootPaneCheckingEnabled());
+
+        assertTrue("layout is not null", applet.getLayout() != null);
+        assertTrue("layout is BorderLayout", applet.getLayout() instanceof BorderLayout);
+
+        assertTrue("rootPane is not null", applet.getRootPane() != null);
+
+        assertTrue("locale is set", applet.getLocale() == JComponent.getDefaultLocale());
+
+        assertTrue("background is set", applet.isBackgroundSet());
+        assertTrue("background is set to white", applet.getBackground() == java.awt.Color.white);
+
+        assertTrue("rootPane.windowDecorationStyle is NONE",
+                applet.getRootPane().getWindowDecorationStyle() == JRootPane.NONE);
+
+        // test that defaultFocusTraversalPolicy is set
+        assertTrue("focusTraversalPolicy is set",
+                   applet.isFocusTraversalPolicySet());
+        assertTrue("focusTraversalPolicy is set correctly",
+                applet.getFocusTraversalPolicy() == KeyboardFocusManager.
+                    getCurrentKeyboardFocusManager().getDefaultFocusTraversalPolicy());
+        assertFalse(applet.isFocusCycleRoot());
+        assertTrue(applet.isFocusTraversalPolicyProvider());
+    }
+
+    /*
+     * Class under test for
+     *     void setRootPaneCheckingEnabled(boolean enabled)
+     *     boolean isRootPaneCheckingEnabled()
+     */
+    public void testSetIsRootPaneCheckingEnabled() {
+        TestApplet applet = new TestApplet();
+
+        assertTrue("rootPaneCheckingEnabled is true by default", applet.isRootPaneCheckingEnabled());
+
+        applet.setRootPaneCheckingEnabled(false);
+        assertFalse("rootPaneCheckingEnabled is set to false", applet.isRootPaneCheckingEnabled());
+    }
+
+    /*
+     * Class under test for void addImpl(Component, Object, int)
+     */
+    public void testAddImpl() {
+        TestApplet applet = new TestApplet();
+        JComponent comp = new JPanel();
+
+        // rootPaneCheckingEnabled is true, no exception since 1.5
+        applet.setRootPaneCheckingEnabled(true);
+        boolean ok = false;
+        try {
+            applet.addImpl(comp, null, 0);
+        } catch (Error e) {
+            ok = true;
+        } finally {
+            assertFalse("no exception", ok);
+            assertTrue("The component is added to contentPane",
+                       comp.getParent() == applet.getContentPane());
+        }
+
+        // rootPaneCheckingEnabled is false, no exception
+        applet.setRootPaneCheckingEnabled(false);
+        ok = false;
+        try {
+            applet.addImpl(comp, null, 0);
+        } catch (Error e) {
+            ok = true;
+        } finally {
+            assertFalse("no exception", ok);
+            assertTrue("the component is added to JWindow",
+                       comp.getParent() == applet);
+            assertTrue("index of the component is 0",
+                       applet.getComponent(0) == comp);
+        }
+    }
+
+    /*
+     * Class under test for
+     *     void setRootPane(JRootPane)
+     *     JRootPane getRootPane()
+     */
+    public void testSetGetRootPane() {
+        TestApplet applet = new TestApplet();
+        assertTrue("setRootPane() is called from the constructor",
+                TestApplet.setRootPaneCalled);
+
+        MyPropertyChangeListener listener = new MyPropertyChangeListener();
+        applet.addPropertyChangeListener("rootPane", listener);
+        JRootPane root = new JRootPane();
+        applet.setRootPane(root);
+        assertTrue(applet.getRootPane() == root);
+        assertFalse("rootPane is not a bound property", listener.ok);
+
+        // test setting rootPane to null
+        applet.setRootPane(null);
+        assertTrue(applet.getRootPane() == null);
+        assertTrue("rootPane is removed from the container", applet.getComponentCount() == 0);
+    }
+
+    /*
+     * Class under test for JRootPane createRootPane()
+     */
+    public void testCreateRootPane() {
+        TestApplet applet = new TestApplet();
+        assertTrue("createRootPane() is called from the constructor",
+                TestApplet.createRootPaneCalled);
+
+        JRootPane root = applet.createRootPane();
+        assertTrue("createRootPane() cannot return null", root != null);
+    }
+
+    /*
+     * Class under test for
+     *     void setJMenuBar(JMenuBar)
+     *     JMenuBar getJMenuBar()
+     */
+    public void testSetGetJMenuBarJMenuBar() {
+        assertEquals(null, applet.getJMenuBar());
+
+        JMenuBar menuBar = new JMenuBar();
+        applet.setJMenuBar(menuBar);
+        assertTrue(applet.getJMenuBar() == menuBar);
+
+        applet.setJMenuBar(null);
+        assertTrue(applet.getJMenuBar() == null);
+    }
+
+    /*
+     * Class under test for
+     *     void setLayeredPane(JLayeredPane)
+     *     JLayeredPane getLayeredPane()
+     */
+    public void testSetGetLayeredPane() {
+        MyPropertyChangeListener listener = new MyPropertyChangeListener();
+        applet.addPropertyChangeListener("layeredPane", listener);
+
+        JLayeredPane pane = new JLayeredPane();
+        applet.setLayeredPane(pane);
+        assertTrue(applet.getLayeredPane() == pane);
+        assertFalse("layeredPane is not a bound property", listener.ok);
+
+        // test throwing exception if the parameter is null
+        boolean ok = false;
+        try {
+            applet.setLayeredPane(null);
+        } catch (IllegalComponentStateException e) {
+            ok = true;
+        } finally {
+            assertEquals(true, ok);
+        }
+        // layeredPane cannot be null, even after setLayeredPane(null)
+        assertTrue(applet.getLayeredPane() != null);
+
+        // setLayeredPane() method is not called by the constructor
+        // (seems that there is an error in docs)
+    }
+
+    /*
+     * Class under test for AccessibleContext getAccessibleContext()
+     */
+    public void testGetAccessibleContext() {
+        AccessibleContext c = applet.getAccessibleContext();
+
+        assertTrue("instance of AccessibleJApplet",
+                   c instanceof JApplet.AccessibleJApplet);
+        assertTrue("AccessibleRole is ok",
+                c.getAccessibleRole() == AccessibleRole.FRAME);
+        assertTrue("AccessibleName is ok", c.getAccessibleName() == null);
+        assertTrue("AccessibleDescription is ok",
+                c.getAccessibleDescription() == null);
+        assertTrue("AccessibleChildrenCount == 1",
+                   c.getAccessibleChildrenCount() == 1);
+    }
+
+    /*
+     * Class under test for String paramString()
+     */
+    public void testParamString() {
+        TestApplet applet = new TestApplet();
+        assertTrue("paramString() cannot return null", applet.paramString() != null);
+    }
+
+    /*
+     * Class under test for void setLayout(LayoutManager)
+     */
+    public void testSetLayout() {
+        TestApplet applet = new TestApplet();
+        LayoutManager contentLayout = applet.getContentPane().getLayout();
+        LayoutManager appletLayout = applet.getLayout();
+
+        // rootPaneCheckingEnabled is true, no exception since 1.5
+        applet.setRootPaneCheckingEnabled(true);
+        boolean ok = false;
+        try {
+            applet.setLayout(new FlowLayout());
+        } catch (Error e) {
+            ok = true;
+        } finally {
+            assertFalse("no exception since 1.5", ok);
+            assertTrue("contentPane layout is changed",
+                       applet.getContentPane().getLayout() != contentLayout);
+            assertTrue("Applet layout shouldn't be changed",
+                       applet.getLayout() == appletLayout);
+            applet.getContentPane().setLayout(contentLayout);
+        }
+
+        // rootPaneCheckingEnabled is false, exception may not be thrown
+        applet.setRootPaneCheckingEnabled(false);
+        ok = false;
+        try {
+            applet.setLayout(new FlowLayout());
+        } catch (Error e) {
+            ok = true;
+        } finally {
+            assertFalse("no exception", ok);
+            assertTrue("contentPane layout shouldn't be changed",
+                       applet.getContentPane().getLayout() == contentLayout);
+            assertTrue("Applet layout is changed",
+                       applet.getLayout() != appletLayout);
+        }
+    }
+
+    /*
+     * Class under test for void update(Graphics)
+     */
+    public void testUpdate() {
+        // Note: painting code, cannot test
+    }
+
+    /*
+     * Class under test for
+     *     void setContentPane(Container)
+     *     Container getContentPane()
+     */
+    public void testSetGetContentPane() {
+        MyPropertyChangeListener listener = new MyPropertyChangeListener();
+        applet.addPropertyChangeListener("contentPane", listener);
+
+        JPanel pane = new JPanel();
+        applet.setContentPane(pane);
+        assertTrue(applet.getContentPane() == pane);
+        assertFalse("contentPane is not a bound property", listener.ok);
+
+        // test throwing exception if the parameter is null
+        boolean ok = false;
+        try {
+            applet.setContentPane(null);
+        } catch (IllegalComponentStateException e) {
+            ok = true;
+        } finally {
+            assertEquals(true, ok);
+        }
+        // contentPane cannot be null, even after setContentPane(null)
+        assertTrue(applet.getContentPane() != null);
+
+        // setContentPane() method is not called by the constructor
+        // (seems that there is an error in docs)
+    }
+
+    /*
+     * Class under test for
+     *     void setGlassPane(Component)
+     *     Component getGlassPane()
+     */
+    public void testSetGetGlassPane() {
+        MyPropertyChangeListener listener = new MyPropertyChangeListener();
+        applet.addPropertyChangeListener("glassPane", listener);
+
+        JPanel pane = new JPanel();
+        applet.setGlassPane(pane);
+        assertTrue(applet.getGlassPane() == pane);
+        assertFalse("glassPane is not a bound property", listener.ok);
+
+        // test throwing exception if the parameter is null
+        boolean ok = false;
+        try {
+            applet.setGlassPane(null);
+        } catch (NullPointerException e) {
+            ok = true;
+        } finally {
+            assertEquals(true, ok);
+        }
+        // glassPane cannot be null, even after setGlassPane(null)
+        assertTrue(applet.getGlassPane() != null);
+
+        // setGlassPane() method is not called by the constructor
+        // (seems that there is an error in docs)
+    }
+
+    /*
+     * Class under test for void remove(Component)
+     */
+    public void testRemove() {
+        JComponent comp = new JPanel();
+        applet.getContentPane().add(comp);
+        assertTrue("label is in contentPane", applet.isAncestorOf(comp));
+        applet.remove(comp);
+        assertFalse("label is removed from contentPane", applet.isAncestorOf(comp));
+
+        ((JPanel)applet.getGlassPane()).add(comp);
+        applet.remove(comp);
+        assertTrue("label is not removed from glassPane", applet.isAncestorOf(comp));
+
+        // test removing directly from the container
+        applet.setRootPaneCheckingEnabled(false);
+        applet.add(comp, BorderLayout.EAST);
+        assertTrue("added", comp.getParent() == applet);
+        applet.remove(comp);
+        assertTrue("not removed", comp.getParent() == applet);
+
+        // test removing rootPane
+        assertTrue(applet.isAncestorOf(applet.getRootPane()));
+        applet.remove(applet.getRootPane());
+        // rootPane is removed from the container
+        assertFalse(applet.isAncestorOf(applet.getRootPane()));
+        // but getRootPane() still returns it
+        assertTrue(applet.getRootPane() != null);
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/H-1609/modules/swing/src/test/api/java.injected/javax/swing/JAppletTest.java
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message