Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 64650 invoked from network); 27 Nov 2007 13:51:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Nov 2007 13:51:21 -0000 Received: (qmail 32187 invoked by uid 500); 27 Nov 2007 13:51:08 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 32094 invoked by uid 500); 27 Nov 2007 13:51:08 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 32085 invoked by uid 99); 27 Nov 2007 13:51:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Nov 2007 05:51:08 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Nov 2007 13:51:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 85FB21A9832; Tue, 27 Nov 2007 05:50:55 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r598643 - /harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java Date: Tue, 27 Nov 2007 13:50:55 -0000 To: commits@harmony.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071127135055.85FB21A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tellison Date: Tue Nov 27 05:50:50 2007 New Revision: 598643 URL: http://svn.apache.org/viewvc?rev=598643&view=rev Log: Apply regression test for HARMONY-2506 ([classlib][beans] BeanContextServiceRevokedEvent.getSourceAsBeanContextServices() throws unexpected ClassCastException) Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java?rev=598643&r1=598642&r2=598643&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/beancontext/BeanContextServiceRevokedEventTest.java Tue Nov 27 05:50:50 2007 @@ -17,13 +17,25 @@ package org.apache.harmony.beans.tests.java.beans.beancontext; +import java.beans.PropertyChangeListener; +import java.beans.VetoableChangeListener; import java.beans.beancontext.BeanContext; +import java.beans.beancontext.BeanContextChild; +import java.beans.beancontext.BeanContextMembershipListener; +import java.beans.beancontext.BeanContextServiceAvailableEvent; +import java.beans.beancontext.BeanContextServiceProvider; import java.beans.beancontext.BeanContextServiceRevokedEvent; +import java.beans.beancontext.BeanContextServiceRevokedListener; import java.beans.beancontext.BeanContextServices; +import java.beans.beancontext.BeanContextServicesListener; import java.beans.beancontext.BeanContextServicesSupport; import java.io.IOException; +import java.io.InputStream; import java.io.Serializable; +import java.net.URL; import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; import java.util.Locale; import junit.framework.TestCase; @@ -86,14 +98,14 @@ } catch (NullPointerException e) { // expected } - + try { event.isServiceClass(null); fail("NPE expected"); } catch (NullPointerException e) { // expected } - + event = new MockBeanContextServiceRevokedEvent(services, services .getClass(), true); assertFalse(event.isServiceClass(null)); @@ -123,6 +135,333 @@ event = new BeanContextServiceRevokedEvent(sup, MockBeanContextServices.class, false); assertNotNull(event.getSourceAsBeanContextServices()); + + // Regression for HARMONY-2506 + BeanContextServiceRevokedEvent obj = new BeanContextServiceRevokedEvent( + new testBeanContextServices(), Integer.class, true); + + obj.setPropagatedFrom(new testBeanContext()); + assertNotNull(obj.getSourceAsBeanContextServices()); + } + + class testBeanContext implements BeanContext { + public void removeBeanContextMembershipListener( + BeanContextMembershipListener p0) { + return; + } + + public void addBeanContextMembershipListener( + BeanContextMembershipListener p0) { + return; + } + + public URL getResource(String p0, BeanContextChild p1) { + return null; + } + + public InputStream getResourceAsStream(String p0, BeanContextChild p1) { + return null; + } + + public Object instantiateChild(String p0) { + return null; + } + + public void removeVetoableChangeListener(String p0, + VetoableChangeListener p1) { + return; + } + + public void addVetoableChangeListener(String p0, + VetoableChangeListener p1) { + return; + } + + public void removePropertyChangeListener(String p0, + PropertyChangeListener p1) { + return; + } + + public void addPropertyChangeListener(String p0, + PropertyChangeListener p1) { + return; + } + + public BeanContext getBeanContext() { + return null; + } + + public void setBeanContext(BeanContext p0) { + return; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object p0) { + return false; + } + + public void clear() { + return; + } + + public boolean retainAll(Collection p0) { + return false; + } + + public boolean removeAll(Collection p0) { + return false; + } + + public boolean addAll(Collection p0) { + return false; + } + + public boolean containsAll(Collection p0) { + return false; + } + + public boolean remove(Object p0) { + return false; + } + + public boolean add(Object p0) { + return false; + } + + public Object[] toArray(Object[] p0) { + return null; + } + + public Object[] toArray() { + return null; + } + + public Iterator iterator() { + return null; + } + + public boolean contains(Object p0) { + return false; + } + + public boolean isEmpty() { + return false; + } + + public int size() { + return 0; + } + + public boolean isDesignTime() { + return false; + } + + public void setDesignTime(boolean p0) { + return; + } + + public boolean avoidingGui() { + return false; + } + + public void okToUseGui() { + return; + } + + public void dontUseGui() { + return; + } + + public boolean needsGui() { + return false; + } + } + + class testBeanContextServices implements BeanContextServices { + public void removeBeanContextServicesListener( + BeanContextServicesListener p0) { + return; + } + + public void addBeanContextServicesListener( + BeanContextServicesListener p0) { + return; + } + + public Iterator getCurrentServiceSelectors(Class p0) { + return null; + } + + public Iterator getCurrentServiceClasses() { + return null; + } + + public void releaseService(BeanContextChild p0, Object p1, Object p2) { + return; + } + + public Object getService(BeanContextChild p0, Object p1, Class p2, + Object p3, BeanContextServiceRevokedListener p4) { + return null; + } + + public boolean hasService(Class p0) { + return false; + } + + public void revokeService(Class p0, BeanContextServiceProvider p1, + boolean p2) { + return; + } + + public boolean addService(Class p0, BeanContextServiceProvider p1) { + return false; + } + + public void removeBeanContextMembershipListener( + BeanContextMembershipListener p0) { + return; + } + + public void addBeanContextMembershipListener( + BeanContextMembershipListener p0) { + return; + } + + public URL getResource(String p0, BeanContextChild p1) { + return null; + } + + public InputStream getResourceAsStream(String p0, BeanContextChild p1) { + return null; + } + + public Object instantiateChild(String p0) { + return null; + } + + public void removeVetoableChangeListener(String p0, + VetoableChangeListener p1) { + return; + } + + public void addVetoableChangeListener(String p0, + VetoableChangeListener p1) { + return; + } + + public void removePropertyChangeListener(String p0, + PropertyChangeListener p1) { + return; + } + + public void addPropertyChangeListener(String p0, + PropertyChangeListener p1) { + return; + } + + public BeanContext getBeanContext() { + return null; + } + + public void setBeanContext(BeanContext p0) { + return; + } + + public int hashCode() { + return 0; + } + + public boolean equals(Object p0) { + return false; + } + + public void clear() { + return; + } + + public boolean retainAll(Collection p0) { + return false; + } + + public boolean removeAll(Collection p0) { + return false; + } + + public boolean addAll(Collection p0) { + return false; + } + + public boolean containsAll(Collection p0) { + return false; + } + + public boolean remove(Object p0) { + return false; + } + + public boolean add(Object p0) { + return false; + } + + public Object[] toArray(Object[] p0) { + return null; + } + + public Object[] toArray() { + return null; + } + + public Iterator iterator() { + return null; + } + + public boolean contains(Object p0) { + return false; + } + + public boolean isEmpty() { + return false; + } + + public int size() { + return 0; + } + + public boolean isDesignTime() { + return false; + } + + public void setDesignTime(boolean p0) { + return; + } + + public boolean avoidingGui() { + return false; + } + + public void okToUseGui() { + return; + } + + public void dontUseGui() { + return; + } + + public boolean needsGui() { + return false; + } + + public void serviceAvailable(BeanContextServiceAvailableEvent p0) { + return; + } + + public void serviceRevoked(BeanContextServiceRevokedEvent p0) { + return; + } } public void testGetServiceClass() { @@ -164,19 +503,19 @@ } - public void testSerialization_Compatibility() throws Exception { - BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent( - new MockBeanContextServices(), ArrayList.class, true); - event.setPropagatedFrom(new MockBeanContextDelegateS("from ID")); - SerializationTest.verifyGolden(this, event, new SerializableAssert(){ - public void assertDeserialized(Serializable orig, Serializable ser) { - assertEqualsSerially((BeanContextServiceRevokedEvent) orig, - (BeanContextServiceRevokedEvent) ser); - } - }); - } - - public void testConstructor() throws Exception { + public void testSerialization_Compatibility() throws Exception { + BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent( + new MockBeanContextServices(), ArrayList.class, true); + event.setPropagatedFrom(new MockBeanContextDelegateS("from ID")); + SerializationTest.verifyGolden(this, event, new SerializableAssert() { + public void assertDeserialized(Serializable orig, Serializable ser) { + assertEqualsSerially((BeanContextServiceRevokedEvent) orig, + (BeanContextServiceRevokedEvent) ser); + } + }); + } + + public void testConstructor() throws Exception { BeanContextServices bcs = new MockBeanContextServices(); BeanContextServiceRevokedEvent event = new BeanContextServiceRevokedEvent( bcs, ArrayList.class, true); @@ -187,7 +526,7 @@ assertSame(bcs, event.getSourceAsBeanContextServices()); assertFalse(event.isPropagated()); } - + private void assertEqualsSerially(BeanContextServiceRevokedEvent orig, BeanContextServiceRevokedEvent ser) { assertNull(ser.getSource());