Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 7988 invoked from network); 8 Jun 2006 03:41:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 8 Jun 2006 03:41:22 -0000 Received: (qmail 9200 invoked by uid 500); 8 Jun 2006 03:41:21 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 8968 invoked by uid 500); 8 Jun 2006 03:41:19 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 8814 invoked by uid 99); 8 Jun 2006 03:41:19 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jun 2006 20:41:19 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jun 2006 20:41:13 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 64AEA1A984A; Wed, 7 Jun 2006 20:40:53 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r412641 [4/32] - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/ main/java/java/beans/beancontext/ test/java-internal/java/beans/beancontext/ test/java/org/apache/harmony/beans/tests/ test/java/org/apa... Date: Thu, 08 Jun 2006 03:40:30 -0000 To: harmony-commits@incubator.apache.org From: mloenko@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060608034053.64AEA1A984A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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=412641&r1=412640&r2=412641&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 7 20:40:24 2006 @@ -1,378 +1,378 @@ -/* - * Copyright 2005 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 Sergey A. Krivenko - * @version $Revision: 1.5.2.2 $ - */ -package java.beans.beancontext; - -import java.beans.beancontext.BeanContextServices; -import java.beans.beancontext.BeanContextServicesSupport; -import java.beans.beancontext.BeanContextServiceProvider; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Test class for java.beans.beancontext.BeanContextServicesSupport.

