harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r417793 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/java/beans/beancontext: BeanContextServicesSupportTest.java BeanContextSupportTest.java
Date Wed, 28 Jun 2006 15:34:25 GMT
Author: mloenko
Date: Wed Jun 28 08:34:24 2006
New Revision: 417793

URL: http://svn.apache.org/viewvc?rev=417793&view=rev
Log:
removing redundant 'try...catch' blocks, replace 'if...fail' with assertXXX, removing unused variables

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java?rev=417793&r1=417792&r2=417793&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/java/beans/beancontext/BeanContextServicesSupportTest.java Wed Jun 28 08:34:24 2006
@@ -65,13 +65,7 @@
      * BeanContextServices, Locale, boolean, boolean)
      */
     public void testConstructorBeanContextServicesLocalebooleanboolean() {
-        try {
-            BeanContextServicesSupport sup = 
-                new BeanContextServicesSupport(null, null, true, true);
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        new BeanContextServicesSupport(null, null, true, true);
     }
 
     /** 
@@ -81,13 +75,7 @@
      * BeanContextServices, Locale, boolean)
      */
     public void testConstructorBeanContextServicesLocaleboolean() {
-        try {
-            BeanContextServicesSupport sup = 
-                new BeanContextServicesSupport(null, null, true);
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        new BeanContextServicesSupport(null, null, true);
     }
 
     /** 
@@ -97,13 +85,7 @@
      * BeanContextServices, Locale)
      */
     public void testConstructorBeanContextServicesLocale() {
-        try {
-            BeanContextServicesSupport sup = 
-                new BeanContextServicesSupport(null, null);
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        new BeanContextServicesSupport(null, null);
     }
 
     /** 
@@ -113,13 +95,7 @@
      * BeanContextServices)
      */
     public void testConstructorBeanContextServices() {
-        try {
-            BeanContextServicesSupport sup = 
-                new BeanContextServicesSupport(null);
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        new BeanContextServicesSupport(null);
     }
 
     /** * Test constructor with no parameters.<p>
@@ -127,12 +103,7 @@
      * @see BeanContextServicesSupport#BeanContextServicesSupport()
      */
     public void testConstructor() {
-        try {
-            BeanContextServicesSupport sup = new BeanContextServicesSupport();
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        new BeanContextServicesSupport();
     }
 
     /** TEST METHODS **/
@@ -141,146 +112,89 @@
      * Test method createBCSChild() with Object, Object parameters.<p>
      */
     public void testCreateBCSChildObjectObject() {
-        try {
-            
-            // Just call the method
-            BeanContextServicesSupport sup = new BeanContextServicesSupport();
-            sup.createBCSChild(new Object(), new Object());
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Just call the method
+        BeanContextServicesSupport sup = new BeanContextServicesSupport();
+        sup.createBCSChild(new Object(), new Object());
     }
 
     /**
      * Test method addService() with Class, BeanContextServiceProvider, boolean parameters.<p>
      */
     public void testAddServiceClassBeanContextServiceProviderboolean() {
-        try {
-            
-            // Instantiate services and add service
-            BeanContextServicesSupport sup = new BeanContextServicesSupport();
-            sup.addService(Object.class, getProvider(), true);
-            
-            if (sup.services.size() != 1) {
-                fail("One service should be registered");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Instantiate services and add service
+        BeanContextServicesSupport sup = new BeanContextServicesSupport();
+        sup.addService(Object.class, getProvider(), true);
+
+        assertEquals("One service should be registered", 1, sup.services.size());
     }
 
     /**
      * Test method revokeService() with Class, BeanContextServiceProvider, boolean parameters.<p>
      */
     public void testRevokeServiceClassBeanContextServiceProviderboolean() {
-        try {
-            
-            // Instantiate services, add and remove service
-            BeanContextServicesSupport sup = new BeanContextServicesSupport();
-            BeanContextServiceProvider pr = getProvider();
-            sup.addService(Object.class, pr, true);
-            sup.revokeService(Object.class, pr, true);
-            
-            if (sup.services.size() != 0) {
-                fail("No service should be registered");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Instantiate services, add and remove service
+        BeanContextServicesSupport sup = new BeanContextServicesSupport();
+        BeanContextServiceProvider pr = getProvider();
+        sup.addService(Object.class, pr, true);
+        sup.revokeService(Object.class, pr, true);
+
+        assertEquals("No service should be registered", 0, sup.services.size());
     }
 
     /**
      * Test method addService() with Class, BeanContextServiceProvider parameters.<p>
      */
     public void testAddServiceClassBeanContextServiceProvider() {
-        try {
-            
-            // Instantiate services and add service
-            BeanContextServicesSupport sup = new BeanContextServicesSupport();
-            sup.addService(Object.class, getProvider());
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Instantiate services and add service
+        BeanContextServicesSupport sup = new BeanContextServicesSupport();
+        sup.addService(Object.class, getProvider());
     }
 
     /**
      * Test method hasService() with Class parameter.<p>
      */
     public void testHasServiceClass() {
-        try {
-            
-            // Instantiate services and add service
-            BeanContextServicesSupport sup = new BeanContextServicesSupport();
-            Class cl = new Object().getClass();
-            sup.addService(cl, getProvider(), true);
-            
-            if (!sup.hasService(cl)) {
-                fail("Service not found");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Instantiate services and add service
+        BeanContextServicesSupport sup = new BeanContextServicesSupport();
+        Class cl = new Object().getClass();
+        sup.addService(cl, getProvider(), true);
+
+        assertTrue("Service not found", sup.hasService(cl));
     }
 
     /**
      * Test method getBeanContextServicesPeer() with no parameters.<p>
      */
     public void testGetBeanContextServicesPeer() {
-        try {
-            
-            // Instantiate services
-            BeanContextServicesSupport sup = new BeanContextServicesSupport();
-            
-            if (!sup.getBeanContextServicesPeer().equals(sup)) {
-                fail("The objects are not equal");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Instantiate services
+        BeanContextServicesSupport sup = new BeanContextServicesSupport();
+
+        assertTrue("The objects are not equal", sup
+                .getBeanContextServicesPeer().equals(sup));
     }
 
     /**
      * Test method releaseBeanContextResources() with no parameters.<p>
      */
     public void testReleaseBeanContextResources() {
-        try {
-            
-            // Instantiate services
-            BeanContextServicesSupport sup = new BeanContextServicesSupport();
-            sup.releaseBeanContextResources();
-            
-            if (sup.proxy != null) {
-                fail("The resources are not released");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Instantiate services
+        BeanContextServicesSupport sup = new BeanContextServicesSupport();
+        sup.releaseBeanContextResources();
+
+        assertNull("The resources are not released", sup.proxy);
     }
 
     /**
      * Test method initializeBeanContextResources() with no parameters.<p>
      */
     public void testInitializeBeanContextResources() {
-        try {
-            
-            // Instantiate services
-            BeanContextServicesSupport sup = new BeanContextServicesSupport();
-            sup.initializeBeanContextResources();
-            
-            //if (sup.proxy == null) {
-                //fail("The resources are not initialized");
-            //}
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Instantiate services
+        BeanContextServicesSupport sup = new BeanContextServicesSupport();
+        sup.initializeBeanContextResources();
+
+        //if (sup.proxy == null) {
+        //fail("The resources are not initialized");
+        //}
     }
 
     /**
@@ -291,8 +205,7 @@
         try {
             obj.hasService(null);
             fail("NullPointerException expected");
-        } catch (NullPointerException t) {
-        }
+        } catch (NullPointerException t) {}
     }
 
     /**
@@ -303,8 +216,7 @@
         try {
             obj.removeBeanContextServicesListener(null);
             fail("NullPointerException expected");
-        } catch (NullPointerException t) {
-        }
+        } catch (NullPointerException t) {}
     }
 
     /**
@@ -315,8 +227,7 @@
         try {
             obj.serviceAvailable(null);
             fail("NullPointerException expected");
-        } catch (NullPointerException t) {
-        }
+        } catch (NullPointerException t) {}
     }
 
     /**
@@ -327,34 +238,32 @@
         try {
             obj.serviceRevoked(null);
             fail("NullPointerException expected");
-        } catch (NullPointerException t) {
-        }
+        } catch (NullPointerException t) {}
     }
 
     /** UTILITY METHODS **/
-    
+
     /**
      * Fake implementation of provider
      */
     private BeanContextServiceProvider getProvider() {
-    
+
         return new BeanContextServiceProvider() {
 
-            public java.util.Iterator getCurrentServiceSelectors(BeanContextServices bcs, 
-                    Class serviceClass) {
-                        
+            public java.util.Iterator getCurrentServiceSelectors(
+                    BeanContextServices bcs, Class serviceClass) {
+
                 return bcs.getCurrentServiceSelectors(serviceClass);
             }
-            
+
             public Object getService(BeanContextServices bcs, Object requestor,
-                    Class serviceClass, Object serviceSelector) {                            
-                
+                    Class serviceClass, Object serviceSelector) {
+
                 return null;
             }
-            
-            public void releaseService(BeanContextServices bcs, Object requestor, 
-                    Object service) {
-            }
+
+            public void releaseService(BeanContextServices bcs,
+                    Object requestor, Object service) {}
         };
     }
 
@@ -375,4 +284,4 @@
     public static void main(String args[]) {
         junit.textui.TestRunner.run(suite());
     }
-}
\ No newline at end of file
+}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java?rev=417793&r1=417792&r2=417793&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/java/beans/beancontext/BeanContextSupportTest.java Wed Jun 28 08:34:24 2006
@@ -23,751 +23,560 @@
 import java.beans.beancontext.BeanContextSupport;
 import java.beans.beancontext.BeanContextMembershipEvent;
 import java.beans.beancontext.BeanContextMembershipListener;
-import java.beans.PropertyVetoException;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 /**
- * Test class for java.beans.beancontext.BeanContextSupport.<p>
- *
+ * Test class for java.beans.beancontext.BeanContextSupport.
+ * <p>
+ * 
  * @author Sergey A. Krivenko
  * @version $Revision: 1.4.4.2 $
  */
 
 public class BeanContextSupportTest extends TestCase {
 
-    /** STANDARD BEGINNING **/
+    /** STANDARD BEGINNING * */
 
     /**
-     * No arguments constructor to enable serialization.<p>
+     * No arguments constructor to enable serialization.
+     * <p>
      */
     public BeanContextSupportTest() {
         super();
     }
 
     /**
-     * Constructs this test case with the given name.<p>
-     *
-     * @param name - The name for this test case.<p>
+     * Constructs this test case with the given name.
+     * <p>
+     * 
+     * @param name - The name for this test case.
+     *        <p>
      */
     public BeanContextSupportTest(String name) {
         super(name);
     }
 
-    /** TEST CONSTRUCTORS **/
+    /** TEST CONSTRUCTORS * */
 
-    /** * Test constructor with BeanContext, Locale, boolean, boolean parameters.<p>
-     *
-     * @see BeanContextSupport#BeanContextSupport(BeanContext, Locale, boolean, boolean)
+    /**
+     * * Test constructor with BeanContext, Locale, boolean, boolean parameters.
+     * <p>
+     * 
+     * @see BeanContextSupport#BeanContextSupport(BeanContext, Locale, boolean,
+     *      boolean)
      */
     public void testConstructorBeanContextLocalebooleanboolean() {
-        try {
-            BeanContextSupport sup = new BeanContextSupport(null, null, true, true);
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        new BeanContextSupport(null, null, true, true);
     }
 
-    /** * Test constructor with BeanContext, Locale, boolean parameters.<p>
-     *
+    /**
+     * * Test constructor with BeanContext, Locale, boolean parameters.
+     * <p>
+     * 
      * @see BeanContextSupport#BeanContextSupport(BeanContext, Locale, boolean)
      */
     public void testConstructorBeanContextLocaleboolean() {
-        try {
-            BeanContextSupport sup = new BeanContextSupport(null, null, true);
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        new BeanContextSupport(null, null, true);
     }
 
-    /** * Test constructor with BeanContext, Locale parameters.<p>
-     *
+    /**
+     * * Test constructor with BeanContext, Locale parameters.
+     * <p>
+     * 
      * @see BeanContextSupport#BeanContextSupport(BeanContext, Locale)
      */
     public void testConstructorBeanContextLocale() {
-        try {
-            BeanContextSupport sup = new BeanContextSupport(null, null);
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        new BeanContextSupport(null, null);
     }
 
-    /** * Test constructor with BeanContext parameter.<p>
-     *
+    /**
+     * * Test constructor with BeanContext parameter.
+     * <p>
+     * 
      * @see BeanContextSupport#BeanContextSupport(BeanContext)
      */
     public void testConstructorBeanContext() {
-        try {
-            BeanContextSupport sup = new BeanContextSupport(null);
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        new BeanContextSupport(null);
     }
 
-    /** * Test constructor with no parameters.<p>
-     *
+    /**
+     * * Test constructor with no parameters.
+     * <p>
+     * 
      * @see BeanContextSupport#BeanContextSupport()
      */
     public void testConstructor() {
-        try {
-            BeanContextSupport sup = new BeanContextSupport();
-        }
-        catch (Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        new BeanContextSupport();
     }
 
-    /** TEST METHODS **/
+    /** TEST METHODS * */
 
     /**
-     * Test method createBCSChild() with Object, Object parameters.<p>
+     * Test method createBCSChild() with Object, Object parameters.
+     * <p>
      */
     public void testCreateBCSChildObjectObject() {
-        try {
-            BeanContextSupport sup = new BeanContextSupport();
-            sup.createBCSChild(new BeanContextSupport(), new BeanContextSupport());
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        BeanContextSupport sup = new BeanContextSupport();
+        sup.createBCSChild(new BeanContextSupport(), new BeanContextSupport());
     }
 
     /**
-     * Test method setLocale() with Locale parameter.<p>
+     * Test method setLocale() with Locale parameter.
+     * <p>
      */
-    public void testSetLocaleLocale() {
-        try {
-            BeanContextSupport sup = new BeanContextSupport();
-            sup.setLocale(null);
-            
-            if (!sup.getLocale().equals(java.util.Locale.getDefault())) {
-                fail("BeanContext should have default locale");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+    public void testSetLocaleLocale() throws Exception {
+        BeanContextSupport sup = new BeanContextSupport();
+        sup.setLocale(null);
+
+        assertEquals("BeanContext should have default locale", java.util.Locale
+                .getDefault(), sup.getLocale());
     }
 
     /**
-     * Test method bcsChildren() with no parameters.<p>
+     * Test method bcsChildren() with no parameters.
+     * <p>
      */
     public void testBcsChildren() {
-        try {
-            BeanContextSupport sup = new BeanContextSupport();
-            sup.add(new BeanContextChildSupport());
-            
-            for (java.util.Iterator it = sup.bcsChildren(); it.hasNext(); ) {
-                Object next = it.next();
-                
-                if (!(next instanceof BeanContextSupport.BCSChild)) {
-                    fail("Children must be instances of " +
-                         "BeanContextSupport.BCSChild class " +
-                         "but at least one of them: " + next.getClass());
-                }
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
+        BeanContextSupport sup = new BeanContextSupport();
+        sup.add(new BeanContextChildSupport());
+
+        for (java.util.Iterator it = sup.bcsChildren(); it.hasNext();) {
+            Object next = it.next();
+
+            assertTrue("Children must be instances of "
+                    + "BeanContextSupport.BCSChild class "
+                    + "but at least one of them: " + next.getClass(),
+                    next instanceof BeanContextSupport.BCSChild);
         }
     }
 
     /**
-     * Test method retainAll() with Collection parameter.<p>
+     * Test method retainAll() with Collection parameter.
+     * <p>
      */
     public void testRetainAllCollection() {
-        try {
-            
-            /*// Create an instance and add one child
-            BeanContextSupport sup = new BeanContextSupport();
-            BeanContextChildSupport ch = new BeanContextChildSupport();
-            sup.add(ch);
-            
-            // Create collection with an instance of the child that was added
-            java.util.Collection col = new java.util.ArrayList();
-            col.add(ch);            
-            
-            // Remove all children that are not in the collection
-            // The collection must remain unchanged
-            if (sup.retainAll(col)) {
-                fail("False should be returned");
-            }
-            
-            // Just one child must be present
-            if (sup.size() != 1) {
-                fail("The size of the collection must be 1");
-            }
-            
-            // Add a new child in the collection and remove the old one
-            col.clear();
-            col.add(new Object());
-            
-            // Remove all children that are not in the collection
-            // The collection must have 0 elements after that
-            if (!sup.retainAll(col)) {
-                fail("True should be returned");
-            }
-            
-            // No children must be present
-            if (sup.size() != 0) {
-                fail("The size of the collection must be 0");
-            }*/
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+    /*
+     * // Create an instance and add one child BeanContextSupport sup =
+     * new BeanContextSupport(); BeanContextChildSupport ch = new
+     * BeanContextChildSupport(); sup.add(ch);
+     *  // Create collection with an instance of the child that was
+     * added java.util.Collection col = new java.util.ArrayList();
+     * col.add(ch);
+     *  // Remove all children that are not in the collection // The
+     * collection must remain unchanged if (sup.retainAll(col)) {
+     * fail("False should be returned"); }
+     *  // Just one child must be present if (sup.size() != 1) {
+     * fail("The size of the collection must be 1"); }
+     *  // Add a new child in the collection and remove the old one
+     * col.clear(); col.add(new Object());
+     *  // Remove all children that are not in the collection // The
+     * collection must have 0 elements after that if
+     * (!sup.retainAll(col)) { fail("True should be returned"); }
+     *  // No children must be present if (sup.size() != 0) { fail("The
+     * size of the collection must be 0"); }
+     */
     }
 
     /**
-     * Test method removeAll() with Collection parameter.<p>
+     * Test method removeAll() with Collection parameter.
+     * <p>
      */
     public void testRemoveAllCollection() {
-        try {
-            
-            /*// Create an instance and add one child
-            BeanContextSupport sup = new BeanContextSupport();
-            BeanContextChildSupport ch = new BeanContextChildSupport();
-            sup.add(ch);
-            
-            // Create collection with an instance of an arbitrary child
-            java.util.Collection col = new java.util.ArrayList();
-            col.add(new Object());    
-            
-            // Remove all children that are in the collection
-            // The collection should not change after that
-            if (sup.removeAll(col)) {
-                fail("False should be returned");
-            }
-            
-            // Add a child that is a member of the BeanContext
-            col.add(ch); 
-            
-            // Remove all children that are in the collection
-            // The collection should change after that
-            if (!sup.removeAll(col)) {
-                fail("True should be returned");
-            }
-            
-            // No children must be present
-            if (sup.size() != 0) {
-                fail("The size of the collection must be 0 but is " + sup.size());
-            }*/
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+    /*
+     * // Create an instance and add one child BeanContextSupport sup =
+     * new BeanContextSupport(); BeanContextChildSupport ch = new
+     * BeanContextChildSupport(); sup.add(ch);
+     *  // Create collection with an instance of an arbitrary child
+     * java.util.Collection col = new java.util.ArrayList(); col.add(new
+     * Object());
+     *  // Remove all children that are in the collection // The
+     * collection should not change after that if (sup.removeAll(col)) {
+     * fail("False should be returned"); }
+     *  // Add a child that is a member of the BeanContext col.add(ch);
+     *  // Remove all children that are in the collection // The
+     * collection should change after that if (!sup.removeAll(col)) {
+     * fail("True should be returned"); }
+     *  // No children must be present if (sup.size() != 0) { fail("The
+     * size of the collection must be 0 but is " + sup.size()); }
+     */
     }
 
     /**
-     * Test method containsAll() with Collection parameter.<p>
+     * Test method containsAll() with Collection parameter.
+     * <p>
      */
     public void testContainsAllCollection() {
-        try {
-            
-            /*// Create an instance and add two children
-            BeanContextSupport sup = new BeanContextSupport();
-            BeanContextChildSupport ch = new BeanContextChildSupport();
-            Object obj = new Object();
-            sup.add(ch);
-            sup.add(obj);
-            
-            // Create collection with BCS children that just were added
-            java.util.Collection col = new java.util.ArrayList();
-            
-            for (java.util.Iterator it = sup.bcsChildren(); it.hasNext(); ) {
-                col.add(it.next());
-            }
-            
-            // Two collections have the same elements
-            if (!sup.containsAll(col)) {
-                fail("True should be returned");
-            }
-            
-            sup.remove(obj);
-            
-            // Now they are different
-            if (sup.containsAll(col)) {
-                fail("False should be returned");
-            }*/
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+    /*
+     * // Create an instance and add two children BeanContextSupport sup =
+     * new BeanContextSupport(); BeanContextChildSupport ch = new
+     * BeanContextChildSupport(); Object obj = new Object();
+     * sup.add(ch); sup.add(obj);
+     *  // Create collection with BCS children that just were added
+     * java.util.Collection col = new java.util.ArrayList();
+     * 
+     * for (java.util.Iterator it = sup.bcsChildren(); it.hasNext(); ) {
+     * col.add(it.next()); }
+     *  // Two collections have the same elements if
+     * (!sup.containsAll(col)) { fail("True should be returned"); }
+     * 
+     * sup.remove(obj);
+     *  // Now they are different if (sup.containsAll(col)) {
+     * fail("False should be returned"); }
+     */
     }
 
     /**
-     * Test method addAll() with Collection parameter.<p>
+     * Test method addAll() with Collection parameter.
+     * <p>
      */
     public void testAddAllCollection() {
-        try {
-            
-            /*// Create an instance and add two children
-            BeanContextSupport sup = new BeanContextSupport();
-                     
-            // Create collection with two elements
-            java.util.Collection col = new java.util.ArrayList();
-            col.add(new BeanContextChildSupport());
-            col.add(new Object());
-            
-            // Place two children into the BeanContext
-            if (!sup.addAll(col)) {
-                fail("True should be returned");
-            }
-            
-            // Two children must be present
-            if (sup.size() != 2) {
-                fail("The size of the collection must be 2 but is " + sup.size());
-            }*/
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+    /*
+     * // Create an instance and add two children BeanContextSupport sup =
+     * new BeanContextSupport();
+     *  // Create collection with two elements java.util.Collection col =
+     * new java.util.ArrayList(); col.add(new
+     * BeanContextChildSupport()); col.add(new Object());
+     *  // Place two children into the BeanContext if (!sup.addAll(col)) {
+     * fail("True should be returned"); }
+     *  // Two children must be present if (sup.size() != 2) { fail("The
+     * size of the collection must be 2 but is " + sup.size()); }
+     */
     }
 
     /**
-     * Test method remove() with Object, boolean parameters.<p>
+     * Test method remove() with Object, boolean parameters.
+     * <p>
      */
     public void testRemoveObjectboolean() {
-        try {
-            
-            // Create an instance and add one child
-            BeanContextSupport sup = new BeanContextSupport();
-            BeanContextChildSupport ch = new BeanContextChildSupport();
-            sup.add(ch);
-            
-            // Remove unexisting child
-            if (sup.remove(new Object(), true)) {
-                fail("False should be returned");
-            }
-            
-            // Remove it
-            if (!sup.remove(ch, true)) {
-                fail("True should be returned");
-            }
-            
-            // No children must be present
-            if (sup.size() != 0) {
-                fail("The size of the collection must be 0 but is " + sup.size());
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Create an instance and add one child
+        BeanContextSupport sup = new BeanContextSupport();
+        BeanContextChildSupport ch = new BeanContextChildSupport();
+        sup.add(ch);
+
+        // Remove unexisting child
+        assertFalse(sup.remove(new Object(), true));
+
+        // Remove it
+        assertTrue(sup.remove(ch, true));
+
+        // No children must be present
+        assertEquals("The size of the collection must be 0", 0, sup.size());
     }
 
     /**
-     * Test method remove() with Object parameter.<p>
+     * Test method remove() with Object parameter.
+     * <p>
      */
     public void testRemoveObject() {
-        try {
-            
-            // Create an instance and add one child
-            BeanContextSupport sup = new BeanContextSupport();
-            BeanContextChildSupport ch = new BeanContextChildSupport();
-            sup.add(ch);
-            
-            // Remove unexisting child
-            if (sup.remove(new Object())) {
-                fail("False should be returned");
-            }
-            
-            // Remove it
-            if (!sup.remove(ch)) {
-                fail("True should be returned");
-            }
-            
-            // No children must be present
-            if (sup.size() != 0) {
-                fail("The size of the collection must be 0 but is " + sup.size());
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Create an instance and add one child
+        BeanContextSupport sup = new BeanContextSupport();
+        BeanContextChildSupport ch = new BeanContextChildSupport();
+        sup.add(ch);
+
+        // Remove unexisting child
+        assertFalse(sup.remove(new Object()));
+
+        // Remove it
+        assertTrue(sup.remove(ch));
+
+        // No children must be present
+        assertEquals("The size of the collection must be 0", 0, sup.size());
     }
 
     /**
-     * Test method containsKey() with Object parameter.<p>
+     * Test method containsKey() with Object parameter.
+     * <p>
      */
     public void testContainsKeyObject() {
-        try {
-            
-            // Create an instance and add a child
-            BeanContextSupport sup = new BeanContextSupport();
-            BeanContextChildSupport ch = new BeanContextChildSupport();
-            sup.add(ch);
-            
-            // We should find the child now
-            if (!sup.containsKey(ch)) {
-                fail("True should be returned");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+
+        // Create an instance and add a child
+        BeanContextSupport sup = new BeanContextSupport();
+        BeanContextChildSupport ch = new BeanContextChildSupport();
+        sup.add(ch);
+
+        // We should find the child now
+        assertTrue(sup.containsKey(ch));
     }
 
     /**
-     * Test method contains() with Object parameter.<p>
+     * Test method contains() with Object parameter.
+     * <p>
      */
     public void testContainsObject() {
-        try {
-            
-            // Create an instance and add a child
-            BeanContextSupport sup = new BeanContextSupport();
-            BeanContextChildSupport ch = new BeanContextChildSupport();
-            sup.add(ch);
-            
-            BeanContextSupport.BCSChild bcs = 
-                (BeanContextSupport.BCSChild) sup.bcsChildren().next();
-            
-            // We should find the child now
-            if (!sup.contains(bcs)) {
-                // fail("True should be returned");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
+        // Create an instance and add a child
+        BeanContextSupport sup = new BeanContextSupport();
+        BeanContextChildSupport ch = new BeanContextChildSupport();
+        sup.add(ch);
+
+        BeanContextSupport.BCSChild bcs = (BeanContextSupport.BCSChild) sup
+                .bcsChildren().next();
+
+        // We should find the child now
+        if (!sup.contains(bcs)) {
+            // fail("True should be returned");
         }
     }
 
     /**
-     * Test method add() with Object parameter.<p>
+     * Test method add() with Object parameter.
+     * <p>
      */
     public void testAddObject() {
-        try {
-            
-            // Create an instance and add a child
-            BeanContextSupport sup = new BeanContextSupport();
-            sup.add(new Object());
-            
-            // Just one child must be present
-            if (sup.size() != 1) {
-                fail("The size of the collection must be 1 but is " + sup.size());
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Create an instance and add a child
+        BeanContextSupport sup = new BeanContextSupport();
+        sup.add(new Object());
+
+        // Just one child must be present
+        assertEquals("The size of the collection must be 1", 1, sup.size());
     }
 
     /**
-     * Test method toArray() with no parameters.<p>
+     * Test method toArray() with no parameters.
+     * <p>
      */
     public void testToArray() {
-        try {
-            
-            // Create an instance and add two children
-            BeanContextSupport sup = new BeanContextSupport();
-            sup.add("obj1");
-            sup.add("obj2");
-            
-            // Convert to array
-            Object[] array = sup.toArray();
-            
-            // Check length
-            if (array.length != 2) {
-                fail("The size of the collection must be 2 but is " + array.length);
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Create an instance and add two children
+        BeanContextSupport sup = new BeanContextSupport();
+        sup.add("obj1");
+        sup.add("obj2");
+
+        // Convert to array
+        Object[] array = sup.toArray();
+
+        // Check length
+        assertEquals("The size of the collection must be 2", 2, array.length);
     }
 
     /**
-     * Test method copyChildren() with no parameters.<p>
+     * Test method copyChildren() with no parameters.
+     * <p>
      */
     public void testCopyChildren() {
-        try {
-            
-            // Create an instance and add two children
-            BeanContextSupport sup = new BeanContextSupport();
-            sup.add("obj1");
-            sup.add("obj2");
-            
-            // Convert to array
-            Object[] array = sup.copyChildren();
-            
-            // Check length
-            if (array.length != 2) {
-                fail("The size of the collection must be 2 but is " + array.length);
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Create an instance and add two children
+        BeanContextSupport sup = new BeanContextSupport();
+        sup.add("obj1");
+        sup.add("obj2");
+
+        // Convert to array
+        Object[] array = sup.copyChildren();
+
+        // Check length
+        assertEquals("The size of the collection must be 2", 2, array.length);
     }
 
     /**
-     * Test method removeBeanContextMembershipListener() with BeanContextMembershipListener parameter.<p>
+     * Test method removeBeanContextMembershipListener() with
+     * BeanContextMembershipListener parameter.
+     * <p>
      */
     public void testRemoveBeanContextMembershipListenerBeanContextMembershipListener() {
-        try {
-            
-            // Create BeanContext and BeanContextMembershipListener instances
-            BeanContextSupport sup = new BeanContextSupport();
-            BeanContextMembershipListener l = getBeanContextMembershipListener();
-            sup.addBeanContextMembershipListener(l);
-            sup.removeBeanContextMembershipListener(l);
-            
-            // Check if it's there
-            if (sup.bcmListeners.contains(l)) {
-                fail("Listener should not be present");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Create BeanContext and BeanContextMembershipListener instances
+        BeanContextSupport sup = new BeanContextSupport();
+        BeanContextMembershipListener l = getBeanContextMembershipListener();
+        sup.addBeanContextMembershipListener(l);
+        sup.removeBeanContextMembershipListener(l);
+
+        assertFalse("Listener should not be present", sup.bcmListeners
+                .contains(l));
     }
 
     /**
-     * Test method addBeanContextMembershipListener() with BeanContextMembershipListener parameter.<p>
+     * Test method addBeanContextMembershipListener() with
+     * BeanContextMembershipListener parameter.
+     * <p>
      */
     public void testAddBeanContextMembershipListenerBeanContextMembershipListener() {
-        try {
-            
-            // Create BeanContext and BeanContextMembershipListener instances
-            BeanContextSupport sup = new BeanContextSupport();
-            BeanContextMembershipListener l = getBeanContextMembershipListener();
-            sup.addBeanContextMembershipListener(l);
-            
-            // Check if it's there
-            if (!sup.bcmListeners.contains(l)) {
-                fail("Listener should be present");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Create BeanContext and BeanContextMembershipListener instances
+        BeanContextSupport sup = new BeanContextSupport();
+        BeanContextMembershipListener l = getBeanContextMembershipListener();
+        sup.addBeanContextMembershipListener(l);
+
+        assertTrue("Listener should be present", sup.bcmListeners.contains(l));
     }
 
     /**
-     * Test method getBeanContextPeer() with no parameters.<p>
+     * Test method getBeanContextPeer() with no parameters.
+     * <p>
      */
     public void testGetBeanContextPeer() {
-        try {
-            
-            // Create BeanContext instance
-            BeanContextSupport sup = new BeanContextSupport();
-            
-            // The peer and this context should be equal
-            if (!sup.getBeanContextPeer().equals(sup)) {
-                fail("The peer and the BeanContext should be equal");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Create BeanContext instance
+        BeanContextSupport sup = new BeanContextSupport();
+
+        // The peer and this context should be equal
+        assertEquals("The peer and the BeanContext should be equal", sup, sup
+                .getBeanContextPeer());
     }
 
     /**
-     * Test method vetoableChange() with PropertyChangeEvent parameter.<p>
+     * Test method vetoableChange() with PropertyChangeEvent parameter.
+     * <p>
      */
     public void testVetoableChangePropertyChangeEvent() {
-        try {
-            
-            /** @todo: not implemented yet in the class **/
-            // Create BeanContext instance
-            BeanContextSupport sup = new BeanContextSupport();
-            //sup.vetoableChange(null);
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        /** @todo: not implemented yet in the class * */
+        // Create BeanContext instance
+        BeanContextSupport sup = new BeanContextSupport();
+        // sup.vetoableChange(null);
     }
 
     /**
-     * Test method propertyChange() with PropertyChangeEvent parameter.<p>
+     * Test method propertyChange() with PropertyChangeEvent parameter.
+     * <p>
      */
     public void testPropertyChangePropertyChangeEvent() {
-        try {
-            
-            /** @todo: not implemented yet in the class **/
-            // Create BeanContext instance
-            BeanContextSupport sup = new BeanContextSupport();
-            //sup.propertyChange(null);
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        /** @todo: not implemented yet in the class * */
+        // Create BeanContext instance
+        BeanContextSupport sup = new BeanContextSupport();
+        // sup.propertyChange(null);
     }
 
     /**
-     * Test method isEmpty() with no parameters.<p>
+     * Test method isEmpty() with no parameters.
+     * <p>
      */
     public void testIsEmpty() {
-        try {
-            
-            // Create BeanContext instance
-            BeanContextSupport sup = new BeanContextSupport();
-            
-            if (!sup.isEmpty()) {
-                fail("The collection of children should be empty");
-            } 
-            
-            sup.add(new Object());
-            
-            if (sup.isEmpty()) {
-                fail("The collection of children should not be empty");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Create BeanContext instance
+        BeanContextSupport sup = new BeanContextSupport();
+
+        assertTrue("The collection of children should be empty", sup.isEmpty());
+
+        sup.add(new Object());
+
+        assertFalse("The collection of children should not be empty", sup
+                .isEmpty());
     }
 
     /**
-     * Test method clear() with no parameters.<p>
+     * Test method clear() with no parameters.
+     * <p>
      */
     public void testClear() {
-        try {
-            
-            /*// Create BeanContext instance
-            BeanContextSupport sup = new BeanContextSupport();
-            
-            // Add a child and then clear
-            sup.add(new Object());
-            sup.clear();
-            
-            if (!sup.isEmpty()) {
-                fail("The collection of children should be empty");
-            }*/
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+    /*
+     * // Create BeanContext instance BeanContextSupport sup = new
+     * BeanContextSupport();
+     *  // Add a child and then clear sup.add(new Object());
+     * sup.clear();
+     * 
+     * if (!sup.isEmpty()) { fail("The collection of children should be
+     * empty"); }
+     */
     }
 
     /**
-     * Test method size() with no parameters.<p>
+     * Test method size() with no parameters.
+     * <p>
      */
     public void testSize() {
-        try {
-            
-            // Create BeanContext instance
-            BeanContextSupport sup = new BeanContextSupport();
-            
-            if (sup.size() != 0) {
-                fail("The size of the collection should be equal to 0");
-            }
-            
-            sup.add(new Object());
-            
-            if (sup.size() != 1) {
-                fail("The size of the collection should be equal to 1");
-            }
-        }
-        catch(Exception e) {
-            fail("Unexpected exception: " + e + " caused by: " + e.getCause());
-        }
+        // Create BeanContext instance
+        BeanContextSupport sup = new BeanContextSupport();
+
+        assertEquals("The size of the collection should be equal to 0", 0, sup.size());
+
+        sup.add(new Object());
+
+        assertEquals("The collection of children should not be empty", 1, sup
+                .size());
     }
 
     /**
-     * Test method getResourceAsStream() with String, BeanContextChild=null parameters.<p>
+     * Test method getResourceAsStream() with String, BeanContextChild=null
+     * parameters.
+     * <p>
      */
     public void test_getResourceAsStreamLlava_lang_StringLjava_beans_beancontext_BeanContextChild() {
         BeanContextSupport obj = new BeanContextSupport();
         try {
             obj.getResourceAsStream(new String(), null);
             fail("NullPointerException expected");
-        } catch (NullPointerException t) {
-        }
+        } catch (NullPointerException t) {}
     }
 
     /**
-     * Test method getResourceAsStream() with String=null, BeanContextChild=null parameters.<p>
+     * Test method getResourceAsStream() with String=null, BeanContextChild=null
+     * parameters.
+     * <p>
      */
     public void test_getResourceAsStreamLlava_lang_StringLjava_beans_beancontext_BeanContextChild2() {
         BeanContextSupport obj = new BeanContextSupport();
         try {
             obj.getResourceAsStream(null, null);
             fail("NullPointerException expected");
-        } catch (IllegalArgumentException t) {
-            fail("NullPointerException expected");
-        } catch (NullPointerException t) {
-        }
+        } catch (NullPointerException t) {}
     }
 
     /**
-     * Test method vetoableChange() with PropertyChangeEvent=null parameter.<p>
+     * Test method vetoableChange() with PropertyChangeEvent=null parameter.
+     * <p>
+     * @throws Exception 
      */
-    public void test_vetoableChangeLjava_beans_PropertyChangeEvent() {
+    public void test_vetoableChangeLjava_beans_PropertyChangeEvent() throws Exception {
         BeanContextSupport obj = new BeanContextSupport();
         try {
             obj.vetoableChange(null);
             fail("NullPointerException expected");
-        } catch (PropertyVetoException p) {
-            fail("NullPointerException expected");
-        } catch (NullPointerException t) {
-        }
+        } catch (NullPointerException t) {}
     }
 
     /**
-     * Test method getResource() with String!=null, BeanContextChild=null parameters.<p>
+     * Test method getResource() with String!=null, BeanContextChild=null
+     * parameters.
+     * <p>
      */
     public void test_getResourceLjava_lang_StringLjava_beans_beancontext_BeanContextChild() {
         BeanContextSupport obj = new BeanContextSupport();
         try {
             obj.getResource("", null);
             fail("NullPointerException expected");
-        } catch (NullPointerException t) {
-        }
+        } catch (NullPointerException t) {}
     }
 
     /**
-     * Test method getResource() with String=null, BeanContextChild=null parameters.<p>
+     * Test method getResource() with String=null, BeanContextChild=null
+     * parameters.
+     * <p>
      */
     public void test_getResourceLjava_lang_StringLjava_beans_beancontext_BeanContextChild2() {
         BeanContextSupport obj = new BeanContextSupport();
         try {
             obj.getResource(null, null);
             fail("NullPointerException expected");
-        } catch (IllegalArgumentException t) {
-            fail("NullPointerException expected");
-        } catch (NullPointerException t) {
-        }
+        } catch (NullPointerException t) {}
     }
 
-    /** UTILITY METHODS **/
-    
+    /** UTILITY METHODS * */
+
     /**
      * Create BeanContextMembershipListener instance
      */
     private BeanContextMembershipListener getBeanContextMembershipListener() {
         return new BeanContextMembershipListener() {
-                    
-            public void childrenAdded(BeanContextMembershipEvent bcme) {
-                ;
-            }
-            
-            public void childrenRemoved(BeanContextMembershipEvent bcme) {
-                ;
-            }
+
+            public void childrenAdded(BeanContextMembershipEvent bcme) {}
+
+            public void childrenRemoved(BeanContextMembershipEvent bcme) {}
         };
     }
 
-    /** STANDARD ENDING **/
+    /** STANDARD ENDING * */
 
     /**
-     * Start testing from the command line.<p>
+     * Start testing from the command line.
+     * <p>
      */
     public static Test suite() {
         return new TestSuite(BeanContextSupportTest.class);
     }
 
     /**
-     * Start testing from the command line.<p>
-     *
-     * @param args - Command line parameters.<p>
+     * Start testing from the command line.
+     * <p>
+     * 
+     * @param args - Command line parameters.
+     *        <p>
      */
     public static void main(String args[]) {
         junit.textui.TestRunner.run(suite());
     }
-}
\ No newline at end of file
+}



Mime
View raw message