You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by to...@apache.org on 2007/07/19 08:17:34 UTC
svn commit: r557499 - in /harmony/enhanced/classlib/trunk/modules/beans/src:
main/java/java/beans/ test/java/org/apache/harmony/beans/tests/java/beans/
test/support/java/org/apache/harmony/beans/tests/support/mock/
Author: tonywu
Date: Wed Jul 18 23:17:33 2007
New Revision: 557499
URL: http://svn.apache.org/viewvc?view=rev&rev=557499
Log:
correct the behavior of merging display name
Added:
harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterface.java (with props)
harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterfaceBeanInfo.java (with props)
harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClass.java (with props)
harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClassBeanInfo.java (with props)
harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClass.java (with props)
harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClassBeanInfo.java (with props)
Modified:
harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/EventSetDescriptor.java?view=diff&rev=557499&r1=557498&r2=557499
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/EventSetDescriptor.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/EventSetDescriptor.java Wed Jul 18 23:17:33 2007
@@ -52,7 +52,6 @@
listenerMethodName);
setName(eventSetName);
- setDisplayName(eventSetName);
this.listenerType = listenerType;
m = findListenerMethodByName(listenerMethodName);
checkEventType(eventSetName, m);
@@ -92,7 +91,6 @@
listenerMethodNames);
setName(eventSetName);
- setDisplayName(eventSetName);
this.listenerType = listenerType;
listenerMethodDescriptors = new ArrayList<MethodDescriptor>();
@@ -153,7 +151,6 @@
throws IntrospectionException {
setName(eventSetName);
- setDisplayName(eventSetName);
this.listenerType = listenerType;
this.listenerMethods = listenerMethods;
Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java?view=diff&rev=557499&r1=557498&r2=557499
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/PropertyDescriptor.java Wed Jul 18 23:17:33 2007
@@ -45,7 +45,6 @@
throw new IntrospectionException(Messages.getString("beans.04")); //$NON-NLS-1$
}
this.setName(propertyName);
- this.setDisplayName(propertyName);
if (getterName != null) {
if(getterName.length() == 0){
throw new IntrospectionException("read or write method cannot be empty."); //$NON-NLS-1$
@@ -71,7 +70,6 @@
throw new IntrospectionException(Messages.getString("beans.04")); //$NON-NLS-1$
}
this.setName(propertyName);
- this.setDisplayName(propertyName);
setReadMethod(getter);
setWriteMethod(setter);
}
@@ -85,7 +83,6 @@
throw new IntrospectionException(Messages.getString("beans.04")); //$NON-NLS-1$
}
this.setName(propertyName);
- this.setDisplayName(propertyName);
try {
setReadMethod(beanClass, createDefaultMethodName(propertyName, "is")); //$NON-NLS-1$
} catch (Exception e) {
Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java?view=diff&rev=557499&r1=557498&r2=557499
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.java Wed Jul 18 23:17:33 2007
@@ -62,6 +62,7 @@
import org.apache.harmony.beans.tests.support.mock.MockFooSub;
import org.apache.harmony.beans.tests.support.mock.MockFooSubSub;
import org.apache.harmony.beans.tests.support.mock.MockJavaBean;
+import org.apache.harmony.beans.tests.support.mock.MockSubClass;
/**
* Unit test for Introspector.
@@ -440,11 +441,10 @@
assertTrue(contains("setName", mds));
assertTrue(contains("getComplexLabel", mds));
assertTrue(contains("setComplexLabel", mds));
- try{
- BeanInfo info2 = Introspector.getBeanInfo(MockFoo.class,
- Serializable.class);
+ try {
+ Introspector.getBeanInfo(MockFoo.class, Serializable.class);
fail("Shoule throw exception, stopclass must be superclass of given bean");
- }catch(IntrospectionException e){
+ } catch (IntrospectionException e) {
}
}
@@ -1282,6 +1282,41 @@
assertNotNull(pds[1].getWriteMethod());
}
+ public void testGetBeanInfoComplexHierarchy() throws Exception {
+ Introspector.flushCaches();
+ BeanInfo subinfo = Introspector.getBeanInfo(MockSubClass.class);
+ PropertyDescriptor[] allProps = subinfo.getPropertyDescriptors();
+ boolean propFound = false;
+ for (int i = 0; i < allProps.length; i++) {
+ if (allProps[i].getName().equals("value")) {
+ assertTrue(allProps[i].isExpert());
+ assertTrue(allProps[i].isHidden());
+ assertTrue(allProps[i].isBound());
+ assertFalse(allProps[i].isConstrained());
+ assertEquals("adddisplay", allProps[i].getDisplayName());
+ assertEquals("subdesc", allProps[i].getShortDescription());
+ propFound = true;
+ break;
+ }
+ }
+ assertTrue(propFound);
+
+ boolean eventFound = false;
+ EventSetDescriptor[] events = subinfo.getEventSetDescriptors();
+ for (int i = 0; i < events.length; i++) {
+ if (events[i].getName().equals("mockPropertyChange")) {
+ assertTrue(events[i].isExpert());
+ assertTrue(events[i].isHidden());
+ assertFalse(events[i].isUnicast());
+ assertFalse(events[i].isInDefaultEventSet());
+ assertEquals("adddisplay", events[i].getDisplayName());
+ assertEquals("subdesc", events[i].getShortDescription());
+ eventFound = true;
+ break;
+ }
+ }
+ assertTrue(eventFound);
+ }
static class FakeFoxInfo {
public int getProp6(boolean i) {
Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterface.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterface.java?view=auto&rev=557499
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterface.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterface.java Wed Jul 18 23:17:33 2007
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.support.mock;
+
+public interface MockInterface {
+ int getValue();
+ void setValue(int value);
+}
Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterface.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterfaceBeanInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterfaceBeanInfo.java?view=auto&rev=557499
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterfaceBeanInfo.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterfaceBeanInfo.java Wed Jul 18 23:17:33 2007
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.support.mock;
+
+import java.beans.EventSetDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class MockInterfaceBeanInfo extends SimpleBeanInfo{
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ PropertyDescriptor P = null;
+ try {
+ P = new PropertyDescriptor("value", MockInterface.class);
+ P.setExpert(true);
+ P.setBound(true);
+ P.setConstrained(false);
+ P.setDisplayName("adddisplay");
+ P.setShortDescription("adddesc");
+ } catch (IntrospectionException e) {
+ e.printStackTrace();
+ return null;
+ }
+ return new PropertyDescriptor[]{ P };
+ }
+
+ public EventSetDescriptor[] getEventSetDescriptors(){
+ EventSetDescriptor event = null;
+ try{
+ event = new EventSetDescriptor(MockSuperClass.class, "mockPropertyChange", MockPropertyChangeListener.class, "mockPropertyChange");
+ event.setHidden(false);
+ event.setExpert(true);
+ event.setShortDescription("adddesc");
+ event.setDisplayName("adddisplay");
+ event.setUnicast(true);
+ event.setInDefaultEventSet(false);
+ }catch(IntrospectionException e){
+ return null;
+ }
+ return new EventSetDescriptor[]{event};
+ }
+}
Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockInterfaceBeanInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClass.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClass.java?view=auto&rev=557499
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClass.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClass.java Wed Jul 18 23:17:33 2007
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.support.mock;
+
+public class MockSubClass extends MockSuperClass implements MockInterface{
+
+}
Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClass.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClassBeanInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClassBeanInfo.java?view=auto&rev=557499
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClassBeanInfo.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClassBeanInfo.java Wed Jul 18 23:17:33 2007
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.support.mock;
+
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class MockSubClassBeanInfo extends SimpleBeanInfo{
+
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ return new BeanInfo[] {
+ Introspector.getBeanInfo(MockInterface.class) };
+ } catch (IntrospectionException e) {
+ }
+ return new BeanInfo[] {};
+ }
+
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ PropertyDescriptor P = null;
+ try {
+ P = new PropertyDescriptor("value",MockSuperClass.class);
+ P.setHidden(true);
+ P.setBound(false);
+ P.setConstrained(false);
+ P.setShortDescription("subdesc");
+ } catch (IntrospectionException e) {
+ e.printStackTrace();
+ return null;
+ }
+ return new PropertyDescriptor[]{ P };
+ }
+
+ public EventSetDescriptor[] getEventSetDescriptors(){
+ EventSetDescriptor event = null;
+ try{
+ event = new EventSetDescriptor(MockSuperClass.class, "mockPropertyChange", MockPropertyChangeListener.class, "mockPropertyChange");
+ event.setHidden(true);
+ event.setShortDescription("subdesc");
+ event.setUnicast(false);
+ event.setInDefaultEventSet(true);
+ }catch(IntrospectionException e){
+ return null;
+ }
+ return new EventSetDescriptor[]{event};
+ }
+}
Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSubClassBeanInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClass.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClass.java?view=auto&rev=557499
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClass.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClass.java Wed Jul 18 23:17:33 2007
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.support.mock;
+
+public class MockSuperClass {
+ private int num = 1;
+ public int getValue() {
+ return num;
+ }
+ public void setValue(int value) {
+ this.num = value;
+ }
+
+ public void addMockPropertyChangeListener(MockPropertyChangeListener a) {
+ }
+ public void removeMockPropertyChangeListener(MockPropertyChangeListener a) {
+ }
+}
Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClass.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClassBeanInfo.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClassBeanInfo.java?view=auto&rev=557499
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClassBeanInfo.java (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClassBeanInfo.java Wed Jul 18 23:17:33 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.support.mock;
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class MockSuperClassBeanInfo extends SimpleBeanInfo{
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ PropertyDescriptor P = null;
+ try {
+ P = new PropertyDescriptor("value",MockSuperClass.class);
+ P.setHidden(true);
+ P.setBound(false);
+ P.setConstrained(true);
+ } catch (IntrospectionException e) {
+ e.printStackTrace();
+ return null;
+ }
+ return new PropertyDescriptor[]{ P };
+ }
+}
Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockSuperClassBeanInfo.java
------------------------------------------------------------------------------
svn:eol-style = native