harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r462760 - /incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/LookAndFeelTest.java
Date Wed, 11 Oct 2006 10:36:45 GMT
Author: hindessm
Date: Wed Oct 11 03:36:44 2006
New Revision: 462760

URL: http://svn.apache.org/viewvc?view=rev&rev=462760
Log:
Use junit for exception handling to make tests easier to read.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/LookAndFeelTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/LookAndFeelTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/LookAndFeelTest.java?view=diff&rev=462760&r1=462759&r2=462760
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/LookAndFeelTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/LookAndFeelTest.java
Wed Oct 11 03:36:44 2006
@@ -212,66 +212,49 @@
         assertFalse(lf.getSupportsWindowDecorations());
     }
 
-    public void testInstallProperty() {
+    public void testInstallProperty() throws Exception {
         if (!isHarmony()) {
             return;
         }
         JComponent comp1 = new JPanel();
         JButton comp2 = new JButton();
 
-        try {
-            LookAndFeel.installProperty(comp1, "opaque", Boolean.TRUE);
-            assertEquals("opaque", true, comp1.isOpaque());
-            LookAndFeel.installProperty(comp1, "opaque", Boolean.FALSE);
-            assertEquals("opaque", false, comp1.isOpaque());
-            comp1.setOpaque(true);
-            LookAndFeel.installProperty(comp1, "opaque", Boolean.FALSE);
-            assertEquals("opaque", true, comp1.isOpaque());
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-        try {
-            LookAndFeel.installProperty(comp2, "opaque", Boolean.TRUE);
-            assertEquals("opaque", true, comp2.isOpaque());
-            LookAndFeel.installProperty(comp2, "opaque", Boolean.FALSE);
-            assertEquals("opaque", false, comp2.isOpaque());
-            comp1.setOpaque(true);
-            LookAndFeel.installProperty(comp2, "opaque", Boolean.FALSE);
-            assertEquals("opaque", false, comp2.isOpaque());
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
+        LookAndFeel.installProperty(comp1, "opaque", Boolean.TRUE);
+        assertEquals("opaque", true, comp1.isOpaque());
+        LookAndFeel.installProperty(comp1, "opaque", Boolean.FALSE);
+        assertEquals("opaque", false, comp1.isOpaque());
+        comp1.setOpaque(true);
+        LookAndFeel.installProperty(comp1, "opaque", Boolean.FALSE);
+        assertEquals("opaque", true, comp1.isOpaque());
+
+        LookAndFeel.installProperty(comp2, "opaque", Boolean.TRUE);
+        assertEquals("opaque", true, comp2.isOpaque());
+        LookAndFeel.installProperty(comp2, "opaque", Boolean.FALSE);
+        assertEquals("opaque", false, comp2.isOpaque());
+        comp1.setOpaque(true);
+        LookAndFeel.installProperty(comp2, "opaque", Boolean.FALSE);
+        assertEquals("opaque", false, comp2.isOpaque());
 
-        boolean thrown = false;
         try {
             LookAndFeel.installProperty(comp1, "iconTextGap", Boolean.TRUE);
-        } catch (Throwable e) {
-            thrown = true;
-            assertTrue("exception of proper type is thrown", e instanceof IllegalArgumentException);
+            fail("IllegalArgumentException shall be thrown");
+        } catch (IllegalArgumentException e) {
+            // expected
         }
-        assertTrue("exception is thrown", thrown);
 
-        thrown = false;
         try {
             LookAndFeel.installProperty(comp2, "iconTextGap", Boolean.TRUE);
-        } catch (Throwable e) {
-            thrown = true;
-            assertTrue("exception of proper type is thrown", e instanceof ClassCastException);
-        }
-        assertTrue("exception is thrown", thrown);
-
-        try {
-            LookAndFeel.installProperty(comp2, "iconTextGap", new Integer(0));
-            assertEquals("iconTextGap", 0, comp2.getIconTextGap());
-            LookAndFeel.installProperty(comp2, "iconTextGap", new Integer(120));
-            assertEquals("iconTextGap", 120, comp2.getIconTextGap());
-            comp2.setIconTextGap(300);
-            LookAndFeel.installProperty(comp2, "iconTextGap", new Integer(120));
-            assertEquals("iconTextGap", 300, comp2.getIconTextGap());
-        } catch (Exception e) {
-            fail(e.getMessage());
+            fail("ClassCastException shall be thrown");
+        } catch (ClassCastException e) {
+            // expected
         }
 
+        LookAndFeel.installProperty(comp2, "iconTextGap", new Integer(0));
+        assertEquals("iconTextGap", 0, comp2.getIconTextGap());
+        LookAndFeel.installProperty(comp2, "iconTextGap", new Integer(120));
+        assertEquals("iconTextGap", 120, comp2.getIconTextGap());
+        comp2.setIconTextGap(300);
+        LookAndFeel.installProperty(comp2, "iconTextGap", new Integer(120));
+        assertEquals("iconTextGap", 300, comp2.getIconTextGap());
     }
 }



Mime
View raw message