- * - * @author Sergey A. Krivenko - * @version $Revision: 1.5.2.2 $ - */ - -public class BeanContextServicesSupportTest extends TestCase { - - /** STANDARD BEGINNING **/ - - /** - * No arguments constructor to enable serialization.

- */ - public BeanContextServicesSupportTest() { - super(); - } - - /** - * Constructs this test case with the given name.

- * - * @param name - The name for this test case.

- */ - public BeanContextServicesSupportTest(String name) { - super(name); - } - - /** TEST CONSTRUCTORS **/ - - /** - * Test constructor with BeanContextServices, Locale, boolean, - * boolean parameters.

- * - * @see BeanContextServicesSupport#BeanContextServicesSupport( - * 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()); - } - } - - /** - * Test constructor with BeanContextServices, Locale, boolean parameters - * - * @see BeanContextServicesSupport#BeanContextServicesSupport( - * 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()); - } - } - - /** - * Test constructor with BeanContextServices, Locale parameters.

- * - * @see BeanContextServicesSupport#BeanContextServicesSupport( - * BeanContextServices, Locale) - */ - public void testConstructorBeanContextServicesLocale() { - try { - BeanContextServicesSupport sup = - new BeanContextServicesSupport(null, null); - } - catch (Exception e) { - fail("Unexpected exception: " + e + " caused by: " + e.getCause()); - } - } - - /** - * Test constructor with BeanContextServices parameter.

- * - * @see BeanContextServicesSupport#BeanContextServicesSupport( - * BeanContextServices) - */ - public void testConstructorBeanContextServices() { - try { - BeanContextServicesSupport sup = - new BeanContextServicesSupport(null); - } - catch (Exception e) { - fail("Unexpected exception: " + e + " caused by: " + e.getCause()); - } - } - - /** * Test constructor with no parameters.

- * - * @see BeanContextServicesSupport#BeanContextServicesSupport() - */ - public void testConstructor() { - try { - BeanContextServicesSupport sup = new BeanContextServicesSupport(); - } - catch (Exception e) { - fail("Unexpected exception: " + e + " caused by: " + e.getCause()); - } - } - - /** TEST METHODS **/ - - /** - * Test method createBCSChild() with Object, Object parameters.

- */ - 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()); - } - } - - /** - * Test method addService() with Class, BeanContextServiceProvider, boolean parameters.

- */ - 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()); - } - } - - /** - * Test method revokeService() with Class, BeanContextServiceProvider, boolean parameters.

- */ - 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()); - } - } - - /** - * Test method addService() with Class, BeanContextServiceProvider parameters.

- */ - 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()); - } - } - - /** - * Test method hasService() with Class parameter.

- */ - 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()); - } - } - - /** - * Test method getBeanContextServicesPeer() with no parameters.

- */ - 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()); - } - } - - /** - * Test method releaseBeanContextResources() with no parameters.

- */ - 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()); - } - } - - /** - * Test method initializeBeanContextResources() with no parameters.

- */ - 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()); - } - } - - /** - * Test method hasService() with Class=null parameter.

- */ - public void test_hasServiceLjava_lang_Class() { - BeanContextServicesSupport obj = new BeanContextServicesSupport(); - try { - obj.hasService(null); - fail("NullPointerException expected"); - } catch (NullPointerException t) { - } - } - - /** - * Test method removeBeanContextServicesListener() with BeanContextServicesListener=null parameter.

- */ - public void test_removeBeanContextServicesListenerLjava_beans_beancontext_BeanContextServicesListener() { - BeanContextServicesSupport obj = new BeanContextServicesSupport(); - try { - obj.removeBeanContextServicesListener(null); - fail("NullPointerException expected"); - } catch (NullPointerException t) { - } - } - - /** - * Test method serviceAvailable() with BeanContextServiceAvailableEvent=null parameter.

- */ - public void test_serviceAvailableLjava_beans_beancontext_BeanContextServiceAvailableEvent() { - BeanContextServicesSupport obj = new BeanContextServicesSupport(); - try { - obj.serviceAvailable(null); - fail("NullPointerException expected"); - } catch (NullPointerException t) { - } - } - - /** - * Test method serviceRevoked() with BeanContextServiceRevokedEvent=null parameter.

- */ - public void test_serviceRevokedLjava_beans_beancontext_BeanContextServiceRevokedEvent() { - BeanContextServicesSupport obj = new BeanContextServicesSupport(); - try { - obj.serviceRevoked(null); - fail("NullPointerException expected"); - } catch (NullPointerException t) { - } - } - - /** UTILITY METHODS **/ - - /** - * Fake implementation of provider - */ - private BeanContextServiceProvider getProvider() { - - return new BeanContextServiceProvider() { - - public java.util.Iterator getCurrentServiceSelectors(BeanContextServices bcs, - Class serviceClass) { - - return bcs.getCurrentServiceSelectors(serviceClass); - } - - public Object getService(BeanContextServices bcs, Object requestor, - Class serviceClass, Object serviceSelector) { - - return null; - } - - public void releaseService(BeanContextServices bcs, Object requestor, - Object service) { - } - }; - } - - /** STANDARD ENDING **/ - - /** - * Start testing from the command line.

- */ - public static Test suite() { - return new TestSuite(BeanContextServicesSupportTest.class); - } - - /** - * Start testing from the command line.

- * - * @param args - Command line parameters.

- */ - public static void main(String args[]) { - junit.textui.TestRunner.run(suite()); - } +/* + * Copyright 2005 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 Sergey A. Krivenko + * @version $Revision: 1.5.2.2 $ + */ +package java.beans.beancontext; + +import java.beans.beancontext.BeanContextServices; +import java.beans.beancontext.BeanContextServicesSupport; +import java.beans.beancontext.BeanContextServiceProvider; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Test class for java.beans.beancontext.BeanContextServicesSupport.

+ * + * @author Sergey A. Krivenko + * @version $Revision: 1.5.2.2 $ + */ + +public class BeanContextServicesSupportTest extends TestCase { + + /** STANDARD BEGINNING **/ + + /** + * No arguments constructor to enable serialization.

+ */ + public BeanContextServicesSupportTest() { + super(); + } + + /** + * Constructs this test case with the given name.

+ * + * @param name - The name for this test case.

+ */ + public BeanContextServicesSupportTest(String name) { + super(name); + } + + /** TEST CONSTRUCTORS **/ + + /** + * Test constructor with BeanContextServices, Locale, boolean, + * boolean parameters.

+ * + * @see BeanContextServicesSupport#BeanContextServicesSupport( + * 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()); + } + } + + /** + * Test constructor with BeanContextServices, Locale, boolean parameters + * + * @see BeanContextServicesSupport#BeanContextServicesSupport( + * 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()); + } + } + + /** + * Test constructor with BeanContextServices, Locale parameters.

+ * + * @see BeanContextServicesSupport#BeanContextServicesSupport( + * BeanContextServices, Locale) + */ + public void testConstructorBeanContextServicesLocale() { + try { + BeanContextServicesSupport sup = + new BeanContextServicesSupport(null, null); + } + catch (Exception e) { + fail("Unexpected exception: " + e + " caused by: " + e.getCause()); + } + } + + /** + * Test constructor with BeanContextServices parameter.

+ * + * @see BeanContextServicesSupport#BeanContextServicesSupport( + * BeanContextServices) + */ + public void testConstructorBeanContextServices() { + try { + BeanContextServicesSupport sup = + new BeanContextServicesSupport(null); + } + catch (Exception e) { + fail("Unexpected exception: " + e + " caused by: " + e.getCause()); + } + } + + /** * Test constructor with no parameters.

+ * + * @see BeanContextServicesSupport#BeanContextServicesSupport() + */ + public void testConstructor() { + try { + BeanContextServicesSupport sup = new BeanContextServicesSupport(); + } + catch (Exception e) { + fail("Unexpected exception: " + e + " caused by: " + e.getCause()); + } + } + + /** TEST METHODS **/ + + /** + * Test method createBCSChild() with Object, Object parameters.

+ */ + 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()); + } + } + + /** + * Test method addService() with Class, BeanContextServiceProvider, boolean parameters.

+ */ + 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()); + } + } + + /** + * Test method revokeService() with Class, BeanContextServiceProvider, boolean parameters.

+ */ + 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()); + } + } + + /** + * Test method addService() with Class, BeanContextServiceProvider parameters.

+ */ + 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()); + } + } + + /** + * Test method hasService() with Class parameter.

+ */ + 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()); + } + } + + /** + * Test method getBeanContextServicesPeer() with no parameters.

+ */ + 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()); + } + } + + /** + * Test method releaseBeanContextResources() with no parameters.

+ */ + 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()); + } + } + + /** + * Test method initializeBeanContextResources() with no parameters.

+ */ + 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()); + } + } + + /** + * Test method hasService() with Class=null parameter.

+ */ + public void test_hasServiceLjava_lang_Class() { + BeanContextServicesSupport obj = new BeanContextServicesSupport(); + try { + obj.hasService(null); + fail("NullPointerException expected"); + } catch (NullPointerException t) { + } + } + + /** + * Test method removeBeanContextServicesListener() with BeanContextServicesListener=null parameter.

+ */ + public void test_removeBeanContextServicesListenerLjava_beans_beancontext_BeanContextServicesListener() { + BeanContextServicesSupport obj = new BeanContextServicesSupport(); + try { + obj.removeBeanContextServicesListener(null); + fail("NullPointerException expected"); + } catch (NullPointerException t) { + } + } + + /** + * Test method serviceAvailable() with BeanContextServiceAvailableEvent=null parameter.

+ */ + public void test_serviceAvailableLjava_beans_beancontext_BeanContextServiceAvailableEvent() { + BeanContextServicesSupport obj = new BeanContextServicesSupport(); + try { + obj.serviceAvailable(null); + fail("NullPointerException expected"); + } catch (NullPointerException t) { + } + } + + /** + * Test method serviceRevoked() with BeanContextServiceRevokedEvent=null parameter.

+ */ + public void test_serviceRevokedLjava_beans_beancontext_BeanContextServiceRevokedEvent() { + BeanContextServicesSupport obj = new BeanContextServicesSupport(); + try { + obj.serviceRevoked(null); + fail("NullPointerException expected"); + } catch (NullPointerException t) { + } + } + + /** UTILITY METHODS **/ + + /** + * Fake implementation of provider + */ + private BeanContextServiceProvider getProvider() { + + return new BeanContextServiceProvider() { + + public java.util.Iterator getCurrentServiceSelectors(BeanContextServices bcs, + Class serviceClass) { + + return bcs.getCurrentServiceSelectors(serviceClass); + } + + public Object getService(BeanContextServices bcs, Object requestor, + Class serviceClass, Object serviceSelector) { + + return null; + } + + public void releaseService(BeanContextServices bcs, Object requestor, + Object service) { + } + }; + } + + /** STANDARD ENDING **/ + + /** + * Start testing from the command line.

+ */ + public static Test suite() { + return new TestSuite(BeanContextServicesSupportTest.class); + } + + /** + * Start testing from the command line.

+ * + * @param args - Command line parameters.

+ */ + public static void main(String args[]) { + junit.textui.TestRunner.run(suite()); + } } 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=412641&r1=412640&r2=412641&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 7 20:40:24 2006 @@ -1,773 +1,773 @@ -/* - * Copyright 2005 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 Sergey A. Krivenko - * @version $Revision: 1.4.4.2 $ - */ -package java.beans.beancontext; - -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.

- * - * @author Sergey A. Krivenko - * @version $Revision: 1.4.4.2 $ - */ - -public class BeanContextSupportTest extends TestCase { - - /** STANDARD BEGINNING **/ - - /** - * No arguments constructor to enable serialization.

- */ - public BeanContextSupportTest() { - super(); - } - - /** - * Constructs this test case with the given name.

- * - * @param name - The name for this test case.

- */ - public BeanContextSupportTest(String name) { - super(name); - } - - /** TEST CONSTRUCTORS **/ - - /** * Test constructor with BeanContext, Locale, boolean, boolean parameters.

- * - * @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()); - } - } - - /** * Test constructor with BeanContext, Locale, boolean parameters.

- * - * @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()); - } - } - - /** * Test constructor with BeanContext, Locale parameters.

- * - * @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()); - } - } - - /** * Test constructor with BeanContext parameter.

- * - * @see BeanContextSupport#BeanContextSupport(BeanContext) - */ - public void testConstructorBeanContext() { - try { - BeanContextSupport sup = new BeanContextSupport(null); - } - catch (Exception e) { - fail("Unexpected exception: " + e + " caused by: " + e.getCause()); - } - } - - /** * Test constructor with no parameters.

- * - * @see BeanContextSupport#BeanContextSupport() - */ - public void testConstructor() { - try { - BeanContextSupport sup = new BeanContextSupport(); - } - catch (Exception e) { - fail("Unexpected exception: " + e + " caused by: " + e.getCause()); - } - } - - /** TEST METHODS **/ - - /** - * Test method createBCSChild() with Object, Object parameters.

- */ - 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()); - } - } - - /** - * Test method setLocale() with Locale parameter.

- */ - 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()); - } - } - - /** - * Test method bcsChildren() with no parameters.

- */ - 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()); - } - } - - /** - * Test method retainAll() with Collection parameter.

- */ - 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()); - } - } - - /** - * Test method removeAll() with Collection parameter.

- */ - 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()); - } - } - - /** - * Test method containsAll() with Collection parameter.

- */ - 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()); - } - } - - /** - * Test method addAll() with Collection parameter.

- */ - 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()); - } - } - - /** - * Test method remove() with Object, boolean parameters.

- */ - 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()); - } - } - - /** - * Test method remove() with Object parameter.

- */ - 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()); - } - } - - /** - * Test method containsKey() with Object parameter.

- */ - 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()); - } - } - - /** - * Test method contains() with Object parameter.

- */ - 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()); - } - } - - /** - * Test method add() with Object parameter.

- */ - 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()); - } - } - - /** - * Test method toArray() with no parameters.

- */ - 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()); - } - } - - /** - * Test method copyChildren() with no parameters.

- */ - 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()); - } - } - - /** - * Test method removeBeanContextMembershipListener() with BeanContextMembershipListener parameter.

- */ - 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()); - } - } - - /** - * Test method addBeanContextMembershipListener() with BeanContextMembershipListener parameter.

- */ - 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()); - } - } - - /** - * Test method getBeanContextPeer() with no parameters.

- */ - 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()); - } - } - - /** - * Test method vetoableChange() with PropertyChangeEvent parameter.

- */ - 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()); - } - } - - /** - * Test method propertyChange() with PropertyChangeEvent parameter.

- */ - 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()); - } - } - - /** - * Test method isEmpty() with no parameters.

- */ - 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()); - } - } - - /** - * Test method clear() with no parameters.

- */ - 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()); - } - } - - /** - * Test method size() with no parameters.

- */ - 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()); - } - } - - /** - * Test method getResourceAsStream() with String, BeanContextChild=null parameters.

- */ - 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) { - } - } - - /** - * Test method getResourceAsStream() with String=null, BeanContextChild=null parameters.

- */ - 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) { - } - } - - /** - * Test method vetoableChange() with PropertyChangeEvent=null parameter.

- */ - public void test_vetoableChangeLjava_beans_PropertyChangeEvent() { - BeanContextSupport obj = new BeanContextSupport(); - try { - obj.vetoableChange(null); - fail("NullPointerException expected"); - } catch (PropertyVetoException p) { - fail("NullPointerException expected"); - } catch (NullPointerException t) { - } - } - - /** - * Test method getResource() with String!=null, BeanContextChild=null parameters.

- */ - public void test_getResourceLjava_lang_StringLjava_beans_beancontext_BeanContextChild() { - BeanContextSupport obj = new BeanContextSupport(); - try { - obj.getResource("", null); - fail("NullPointerException expected"); - } catch (NullPointerException t) { - } - } - - /** - * Test method getResource() with String=null, BeanContextChild=null parameters.

- */ - 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) { - } - } - - /** UTILITY METHODS **/ - - /** - * Create BeanContextMembershipListener instance - */ - private BeanContextMembershipListener getBeanContextMembershipListener() { - return new BeanContextMembershipListener() { - - public void childrenAdded(BeanContextMembershipEvent bcme) { - ; - } - - public void childrenRemoved(BeanContextMembershipEvent bcme) { - ; - } - }; - } - - /** STANDARD ENDING **/ - - /** - * Start testing from the command line.

- */ - public static Test suite() { - return new TestSuite(BeanContextSupportTest.class); - } - - /** - * Start testing from the command line.

- * - * @param args - Command line parameters.

- */ - public static void main(String args[]) { - junit.textui.TestRunner.run(suite()); - } +/* + * Copyright 2005 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 Sergey A. Krivenko + * @version $Revision: 1.4.4.2 $ + */ +package java.beans.beancontext; + +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.

+ * + * @author Sergey A. Krivenko + * @version $Revision: 1.4.4.2 $ + */ + +public class BeanContextSupportTest extends TestCase { + + /** STANDARD BEGINNING **/ + + /** + * No arguments constructor to enable serialization.

+ */ + public BeanContextSupportTest() { + super(); + } + + /** + * Constructs this test case with the given name.

+ * + * @param name - The name for this test case.

+ */ + public BeanContextSupportTest(String name) { + super(name); + } + + /** TEST CONSTRUCTORS **/ + + /** * Test constructor with BeanContext, Locale, boolean, boolean parameters.

+ * + * @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()); + } + } + + /** * Test constructor with BeanContext, Locale, boolean parameters.

+ * + * @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()); + } + } + + /** * Test constructor with BeanContext, Locale parameters.

+ * + * @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()); + } + } + + /** * Test constructor with BeanContext parameter.

+ * + * @see BeanContextSupport#BeanContextSupport(BeanContext) + */ + public void testConstructorBeanContext() { + try { + BeanContextSupport sup = new BeanContextSupport(null); + } + catch (Exception e) { + fail("Unexpected exception: " + e + " caused by: " + e.getCause()); + } + } + + /** * Test constructor with no parameters.

+ * + * @see BeanContextSupport#BeanContextSupport() + */ + public void testConstructor() { + try { + BeanContextSupport sup = new BeanContextSupport(); + } + catch (Exception e) { + fail("Unexpected exception: " + e + " caused by: " + e.getCause()); + } + } + + /** TEST METHODS **/ + + /** + * Test method createBCSChild() with Object, Object parameters.

+ */ + 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()); + } + } + + /** + * Test method setLocale() with Locale parameter.

+ */ + 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()); + } + } + + /** + * Test method bcsChildren() with no parameters.

+ */ + 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()); + } + } + + /** + * Test method retainAll() with Collection parameter.

+ */ + 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()); + } + } + + /** + * Test method removeAll() with Collection parameter.

+ */ + 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()); + } + } + + /** + * Test method containsAll() with Collection parameter.

+ */ + 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()); + } + } + + /** + * Test method addAll() with Collection parameter.

+ */ + 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()); + } + } + + /** + * Test method remove() with Object, boolean parameters.

+ */ + 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()); + } + } + + /** + * Test method remove() with Object parameter.

+ */ + 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()); + } + } + + /** + * Test method containsKey() with Object parameter.

+ */ + 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()); + } + } + + /** + * Test method contains() with Object parameter.

+ */ + 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()); + } + } + + /** + * Test method add() with Object parameter.

+ */ + 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()); + } + } + + /** + * Test method toArray() with no parameters.

+ */ + 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()); + } + } + + /** + * Test method copyChildren() with no parameters.

+ */ + 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()); + } + } + + /** + * Test method removeBeanContextMembershipListener() with BeanContextMembershipListener parameter.

+ */ + 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()); + } + } + + /** + * Test method addBeanContextMembershipListener() with BeanContextMembershipListener parameter.

+ */ + 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()); + } + } + + /** + * Test method getBeanContextPeer() with no parameters.

+ */ + 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()); + } + } + + /** + * Test method vetoableChange() with PropertyChangeEvent parameter.

+ */ + 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()); + } + } + + /** + * Test method propertyChange() with PropertyChangeEvent parameter.

+ */ + 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()); + } + } + + /** + * Test method isEmpty() with no parameters.

+ */ + 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()); + } + } + + /** + * Test method clear() with no parameters.

+ */ + 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()); + } + } + + /** + * Test method size() with no parameters.

+ */ + 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()); + } + } + + /** + * Test method getResourceAsStream() with String, BeanContextChild=null parameters.

+ */ + 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) { + } + } + + /** + * Test method getResourceAsStream() with String=null, BeanContextChild=null parameters.

+ */ + 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) { + } + } + + /** + * Test method vetoableChange() with PropertyChangeEvent=null parameter.

+ */ + public void test_vetoableChangeLjava_beans_PropertyChangeEvent() { + BeanContextSupport obj = new BeanContextSupport(); + try { + obj.vetoableChange(null); + fail("NullPointerException expected"); + } catch (PropertyVetoException p) { + fail("NullPointerException expected"); + } catch (NullPointerException t) { + } + } + + /** + * Test method getResource() with String!=null, BeanContextChild=null parameters.

+ */ + public void test_getResourceLjava_lang_StringLjava_beans_beancontext_BeanContextChild() { + BeanContextSupport obj = new BeanContextSupport(); + try { + obj.getResource("", null); + fail("NullPointerException expected"); + } catch (NullPointerException t) { + } + } + + /** + * Test method getResource() with String=null, BeanContextChild=null parameters.

+ */ + 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) { + } + } + + /** UTILITY METHODS **/ + + /** + * Create BeanContextMembershipListener instance + */ + private BeanContextMembershipListener getBeanContextMembershipListener() { + return new BeanContextMembershipListener() { + + public void childrenAdded(BeanContextMembershipEvent bcme) { + ; + } + + public void childrenRemoved(BeanContextMembershipEvent bcme) { + ; + } + }; + } + + /** STANDARD ENDING **/ + + /** + * Start testing from the command line.

+ */ + public static Test suite() { + return new TestSuite(BeanContextSupportTest.class); + } + + /** + * Start testing from the command line.

+ * + * @param args - Command line parameters.

+ */ + public static void main(String args[]) { + junit.textui.TestRunner.run(suite()); + } } Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/AllTests.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/AllTests.java?rev=412641&r1=412640&r2=412641&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/AllTests.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/AllTests.java Wed Jun 7 20:40:24 2006 @@ -1,38 +1,38 @@ -/* Copyright 2005 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. - */ - -package org.apache.harmony.beans.tests; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Test suite that includes all tests for the Beans project. - */ -public class AllTests { - - public static void main(String[] args) { - junit.textui.TestRunner.run(AllTests.suite()); - } - - public static Test suite() { - TestSuite suite = new TestSuite("Beans test suites"); - // $JUnit-BEGIN$ - suite.addTest(org.apache.harmony.beans.tests.java.beans.AllTests.suite()); - suite.addTest(org.apache.harmony.beans.tests.java.beans.beancontext.AllTests.suite()); - // $JUnit-END$ - return suite; - } -} +/* Copyright 2005 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. + */ + +package org.apache.harmony.beans.tests; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Test suite that includes all tests for the Beans project. + */ +public class AllTests { + + public static void main(String[] args) { + junit.textui.TestRunner.run(AllTests.suite()); + } + + public static Test suite() { + TestSuite suite = new TestSuite("Beans test suites"); + // $JUnit-BEGIN$ + suite.addTest(org.apache.harmony.beans.tests.java.beans.AllTests.suite()); + suite.addTest(org.apache.harmony.beans.tests.java.beans.beancontext.AllTests.suite()); + // $JUnit-END$ + return suite; + } +} Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/AllTests.java URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/AllTests.java?rev=412641&r1=412640&r2=412641&view=diff ============================================================================== --- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/AllTests.java (original) +++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/AllTests.java Wed Jun 7 20:40:24 2006 @@ -1,70 +1,70 @@ -/* Copyright 2005 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. - */ - -package org.apache.harmony.beans.tests.java.beans; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTests { - - public static Test suite() { - TestSuite suite = new TestSuite( - "Suite for org.apache.harmony.beans.tests.java.beans"); - // $JUnit-BEGIN$ - suite.addTestSuite(IntrospectorTest.class); - suite.addTestSuite(VisibilityTest.class); - suite.addTestSuite(PropertyChangeSupportTest.class); - suite.addTestSuite(DefaultPersistenceDelegateTest.class); - suite.addTestSuite(PersistenceDelegateTest.class); - suite.addTestSuite(CustomizedPersistenceDelegateTest.class); - suite.addTestSuite(PropertyChangeListenerProxyTest.class); - suite.addTestSuite(VetoableChangeListenerTest.class); - suite.addTestSuite(StatementTest.class); - suite.addTestSuite(PropertyChangeEventTest.class); - suite.addTestSuite(EncoderTest.class); - suite.addTestSuite(SimpleBeanInfoTest.class); - suite.addTestSuite(PropertyVetoExceptionTest.class); - suite.addTestSuite(BeanInfoTest.class); - suite.addTestSuite(XMLEncoderTest.class); - suite.addTestSuite(BeansTest.class); - suite.addTestSuite(BeanDescriptorTest.class); - suite.addTestSuite(MethodDescriptorTest.class); - suite.addTestSuite(PropertyChangeListenerTest.class); - suite.addTestSuite(PersistenceDelegateTest.class); - suite.addTestSuite(ExpressionTest.class); - suite.addTestSuite(IndexedPropertyDescriptorTest.class); - suite.addTestSuite(EventSetDescriptorTest.class); - suite.addTestSuite(IntrospectionExceptionTest.class); - suite.addTestSuite(CustomizerTest.class); - suite.addTestSuite(FeatureDescriptorTest.class); - suite.addTestSuite(DesignModeTest.class); - suite.addTestSuite(CustomizedPersistenceDelegateTest.class); - suite.addTestSuite(VetoableChangeListenerProxyTest.class); - suite.addTestSuite(VetoableChangeSupportTest.class); - suite.addTestSuite(PropertyEditorManagerTest.class); - suite.addTestSuite(ParameterDescriptorTest.class); - suite.addTestSuite(AppletInitializerTest.class); - suite.addTestSuite(PropertyEditorSupportTest.class); - suite.addTestSuite(PropertyEditorTest.class); - suite.addTestSuite(PropertyDescriptorTest.class); - suite.addTestSuite(ExceptionListenerTest.class); - suite.addTestSuite(XMLDecoderTest.class); - suite.addTestSuite(EventHandlerTest.class); - - // $JUnit-END$ - return suite; - } -} +/* Copyright 2005 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. + */ + +package org.apache.harmony.beans.tests.java.beans; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTests { + + public static Test suite() { + TestSuite suite = new TestSuite( + "Suite for org.apache.harmony.beans.tests.java.beans"); + // $JUnit-BEGIN$ + suite.addTestSuite(IntrospectorTest.class); + suite.addTestSuite(VisibilityTest.class); + suite.addTestSuite(PropertyChangeSupportTest.class); + suite.addTestSuite(DefaultPersistenceDelegateTest.class); + suite.addTestSuite(PersistenceDelegateTest.class); + suite.addTestSuite(CustomizedPersistenceDelegateTest.class); + suite.addTestSuite(PropertyChangeListenerProxyTest.class); + suite.addTestSuite(VetoableChangeListenerTest.class); + suite.addTestSuite(StatementTest.class); + suite.addTestSuite(PropertyChangeEventTest.class); + suite.addTestSuite(EncoderTest.class); + suite.addTestSuite(SimpleBeanInfoTest.class); + suite.addTestSuite(PropertyVetoExceptionTest.class); + suite.addTestSuite(BeanInfoTest.class); + suite.addTestSuite(XMLEncoderTest.class); + suite.addTestSuite(BeansTest.class); + suite.addTestSuite(BeanDescriptorTest.class); + suite.addTestSuite(MethodDescriptorTest.class); + suite.addTestSuite(PropertyChangeListenerTest.class); + suite.addTestSuite(PersistenceDelegateTest.class); + suite.addTestSuite(ExpressionTest.class); + suite.addTestSuite(IndexedPropertyDescriptorTest.class); + suite.addTestSuite(EventSetDescriptorTest.class); + suite.addTestSuite(IntrospectionExceptionTest.class); + suite.addTestSuite(CustomizerTest.class); + suite.addTestSuite(FeatureDescriptorTest.class); + suite.addTestSuite(DesignModeTest.class); + suite.addTestSuite(CustomizedPersistenceDelegateTest.class); + suite.addTestSuite(VetoableChangeListenerProxyTest.class); + suite.addTestSuite(VetoableChangeSupportTest.class); + suite.addTestSuite(PropertyEditorManagerTest.class); + suite.addTestSuite(ParameterDescriptorTest.class); + suite.addTestSuite(AppletInitializerTest.class); + suite.addTestSuite(PropertyEditorSupportTest.class); + suite.addTestSuite(PropertyEditorTest.class); + suite.addTestSuite(PropertyDescriptorTest.class); + suite.addTestSuite(ExceptionListenerTest.class); + suite.addTestSuite(XMLDecoderTest.class); + suite.addTestSuite(EventHandlerTest.class); + + // $JUnit-END$ + return suite; + } +}